Class AsyncRunLevelContext
- java.lang.Object
-
- org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext
-
@Service @Visibility(LOCAL) public class AsyncRunLevelContext extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
AsyncRunLevelContext.RunLevelControllerThread
private static class
AsyncRunLevelContext.RunLevelThreadFactory
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<ActiveDescriptor<?>,java.lang.Object>
backingMap
The backing maps for this context.private long
cancelTimeout
private java.util.HashMap<ActiveDescriptor<?>,java.lang.Long>
creatingDescriptors
The set of services currently being createdprivate int
currentLevel
private CurrentTaskFutureWrapper
currentTask
private static boolean
DEBUG_CONTEXT
private static java.lang.String
DEBUG_CONTEXT_PROPERTY
private static java.util.concurrent.Executor
DEFAULT_EXECUTOR
private java.util.concurrent.Executor
executor
private java.util.HashSet<ActiveDescriptor<?>>
hardCancelledDescriptors
The set of descriptors that have been hard cancelledprivate Logger
hk2Logger
private java.util.Map<ActiveDescriptor<?>,java.lang.Throwable>
levelErrorMap
private ServiceLocator
locator
private static java.util.logging.Logger
logger
private int
maxThreads
private java.lang.Integer
modeOverride
private java.util.LinkedList<ActiveDescriptor<?>>
orderedCreationList
private RunLevelController.ThreadingPolicy
policy
private static java.util.concurrent.ThreadFactory
THREAD_FACTORY
private static java.util.Timer
timer
private boolean
wasCancelled
-
Constructor Summary
Constructors Modifier Constructor Description private
AsyncRunLevelContext(ServiceLocator locator)
Constructor for the guy who does the work
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
clearErrors()
boolean
containsKey(ActiveDescriptor<?> descriptor)
TheContext
API for discovering if a descriptor has been createdvoid
destroyOne(ActiveDescriptor<?> descriptor)
TheContext
API.<U> U
findOrCreate(ActiveDescriptor<U> activeDescriptor, ServiceHandle<?> root)
This is from theContext
API, called by the wrapper(package private) long
getCancelTimeout()
RunLevelFuture
getCurrentFuture()
Gets the current task(package private) int
getCurrentLevel()
(package private) java.util.concurrent.Executor
getExecutor()
(package private) int
getMaximumThreads()
(package private) java.lang.Integer
getModeOverride()
(package private) java.util.List<ActiveDescriptor<?>>
getOrderedListOfServicesAtLevel(int level)
(package private) RunLevelController.ThreadingPolicy
getPolicy()
(package private) void
hardCancelOne(ActiveDescriptor<?> descriptor)
No need to lock this, it is called with the lock already held(package private) void
jobDone()
(package private) void
levelCancelled()
private static java.lang.String
oneLineDescriptor(ActiveDescriptor<?> descriptor)
private static java.lang.String
oneLineRoot(ServiceHandle<?> root)
RunLevelFuture
proceedTo(int level)
This method is called to change the proceedTo level of the system(package private) void
setCancelTimeout(long cancelTimeout)
(package private) void
setCurrentLevel(int currentLevel)
(package private) void
setExecutor(java.util.concurrent.Executor executor)
(package private) void
setMaximumThreads(int maximum)
(package private) void
setModeOverride(java.lang.Integer modeOverride)
(package private) void
setPolicy(RunLevelController.ThreadingPolicy policy)
private void
validate(ActiveDescriptor<?> descriptor, int currentLevel)
Verifies that the run level value of theRunLevel
annotated service described by the given descriptor is valid for activation.(package private) boolean
wouldBlockRightNow(ActiveDescriptor<?> desc)
-
-
-
Field Detail
-
DEBUG_CONTEXT_PROPERTY
private static final java.lang.String DEBUG_CONTEXT_PROPERTY
- See Also:
- Constant Field Values
-
DEBUG_CONTEXT
private static final boolean DEBUG_CONTEXT
-
logger
private static final java.util.logging.Logger logger
-
timer
private static final java.util.Timer timer
-
THREAD_FACTORY
private static final java.util.concurrent.ThreadFactory THREAD_FACTORY
-
hk2Logger
private final Logger hk2Logger
-
currentLevel
private int currentLevel
-
currentTask
private CurrentTaskFutureWrapper currentTask
-
DEFAULT_EXECUTOR
private static final java.util.concurrent.Executor DEFAULT_EXECUTOR
-
backingMap
private final java.util.Map<ActiveDescriptor<?>,java.lang.Object> backingMap
The backing maps for this context.
-
levelErrorMap
private final java.util.Map<ActiveDescriptor<?>,java.lang.Throwable> levelErrorMap
-
wasCancelled
private boolean wasCancelled
-
creatingDescriptors
private final java.util.HashMap<ActiveDescriptor<?>,java.lang.Long> creatingDescriptors
The set of services currently being created
-
hardCancelledDescriptors
private final java.util.HashSet<ActiveDescriptor<?>> hardCancelledDescriptors
The set of descriptors that have been hard cancelled
-
orderedCreationList
private final java.util.LinkedList<ActiveDescriptor<?>> orderedCreationList
-
executor
private java.util.concurrent.Executor executor
-
locator
private final ServiceLocator locator
-
maxThreads
private int maxThreads
-
policy
private RunLevelController.ThreadingPolicy policy
-
cancelTimeout
private long cancelTimeout
-
modeOverride
private java.lang.Integer modeOverride
-
-
Constructor Detail
-
AsyncRunLevelContext
@Inject private AsyncRunLevelContext(ServiceLocator locator)
Constructor for the guy who does the work- Parameters:
locator
- The locator to use
-
-
Method Detail
-
findOrCreate
public <U> U findOrCreate(ActiveDescriptor<U> activeDescriptor, ServiceHandle<?> root)
This is from theContext
API, called by the wrapper- Parameters:
activeDescriptor
- the descriptor to createroot
- The root descriptor- Returns:
- The object created
-
containsKey
public boolean containsKey(ActiveDescriptor<?> descriptor)
TheContext
API for discovering if a descriptor has been created- Parameters:
descriptor
- The descriptor to find- Returns:
- true if already created, false otherwise
-
wouldBlockRightNow
boolean wouldBlockRightNow(ActiveDescriptor<?> desc)
-
hardCancelOne
void hardCancelOne(ActiveDescriptor<?> descriptor)
No need to lock this, it is called with the lock already held- Parameters:
descriptor
- the non-null descriptor to hard cancel
-
destroyOne
public void destroyOne(ActiveDescriptor<?> descriptor)
TheContext
API. Removes a descriptor from the set- Parameters:
descriptor
- The descriptor to destroy
-
validate
private void validate(ActiveDescriptor<?> descriptor, int currentLevel) throws java.lang.IllegalStateException
Verifies that the run level value of theRunLevel
annotated service described by the given descriptor is valid for activation. Valid means that the run level value is less than or equal to the current or planned run level of the givenRunLevelController
.- Parameters:
descriptor
- the descriptor of the service being activatedservice
- the run level service- Throws:
RunLevelException
- if the validation failsjava.lang.IllegalStateException
-
getCurrentLevel
int getCurrentLevel()
-
levelCancelled
void levelCancelled()
-
setCurrentLevel
void setCurrentLevel(int currentLevel)
-
setPolicy
void setPolicy(RunLevelController.ThreadingPolicy policy)
-
setExecutor
void setExecutor(java.util.concurrent.Executor executor)
-
getExecutor
java.util.concurrent.Executor getExecutor()
-
getPolicy
RunLevelController.ThreadingPolicy getPolicy()
-
getOrderedListOfServicesAtLevel
java.util.List<ActiveDescriptor<?>> getOrderedListOfServicesAtLevel(int level)
-
proceedTo
public RunLevelFuture proceedTo(int level) throws CurrentlyRunningException
This method is called to change the proceedTo level of the system- Parameters:
level
- The level to change to- Returns:
- A non-null RunLevelFuture that is the handle to give the caller
- Throws:
CurrentlyRunningException
- If there is already a running job
-
jobDone
void jobDone()
-
getCurrentFuture
public RunLevelFuture getCurrentFuture()
Gets the current task- Returns:
- The current task, may be null if there is no current task
-
setMaximumThreads
void setMaximumThreads(int maximum)
-
getMaximumThreads
int getMaximumThreads()
-
clearErrors
void clearErrors()
-
setCancelTimeout
void setCancelTimeout(long cancelTimeout)
-
getCancelTimeout
long getCancelTimeout()
-
getModeOverride
java.lang.Integer getModeOverride()
-
setModeOverride
void setModeOverride(java.lang.Integer modeOverride)
-
oneLineDescriptor
private static java.lang.String oneLineDescriptor(ActiveDescriptor<?> descriptor)
-
oneLineRoot
private static java.lang.String oneLineRoot(ServiceHandle<?> root)
-
-