Package de.aristaflow.adept2.core.client
Class ClientServiceSharedServices
java.lang.Object
de.aristaflow.adept2.base.service.AbstractSubService<AbstractADEPT2Service>
de.aristaflow.adept2.core.client.ClientServiceSharedServices
Sub-service implementation which implements some default behaviour for all
implementations of
ClientService.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA tracker for the availability of a specificADEPT2Services. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Map<ADEPT2Service,ClientServiceSharedServices.ServiceAvailabilityTracker> The listeners registered for the availability of anADEPT2Serviceand the corresponding service availability tracker.static final StringConfiguration key for the amount of threads used for theexecutorService.static final StringConfiguration key for the amount of threads used for thescheduledExecutorService.static final StringConfiguration key for the rate at which to poll the availability of services.static final StringConfiguration key for the amount of threads used for the service availability check.protected final intThe amount of threads used for theexecutorService.protected ExecutorServiceThe executor service that is used for new threads started by client components.protected final intThe amount of threads used for thescheduledExecutorService.protected LoggingScheduledThreadPoolExecutorThe scheduled executor service that is used for new threads scheduled by client components.protected final longThe rate in milliseconds at which to poll the availability of servicesserviceAvailibilityChecker.protected final intThe amount of threads used for theserviceAvailibilityChecker.protected ScheduledExecutorServiceThe thread pool for checking the availability of services and notifying changes to the registered listeners.Fields inherited from class de.aristaflow.adept2.base.service.AbstractSubService
logger, runtimeRequiredServices, service, startupRequiredServices -
Constructor Summary
ConstructorsConstructorDescriptionClientServiceSharedServices(AbstractADEPT2Service service, Configuration configuration) Default constructors, expects some configuration values to be set in the provided configuration:CONF_EXECUTOR_POOL_SIZECONF_SCHEDULED_EXECUTOR_POOL_SIZECONF_SERVICE_AVAILABILITY_POOL_SIZECONF_SERVICE_AVAILABILITY_POLL_RATE -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddServiceStateListener(ADEPT2Service service, ClientService.ServiceStateListener listener) Cf.voidAwait the termination of the executors, must be called after callingshutdown(boolean).Cf.Cf.voidinit()Initialise the sub service.voidremoveServiceStateListener(ADEPT2Service service, ClientService.ServiceStateListener listener) Cf.voidshutdown(boolean emergency) Signals this service that it is being shut down.Methods inherited from class de.aristaflow.adept2.base.service.AbstractSubService
getLocalUris, getRuntimeRequiredServices, getStartupRequiredServices, getURIs, ping, privilegeSession, sessionActive, sessionFinished, start
-
Field Details
-
CONF_EXECUTOR_POOL_SIZE
Configuration key for the amount of threads used for theexecutorService.- See Also:
-
CONF_SCHEDULED_EXECUTOR_POOL_SIZE
Configuration key for the amount of threads used for thescheduledExecutorService.- See Also:
-
CONF_SERVICE_AVAILABILITY_POOL_SIZE
Configuration key for the amount of threads used for the service availability check.- See Also:
-
CONF_SERVICE_AVAILABILITY_POLL_RATE
Configuration key for the rate at which to poll the availability of services.- See Also:
-
executorPoolSize
protected final int executorPoolSizeThe amount of threads used for theexecutorService. -
executorService
The executor service that is used for new threads started by client components. -
scheduledExecutorPoolSize
protected final int scheduledExecutorPoolSizeThe amount of threads used for thescheduledExecutorService. -
scheduledExecutorService
The scheduled executor service that is used for new threads scheduled by client components. -
availTracker
protected final Map<ADEPT2Service,ClientServiceSharedServices.ServiceAvailabilityTracker> availTrackerThe listeners registered for the availability of anADEPT2Serviceand the corresponding service availability tracker. -
serviceAvailibilityChecker
The thread pool for checking the availability of services and notifying changes to the registered listeners. -
servAvailPoolSize
protected final int servAvailPoolSizeThe amount of threads used for theserviceAvailibilityChecker. -
servAvailPollRate
protected final long servAvailPollRateThe rate in milliseconds at which to poll the availability of servicesserviceAvailibilityChecker.
-
-
Constructor Details
-
ClientServiceSharedServices
Default constructors, expects some configuration values to be set in the provided configuration:- Parameters:
service- The ClientService implementationconfiguration- The configuration of the client service.
-
-
Method Details
-
init
Description copied from class:AbstractSubServiceInitialise the sub service. Startup-required services may already be used here.
After returning formAbstractSubService.init(), the sub service must be ready forAbstractSubService.start().This implementation is empty which allows subclasses to omit the initialisation if they do not need one.
- Overrides:
initin classAbstractSubService<AbstractADEPT2Service>- Throws:
AbortServiceException- If this sub service cannot be initialised due to a severe problem, anAbortServiceExceptionwill 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.
-
shutdown
public void shutdown(boolean emergency) Description copied from class:AbstractSubServiceSignals this service that it is being shut down. While this method is called, the service is no longer (remotely) available. It should terminate and close all activities and connections. Since the service is in an inconsistent state while shutting down, access should be restricted to the threads relevant for shutting down. All other requests should be blocked (seeServiceThreadHandling.
All startup required services are available in shutdown, runtime services may already be shut down.
In case of an emergency shutdown, even startup required services may not be available. Additionally, shutting down should be rather fast, so cleanup should concentrate on the really important things and use brief timeouts when waiting.This implementation is empty.
- Overrides:
shutdownin classAbstractSubService<AbstractADEPT2Service>- Parameters:
emergency- Whether the shutdown will be an emergency shutdown.
-
awaitTermination
public void awaitTermination()Await the termination of the executors, must be called after callingshutdown(boolean). -
getExecutorService
-
getScheduledExecutorService
-
addServiceStateListener
public boolean addServiceStateListener(ADEPT2Service service, ClientService.ServiceStateListener listener) -
removeServiceStateListener
public void removeServiceStateListener(ADEPT2Service service, ClientService.ServiceStateListener listener)
-