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 TypeFieldDescriptionstatic final longThe rate in milliseconds at which to poll services unless configured otherwise.static final intThe number of threads of theserviceAvailibilityCheckerunless configured otherwise.protected 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 of theserviceAvailibilityChecker.static final StringConfiguration key for the rate in milliseconds at which theserviceAvailibilityCheckerpolls the availability of services.static final StringConfiguration key for the maximum amount of threads of theexecutorService.static final StringDeprecated, for removal: This API element is subject to removal in a future version.static final StringConfiguration key for the amount of threads of thescheduledExecutorService.static final StringDeprecated, for removal: This API element is subject to removal in a future version.UseCONF_SCHEDULED_EXECUTION_CORE_POOL_SIZEinstead, which wins where both are configured.static final StringDeprecated, for removal: This API element is subject to removal in a future version.UseCONF_AVAILABILITY_POLL_RATEinstead, which wins where both are configured.static final StringDeprecated, for removal: This API element is subject to removal in a future version.UseCONF_AVAILABILITY_CORE_POOL_SIZEinstead, which wins where both are configured.static final StringThe name of the pool serving as theexecutorService, which by default also names its threads.protected final intDeprecated, for removal: This API element is subject to removal in a future version.The configuration of the pool of the executor overrides the size stated for it, so this need not be the size of the executor.protected ExecutorServiceThe executor service that is used for new threads started by client components.static final StringThe name of the pool serving as thescheduledExecutorService, which by default also names its threads.static final intThe number of threads of thescheduledExecutorServiceunless configured otherwise.protected final intDeprecated, for removal: This API element is subject to removal in a future version.The configuration of the pool of the executor overrides the size stated for it, so this need not be the size of the executor.protected LoggingScheduledThreadPoolExecutorThe scheduled executor service that is used for new threads scheduled by client components.protected final longThe rate in milliseconds at which theserviceAvailibilityCheckerpolls the availability of services.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) Deprecated, for removal: This API element is subject to removal in a future version.UseClientServiceSharedServices(AbstractADEPT2Service, Configuration, PoolSizes)instead, stating the sizes of theexecutorService.ClientServiceSharedServices(AbstractADEPT2Service service, Configuration configuration, ConfiguredExecutorProvider.PoolSizes executionSizes) Creates the shared services of the designated client service, which states the designated sizes for theexecutorService. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddServiceStateListener(ADEPT2Service service, ClientService.ServiceStateListener listener) Cf.voidDeprecated, for removal: This API element is subject to removal in a future version.UseawaitTermination(boolean)instead, passing the flag of the precedingshutdown(boolean).voidawaitTermination(boolean emergency) Await the termination of the executors, must be called after callingshutdown(boolean)with the same flag.<T extends Executor>
TgetExecutor(String name, Class<T> cls, Class<?>... typeArgs) Cf.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
-
EXECUTION_POOL_NAME
The name of the pool serving as theexecutorService, which by default also names its threads.- See Also:
-
SCHEDULED_EXECUTION_POOL_NAME
The name of the pool serving as thescheduledExecutorService, which by default also names its threads.- See Also:
-
CONF_EXECUTION_MAX_POOL_SIZE
Configuration key for the maximum amount of threads of theexecutorService.- See Also:
-
CONF_SCHEDULED_EXECUTION_CORE_POOL_SIZE
Configuration key for the amount of threads of thescheduledExecutorService.- See Also:
-
CONF_EXECUTOR_POOL_SIZE
Deprecated, for removal: This API element is subject to removal in a future version.UseCONF_EXECUTION_MAX_POOL_SIZEinstead, which wins where both are configured.Configuration key for the amount of threads used for theexecutorService.- See Also:
-
CONF_SCHEDULED_EXECUTOR_POOL_SIZE
@Deprecated(since="18.0.0", forRemoval=true) public static final String CONF_SCHEDULED_EXECUTOR_POOL_SIZEDeprecated, for removal: This API element is subject to removal in a future version.UseCONF_SCHEDULED_EXECUTION_CORE_POOL_SIZEinstead, which wins where both are configured.Configuration key for the amount of threads used for thescheduledExecutorService.- See Also:
-
CONF_AVAILABILITY_CORE_POOL_SIZE
Configuration key for the amount of threads of theserviceAvailibilityChecker.- See Also:
-
CONF_AVAILABILITY_POLL_RATE
Configuration key for the rate in milliseconds at which theserviceAvailibilityCheckerpolls the availability of services.- See Also:
-
CONF_SERVICE_AVAILABILITY_POOL_SIZE
@Deprecated(since="18.0.0", forRemoval=true) public static final String CONF_SERVICE_AVAILABILITY_POOL_SIZEDeprecated, for removal: This API element is subject to removal in a future version.UseCONF_AVAILABILITY_CORE_POOL_SIZEinstead, which wins where both are configured.Configuration key for the amount of threads used for the service availability check.- See Also:
-
CONF_SERVICE_AVAILABILITY_POLL_RATE
@Deprecated(since="18.0.0", forRemoval=true) public static final String CONF_SERVICE_AVAILABILITY_POLL_RATEDeprecated, for removal: This API element is subject to removal in a future version.UseCONF_AVAILABILITY_POLL_RATEinstead, which wins where both are configured.Configuration key for the rate at which to poll the availability of services.- See Also:
-
SCHEDULED_EXECUTION_POOL_SIZE
public static final int SCHEDULED_EXECUTION_POOL_SIZEThe number of threads of thescheduledExecutorServiceunless configured otherwise.- See Also:
-
AVAILABILITY_POOL_SIZE
public static final int AVAILABILITY_POOL_SIZEThe number of threads of theserviceAvailibilityCheckerunless configured otherwise.- See Also:
-
AVAILABILITY_POLL_RATE
public static final long AVAILABILITY_POLL_RATEThe rate in milliseconds at which to poll services unless configured otherwise.- See Also:
-
executorPoolSize
Deprecated, for removal: This API element is subject to removal in a future version.The configuration of the pool of the executor overrides the size stated for it, so this need not be the size of the executor.The maximum amount of threads stated for theexecutorService. -
executorService
The executor service that is used for new threads started by client components. -
scheduledExecutorPoolSize
Deprecated, for removal: This API element is subject to removal in a future version.The configuration of the pool of the executor overrides the size stated for it, so this need not be the size of the executor.The amount of threads stated 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 theserviceAvailibilityCheckerpolls the availability of services.
-
-
Constructor Details
-
ClientServiceSharedServices
@Deprecated(since="18.0.0", forRemoval=true) public ClientServiceSharedServices(AbstractADEPT2Service service, Configuration configuration) Deprecated, for removal: This API element is subject to removal in a future version.UseClientServiceSharedServices(AbstractADEPT2Service, Configuration, PoolSizes)instead, stating the sizes of theexecutorService.Creates the shared services of the designated client service with the generic defaults of a pool as the sizes of theexecutorService.- Parameters:
service- The client service implementation.configuration- The configuration of the client service.- Throws:
IllegalArgumentException- If the configured poll rate of the availability check is below 1, anIllegalArgumentExceptionwill be thrown.
-
ClientServiceSharedServices
public ClientServiceSharedServices(AbstractADEPT2Service service, Configuration configuration, ConfiguredExecutorProvider.PoolSizes executionSizes) Creates the shared services of the designated client service, which states the designated sizes for theexecutorService. The configuration of a pool overrides the sizes stated for it, and a configuredCONF_EXECUTOR_POOL_SIZEorCONF_SCHEDULED_EXECUTOR_POOL_SIZEstill replaces the size stated for its executor, a scheduled size below 1 as 1 with a warning.- Parameters:
service- The client service implementation.configuration- The configuration of the client service.executionSizes- The sizes of theexecutorServiceunless the configuration of its pool states others. This must not benull.- Throws:
IllegalArgumentException- If the configured poll rate of the availability check is below 1, anIllegalArgumentExceptionwill be thrown.
-
-
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
Deprecated, for removal: This API element is subject to removal in a future version.UseawaitTermination(boolean)instead, passing the flag of the precedingshutdown(boolean). Awaiting the termination of an emergency shutdown has to be brief, which this method cannot know.Await the termination of the executors, must be called after callingshutdown(boolean). -
awaitTermination
public void awaitTermination(boolean emergency) Await the termination of the executors, must be called after callingshutdown(boolean)with the same flag. Where an executor does not terminate in time, this gives up on it and continues with the next one.- Parameters:
emergency- Whether the executors have been shut down due to an emergency. Such a shutdown has to be fast and therefore uses a brief timeout.
-
getExecutor
-
getExecutorService
-
getScheduledExecutorService
-
addServiceStateListener
public boolean addServiceStateListener(ADEPT2Service service, ClientService.ServiceStateListener listener) -
removeServiceStateListener
public void removeServiceStateListener(ADEPT2Service service, ClientService.ServiceStateListener listener)
-
CONF_EXECUTION_MAX_POOL_SIZEinstead, which wins where both are configured.