public class Server extends Object implements ConnectionCountMonitor, ServiceFinder
Constructor and Description |
---|
Server(BootProperties props,
String serverType,
Trace appTrace)
Generate the Server from Java properties.
|
Modifier and Type | Method and Description |
---|---|
void |
connectionCountChange(int delta)
Track the number of connections, so server can exit gracefully.
|
void |
enqueue(Runnable runnable)
Drop a runnable onto the main run queue.
|
void |
enqueueSlowTask(Callable<Object> task,
ArgRunnable resultHandler)
Drop a task onto the slow queue.
|
void |
findService(String service,
ArgRunnable handler,
boolean monitor)
Issue a request for service information to the broker.
|
void |
findServiceLink(String service,
ArgRunnable handler)
Obtain a message channel to a service.
|
List<HostDesc> |
listeners()
Get the configured listeners for this server.
|
NetworkManager |
networkManager()
Get this server's network manager.
|
ObjDB |
openObjectDatabase(String propRoot)
Open an asynchronous object database whose location (directory path or
remote repository host) is specified by properties.
|
BootProperties |
props()
Get this server's properties.
|
void |
registerLoadWatcher(LoadWatcher watcher)
Add an object to the collection of objects to be notified when the
server samples its load.
|
void |
registerReinitWatcher(ReinitWatcher watcher)
Add an object to the collection of objects to be notified when the
server is being reinitialized.
|
void |
registerService(ServiceDesc service)
Add a new service offering to the collection of services provided by
this server.
|
void |
registerShutdownWatcher(ShutdownWatcher watcher)
Add an object to the collection of objects to be notified when the
server is being shut down.
|
void |
reinit()
Reinitialize the server.
|
String |
serverName()
Get this server's name.
|
List<ServiceDesc> |
services()
Get the services being offered by this server.
|
void |
setServiceRefTable(RefTable serviceRefTable)
Assign the ref table that will be used to dispatch messages received
from connected services.
|
void |
shutdown(boolean kill)
Shut down the server.
|
int |
startListeners(String propRoot,
ServiceFactory serviceFactory)
Start listening for connections on all the ports that are configured.
|
Trace |
trace()
Return the application trace object for this server.
|
void |
unregisterLoadWatcher(LoadWatcher watcher)
Remove an object from the collection of objects that are notified when
the server samples its load.
|
void |
unregisterReinitWatcher(ReinitWatcher watcher)
Remove an object from the collection of objects that are notified when
the server is being reinitialized.
|
void |
unregisterShutdownWatcher(ShutdownWatcher watcher)
Remove an object from the collection of objects that are notified when
the server is being shut down.
|
String |
version()
Return the version ID string for this build.
|
public Server(BootProperties props, String serverType, Trace appTrace)
props
- The properties, as determined by the boot process.serverType
- Server type tag (for generating property names).appTrace
- Trace object for event logging.public void connectionCountChange(int delta)
connectionCountChange
in interface ConnectionCountMonitor
delta
- An upward or downward adjustment to the connection count.public void enqueue(Runnable runnable)
runnable
- The thing to run.public void enqueueSlowTask(Callable<Object> task, ArgRunnable resultHandler)
task
- Callable that executes the task. This will be executed in
a separate thread and so is permitted to block.resultHandler
- Thunk that will be invoked with the result
returned by the task. This will be executed on the main run queue.public void findService(String service, ArgRunnable handler, boolean monitor)
findService
in interface ServiceFinder
service
- The service desired.handler
- Object to receive the asynchronous result(s).monitor
- If true, keep watching for more results after the first.public void findServiceLink(String service, ArgRunnable handler)
service
- The service desiredhandler
- A runnable that will be invoked with a service link to
the requested service once the connection is located or created. The
handler will be passed a null if no connection was possible.public List<HostDesc> listeners()
public NetworkManager networkManager()
public ObjDB openObjectDatabase(String propRoot)
propRoot
- Prefix string for all the properties describing the odb
that is to be opened.public BootProperties props()
public void registerLoadWatcher(LoadWatcher watcher)
watcher
- An object to notify about load samples.public void unregisterLoadWatcher(LoadWatcher watcher)
watcher
- The object to stop notifying about load samples.public void registerReinitWatcher(ReinitWatcher watcher)
watcher
- An object to notify at reinitialization time.public void unregisterReinitWatcher(ReinitWatcher watcher)
watcher
- The object that no longer cares about reinitialization.public void registerService(ServiceDesc service)
service
- Service descriptor describing the service being added.public void registerShutdownWatcher(ShutdownWatcher watcher)
watcher
- An object to notify at shutdown time.public void unregisterShutdownWatcher(ShutdownWatcher watcher)
watcher
- The object that no longer cares about shutdown.public void reinit()
public String serverName()
public List<ServiceDesc> services()
public void setServiceRefTable(RefTable serviceRefTable)
serviceRefTable
- The ref table to use.public void shutdown(boolean kill)
kill
- If true, shut down immediately instead of cleaning up.public int startListeners(String propRoot, ServiceFactory serviceFactory)
propRoot
- Prefix string for all the properties describing the
listeners that are to be started.serviceFactory
- Object to provide message handler factories for
the new listeners.public Trace trace()
public String version()
Copyright © 2017. All rights reserved.