public class ClientServiceSharedServices extends AbstractSubService<AbstractADEPT2Service>
ClientService.| Modifier and Type | Class and Description |
|---|---|
static class |
ClientServiceSharedServices.ServiceAvailabilityTracker
A tracker for the availability of a specific
ADEPT2Services. |
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Map<ADEPT2Service,ClientServiceSharedServices.ServiceAvailabilityTracker> |
availTracker
The listeners registered for the availability of an
ADEPT2Service and the corresponding service availability
tracker. |
static java.lang.String |
CONF_EXECUTOR_POOL_SIZE
Configuration key for the amount of threads used for the
executorService. |
static java.lang.String |
CONF_SCHEDULED_EXECUTOR_POOL_SIZE
Configuration key for the amount of threads used for the
scheduledExecutorService. |
static java.lang.String |
CONF_SERVICE_AVAILABILITY_POLL_RATE
Configuration key for the rate at which to poll the availability of
services.
|
static java.lang.String |
CONF_SERVICE_AVAILABILITY_POOL_SIZE
Configuration key for the amount of threads used for the service
availability check.
|
protected int |
executorPoolSize
The amount of threads used for the
executorService. |
protected java.util.concurrent.ExecutorService |
executorService
The executor service that is used for new threads started by client
components.
|
protected int |
scheduledExecutorPoolSize
The amount of threads used for the
scheduledExecutorService. |
protected LoggingScheduledThreadPoolExecutor |
scheduledExecutorService
The scheduled executor service that is used for new threads scheduled by
client components.
|
protected long |
servAvailPollRate
The rate in milliseconds at which to poll the availability of services
serviceAvailibilityChecker. |
protected int |
servAvailPoolSize
The amount of threads used for the
serviceAvailibilityChecker. |
protected java.util.concurrent.ScheduledExecutorService |
serviceAvailibilityChecker
The thread pool for checking the availability of services and notifying
changes to the registered listeners.
|
logger, runtimeRequiredServices, service, startupRequiredServices| Constructor and Description |
|---|
ClientServiceSharedServices(AbstractADEPT2Service service,
Configuration configuration)
Default constructors, expects some configuration values to be set in the
provided configuration:
CONF_EXECUTOR_POOL_SIZE
CONF_SCHEDULED_EXECUTOR_POOL_SIZE
CONF_SERVICE_AVAILABILITY_POOL_SIZE
CONF_SERVICE_AVAILABILITY_POLL_RATE
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addServiceStateListener(ADEPT2Service service,
ClientService.ServiceStateListener listener)
Cf.
|
void |
awaitTermination()
Await the termination of the executors, must be called after calling
shutdown(boolean). |
java.util.concurrent.ExecutorService |
getExecutorService()
Cf.
|
LoggingScheduledThreadPoolExecutor |
getScheduledExecutorService()
Cf.
|
void |
init()
Initialise the sub service.
|
void |
removeServiceStateListener(ADEPT2Service service,
ClientService.ServiceStateListener listener)
Cf.
|
void |
shutdown(boolean emergency)
Signals this service that it is being shut down.
|
getLocalUris, getRuntimeRequiredServices, getStartupRequiredServices, getURIs, ping, privilegeSession, sessionActive, sessionFinished, startpublic static final java.lang.String CONF_EXECUTOR_POOL_SIZE
executorService.public static final java.lang.String CONF_SCHEDULED_EXECUTOR_POOL_SIZE
scheduledExecutorService.public static final java.lang.String CONF_SERVICE_AVAILABILITY_POOL_SIZE
public static final java.lang.String CONF_SERVICE_AVAILABILITY_POLL_RATE
protected final int executorPoolSize
executorService.protected java.util.concurrent.ExecutorService executorService
protected final int scheduledExecutorPoolSize
scheduledExecutorService.protected LoggingScheduledThreadPoolExecutor scheduledExecutorService
protected final java.util.Map<ADEPT2Service,ClientServiceSharedServices.ServiceAvailabilityTracker> availTracker
ADEPT2Service and the corresponding service availability
tracker.protected java.util.concurrent.ScheduledExecutorService serviceAvailibilityChecker
protected final int servAvailPoolSize
serviceAvailibilityChecker.protected final long servAvailPollRate
serviceAvailibilityChecker.public ClientServiceSharedServices(AbstractADEPT2Service service, Configuration configuration)
service - The ClientService implementationconfiguration - The configuration of the client service.public void init()
throws AbortServiceException
AbstractSubServiceAbstractSubService.init(), the sub service must be ready for
AbstractSubService.start().
This implementation is empty which allows subclasses to omit the initialisation if they do not need one.
init in class AbstractSubService<AbstractADEPT2Service>AbortServiceException - If this sub service cannot be initialised due
to a severe problem, an AbortServiceException will
be thrown. AbstractSubService.shutdown(boolean) will not be called when aborting;
the sub service has to shut down itself/clean up before throwing
the exception.public void shutdown(boolean emergency)
AbstractSubServiceServiceThreadHandling. This implementation is empty.
shutdown in class AbstractSubService<AbstractADEPT2Service>emergency - Whether the shutdown will be an emergency shutdown.public void awaitTermination()
shutdown(boolean).public java.util.concurrent.ExecutorService getExecutorService()
public LoggingScheduledThreadPoolExecutor getScheduledExecutorService()
public boolean addServiceStateListener(ADEPT2Service service, ClientService.ServiceStateListener listener)
public void removeServiceStateListener(ADEPT2Service service, ClientService.ServiceStateListener listener)