@Service @Visibility(value=LOCAL) public class AsyncRunLevelContext extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
AsyncRunLevelContext.RunLevelControllerThread |
private static class |
AsyncRunLevelContext.RunLevelThreadFactory |
Modifier and Type | Field and 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 created
|
private 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 cancelled
|
private 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 |
Modifier | Constructor and Description |
---|---|
private |
AsyncRunLevelContext(ServiceLocator locator)
Constructor for the guy who does the work
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
clearErrors() |
boolean |
containsKey(ActiveDescriptor<?> descriptor)
The
Context API for discovering if a descriptor has been created |
void |
destroyOne(ActiveDescriptor<?> descriptor)
The
Context API. |
<U> U |
findOrCreate(ActiveDescriptor<U> activeDescriptor,
ServiceHandle<?> root)
This is from the
Context 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 the
RunLevel annotated
service described by the given descriptor is valid for activation. |
(package private) boolean |
wouldBlockRightNow(ActiveDescriptor<?> desc) |
private static final java.lang.String DEBUG_CONTEXT_PROPERTY
private static final boolean DEBUG_CONTEXT
private static final java.util.logging.Logger logger
private static final java.util.Timer timer
private static final java.util.concurrent.ThreadFactory THREAD_FACTORY
private final Logger hk2Logger
private int currentLevel
private CurrentTaskFutureWrapper currentTask
private static final java.util.concurrent.Executor DEFAULT_EXECUTOR
private final java.util.Map<ActiveDescriptor<?>,java.lang.Object> backingMap
private final java.util.Map<ActiveDescriptor<?>,java.lang.Throwable> levelErrorMap
private boolean wasCancelled
private final java.util.HashMap<ActiveDescriptor<?>,java.lang.Long> creatingDescriptors
private final java.util.HashSet<ActiveDescriptor<?>> hardCancelledDescriptors
private final java.util.LinkedList<ActiveDescriptor<?>> orderedCreationList
private java.util.concurrent.Executor executor
private final ServiceLocator locator
private int maxThreads
private RunLevelController.ThreadingPolicy policy
private long cancelTimeout
private java.lang.Integer modeOverride
@Inject private AsyncRunLevelContext(ServiceLocator locator)
locator
- The locator to usepublic <U> U findOrCreate(ActiveDescriptor<U> activeDescriptor, ServiceHandle<?> root)
Context
API, called by the wrapperactiveDescriptor
- the descriptor to createroot
- The root descriptorpublic boolean containsKey(ActiveDescriptor<?> descriptor)
Context
API for discovering if a descriptor has been createddescriptor
- The descriptor to findboolean wouldBlockRightNow(ActiveDescriptor<?> desc)
void hardCancelOne(ActiveDescriptor<?> descriptor)
descriptor
- the non-null descriptor to hard cancelpublic void destroyOne(ActiveDescriptor<?> descriptor)
Context
API. Removes a descriptor from the setdescriptor
- The descriptor to destroyprivate void validate(ActiveDescriptor<?> descriptor, int currentLevel) throws java.lang.IllegalStateException
RunLevel
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 given RunLevelController
.descriptor
- the descriptor of the service being activatedservice
- the run level serviceRunLevelException
- if the validation failsjava.lang.IllegalStateException
int getCurrentLevel()
void levelCancelled()
void setCurrentLevel(int currentLevel)
void setPolicy(RunLevelController.ThreadingPolicy policy)
void setExecutor(java.util.concurrent.Executor executor)
java.util.concurrent.Executor getExecutor()
RunLevelController.ThreadingPolicy getPolicy()
java.util.List<ActiveDescriptor<?>> getOrderedListOfServicesAtLevel(int level)
public RunLevelFuture proceedTo(int level) throws CurrentlyRunningException
level
- The level to change toCurrentlyRunningException
- If there is already a running jobvoid jobDone()
public RunLevelFuture getCurrentFuture()
void setMaximumThreads(int maximum)
int getMaximumThreads()
void clearErrors()
void setCancelTimeout(long cancelTimeout)
long getCancelTimeout()
java.lang.Integer getModeOverride()
void setModeOverride(java.lang.Integer modeOverride)
private static java.lang.String oneLineDescriptor(ActiveDescriptor<?> descriptor)
private static java.lang.String oneLineRoot(ServiceHandle<?> root)