Class RegistryProviderConf
- java.lang.Object
-
- de.aristaflow.adept2.base.service.AbstractADEPT2Service
-
- de.aristaflow.adept2.base.cluster.RegistryProviderConf
-
- All Implemented Interfaces:
GlobalRegistryProvider
,ADEPT2Service
,LogService
,ServiceThreadHandling
@ConfigurationDescription(properties={@Property(name="GlobalRegistryUris",type=STRING,isRequired=true,description="A list of URIs that refer to global registries running on the available cluster nodes. At most one of the URIs will be valid at a time."),}) public class RegistryProviderConf extends AbstractADEPT2Service implements GlobalRegistryProvider
AGlobalRegistryProvider
retrieving a list of possible global registry URIs from its configuration and trying to get a global registry with this URIs. That is, you configure a list of all possible global registry URIs and this global registry provider retrieves one of them.
Each URI is requested concurrently, the first successful retrieval of a global registry succeeds, that is, these URIs will be returned. The configured timeout applies to all requests accumulated, that is, retrieval of a global registry will not exceed this timeout.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.aristaflow.adept2.base.service.AbstractADEPT2Service
AbstractADEPT2Service.ActiveSessions
-
-
Field Summary
Fields Modifier and Type Field Description static String
CONF_GLOBAL_REGISTRY_URIS
Configuration key for the URIs of the possible global registries.static String
CONF_TIMEOUT
Configuration key for the time in milliseconds to wait for the requested URIs.protected ExecutorService
earlyRequests
The executor service that requests a global registry for a specific URI while the registry is starting or shutting down.protected List<URI>
globRegUris
The URIs of the possible global registries.protected ExecutorService
requests
The executor service that requests a global registry for a specific URI while the registry is active.protected long
timeout
The time in milliseconds to wait for the service requests.-
Fields inherited from class de.aristaflow.adept2.base.service.AbstractADEPT2Service
CONF_CSV_LOGGING, configuration, logger, registry, runtimeRequiredServices, startupRequiredServices
-
-
Constructor Summary
Constructors Constructor Description RegistryProviderConf(org.apache.commons.configuration2.Configuration conf, Registry registry)
Creates a new global registry provider retrieving the global registry URIs from the designated configuration, trying to retrieve a valid global registry from these when requested.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description URI[]
getGlobalRegistry(SessionToken session)
Gets the URIs of the current global registry.void
shutdown(boolean emergency)
This implementation waits 10 seconds in case of an emergency and otherwise indefinitely for the termination of the active sessions.-
Methods inherited from class de.aristaflow.adept2.base.service.AbstractADEPT2Service
_sessionActive, _sessionFinished, activeOrInvalidServiceStateException, changeLogContext, changeLogContext, changeLogContext, consoleLog, csvLoggingEnabled, getClassSpecificJulLogger, getDependencyRegistry, getLocalUris, getLogger, getRelease, getRuntimeRequiredServices, getServiceInstanceName, getStartupRequiredServices, getURIs, getUserCredentials, init, isActive, isSessionActive, isShutdown, logMethodEntry, logMethodEntry, logMethodEntry, logMethodExit, logMethodExit, ping, preShutdown, privilegeSession, privilegeThread, revertLogContextChanges, sessionActive, sessionActive, sessionActive, sessionActive, sessionFinished, sessionFinished, signalShutdown, signalStart, start, unprivilegeThread
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.aristaflow.adept2.base.service.ADEPT2Service
getLocalUris, getRelease, getRuntimeRequiredServices, getServiceInstanceName, getStartupRequiredServices, getURIs, init, ping, preShutdown, start
-
-
-
-
Field Detail
-
CONF_GLOBAL_REGISTRY_URIS
public static final String CONF_GLOBAL_REGISTRY_URIS
Configuration key for the URIs of the possible global registries.- See Also:
- Constant Field Values
-
CONF_TIMEOUT
public static final String CONF_TIMEOUT
Configuration key for the time in milliseconds to wait for the requested URIs.- See Also:
- Constant Field Values
-
requests
protected final ExecutorService requests
The executor service that requests a global registry for a specific URI while the registry is active.
-
earlyRequests
protected final ExecutorService earlyRequests
The executor service that requests a global registry for a specific URI while the registry is starting or shutting down.
This executor service runs all tasks in the calling thread. This is required for requests that occur before the registry has signalled its start or while it is shutting down. In this case, only the requesting thread may access the registry since it is privileged. All other threads will block when accessing the registry.
-
timeout
protected final long timeout
The time in milliseconds to wait for the service requests. Waiting for the requests will be accumulated, so waiting time for all requests will not exceed this timeout.
-
-
Constructor Detail
-
RegistryProviderConf
public RegistryProviderConf(org.apache.commons.configuration2.Configuration conf, Registry registry) throws AbortServiceException
Creates a new global registry provider retrieving the global registry URIs from the designated configuration, trying to retrieve a valid global registry from these when requested.- Parameters:
conf
- The configuration of this service.registry
- The registry of this service.- Throws:
AbortServiceException
- If there are no global registry URIs configured or they are not valid, anAbortServiceException
will be thrown.
-
-
Method Detail
-
shutdown
public void shutdown(boolean emergency)
Description copied from class:AbstractADEPT2Service
This implementation waits 10 seconds in case of an emergency and otherwise indefinitely for the termination of the active sessions. In case of an emergency shutdown may proceed even if there are active sessions.- Specified by:
shutdown
in interfaceADEPT2Service
- Overrides:
shutdown
in classAbstractADEPT2Service
- Parameters:
emergency
- Whether the shutdown will be an emergency shutdown.
-
getGlobalRegistry
public URI[] getGlobalRegistry(SessionToken session) throws ServiceNotKnownException
Description copied from interface:GlobalRegistryProvider
Gets the URIs of the current global registry.- Specified by:
getGlobalRegistry
in interfaceGlobalRegistryProvider
- Parameters:
session
- The session which is used to check for access rights on this method.- Returns:
- The URIs of the current global registry.
- Throws:
ServiceNotKnownException
- If there is currently no global registry, aServiceNotKnownException
will be thrown.
-
-