Module org.glassfish.hk2.runlevel
Class RunLevelControllerImpl
java.lang.Object
org.glassfish.hk2.runlevel.internal.RunLevelControllerImpl
- All Implemented Interfaces:
RunLevelController
@Service
@ContractsProvided(RunLevelController.class)
@Visibility(LOCAL)
public class RunLevelControllerImpl
extends Object
implements RunLevelController
This is the implementation of the RunLevelController
- Author:
- jwells
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.glassfish.hk2.runlevel.RunLevelController
RunLevelController.ThreadingPolicy -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()If there is a current procedure in process this method will get it and cancel itlongReturns the amount of time in milliseconds the run level service will wait after a cancel call before orphaning services that have not yet completed executionThis method will return the current proceedTo that the RunLevelController is working on, or it will return null if the controller is not currently moving up or downintThe current run level state.Gets the executor that will be used by the system when executing tasks.intReturns the current number of maximum useable threadsReturns the threading policy currently being used by this controllerReturns the override value for theRunLevel.mode()field in RunLevel services.voidproceedTo(int runLevel) This method will move to the given run level synchronously as perRunLevelController.proceedToAsync(int).proceedToAsync(int runLevel) Causes this RunLevelController to move to the specified run level for allRunLevelinstances, orchestrating the appropriate lifecycle events.voidsetCancelTimeoutMilliseconds(long cancelTimeout) Sets the amount of time in milliseconds the run level service will wait after a cancel call before orphaning services that have not yet completed executionvoidsetExecutor(Executor executor) Sets the executor to use for the next job.voidsetMaximumUseableThreads(int maximumThreads) This sets the maximum number of threads that the system can create for creation and/or destruction of threads.voidSets the threading policy that will be used by this controller.voidsetValidationOverride(Integer validationMode) Sets the override value for theRunLevel.mode()field in RunLevel services.
-
Constructor Details
-
RunLevelControllerImpl
public RunLevelControllerImpl()
-
-
Method Details
-
proceedTo
public void proceedTo(int runLevel) Description copied from interface:RunLevelControllerThis method will move to the given run level synchronously as perRunLevelController.proceedToAsync(int).- Specified by:
proceedToin interfaceRunLevelController- Parameters:
runLevel- The level that should be proceeded to
-
proceedToAsync
public RunLevelFuture proceedToAsync(int runLevel) throws CurrentlyRunningException, IllegalStateException Description copied from interface:RunLevelControllerCauses this RunLevelController to move to the specified run level for allRunLevelinstances, orchestrating the appropriate lifecycle events.If the run level specified is the same as the current run level then the RunLevelController may return immediately
- Specified by:
proceedToAsyncin interfaceRunLevelController- Parameters:
runLevel- the run level to move to- Returns:
- The future that can be used to wait for this object
- Throws:
CurrentlyRunningException- if there is currently a job running this exception will be thrown with the currently running jobIllegalStateException- if this method is called when the USE_NO_THREADS policy is in effect
-
getCurrentProceeding
Description copied from interface:RunLevelControllerThis method will return the current proceedTo that the RunLevelController is working on, or it will return null if the controller is not currently moving up or down- Specified by:
getCurrentProceedingin interfaceRunLevelController- Returns:
- the current job the run level controller is working on or null if the system is not currently in flight
-
cancel
public void cancel()Description copied from interface:RunLevelControllerIf there is a current procedure in process this method will get it and cancel it- Specified by:
cancelin interfaceRunLevelController
-
getCurrentRunLevel
public int getCurrentRunLevel()Description copied from interface:RunLevelControllerThe current run level state. This represents the last run level successfully achieved by the underlying RunLevelController responsible for this scope.- Specified by:
getCurrentRunLevelin interfaceRunLevelController- Returns:
- the current run level, or null if no run level has been been achieved
-
setMaximumUseableThreads
public void setMaximumUseableThreads(int maximumThreads) Description copied from interface:RunLevelControllerThis sets the maximum number of threads that the system can create for creation and/or destruction of threads. This number must be one or greater- Specified by:
setMaximumUseableThreadsin interfaceRunLevelController- Parameters:
maximumThreads- The maximum number of threads that can be used by the system for creation or destruction of services
-
getMaximumUseableThreads
public int getMaximumUseableThreads()Description copied from interface:RunLevelControllerReturns the current number of maximum useable threads- Specified by:
getMaximumUseableThreadsin interfaceRunLevelController- Returns:
- the current number of maximum useable threads
-
setThreadingPolicy
Description copied from interface:RunLevelControllerSets the threading policy that will be used by this controller. The values can be:- FULLY_THREADED: Use maximumUseableThreads to complete any task
- USE_NO_THREADS: Never create a thread, use the callers thread always
- Specified by:
setThreadingPolicyin interfaceRunLevelController- Parameters:
policy- The policy that should be used by this controller
-
getThreadingPolicy
Description copied from interface:RunLevelControllerReturns the threading policy currently being used by this controller- Specified by:
getThreadingPolicyin interfaceRunLevelController- Returns:
- The threading policy currently in use with this controller
-
setExecutor
Description copied from interface:RunLevelControllerSets the executor to use for the next job. This value will be used even if the policy is USE_NO_THREADS in order to support canceling hung threads- Specified by:
setExecutorin interfaceRunLevelController- Parameters:
executor- The executor to use for the next job. If null a default executor will be used
-
getExecutor
Description copied from interface:RunLevelControllerGets the executor that will be used by the system when executing tasks. This value will be used even if the policy is USE_NO_THREADS in order to support canceling hung threads- Specified by:
getExecutorin interfaceRunLevelController- Returns:
- The currently installed executor. Will not return null (the default executor implementation will be returned if the user has not supplied an executor)
-
getCancelTimeoutMilliseconds
public long getCancelTimeoutMilliseconds()Description copied from interface:RunLevelControllerReturns the amount of time in milliseconds the run level service will wait after a cancel call before orphaning services that have not yet completed execution- Specified by:
getCancelTimeoutMillisecondsin interfaceRunLevelController- Returns:
- The amount of time in milliseconds that cancel will wait for running services
-
setCancelTimeoutMilliseconds
public void setCancelTimeoutMilliseconds(long cancelTimeout) Description copied from interface:RunLevelControllerSets the amount of time in milliseconds the run level service will wait after a cancel call before orphaning services that have not yet completed executionThe default value is 5000 (5 seconds). In general this value should be set to be longer than than the running time of the longest service that may be cancelled
- Specified by:
setCancelTimeoutMillisecondsin interfaceRunLevelController- Parameters:
cancelTimeout- The amount of time in milliseconds that cancel will wait for running services. Must be greater than 0
-
getValidationOverride
Description copied from interface:RunLevelControllerReturns the override value for theRunLevel.mode()field in RunLevel services. If this value is non-null then the mode will be forced to this value. This is useful in testing scenarios where the test would like to instantiate a run-level service without having to instantiate all the others at a certain level- Specified by:
getValidationOverridein interfaceRunLevelController- Returns:
- null if there is no override or the value that the
RunLevel.mode()value should be
-
setValidationOverride
Description copied from interface:RunLevelControllerSets the override value for theRunLevel.mode()field in RunLevel services. If this value is non-null then the mode will be forced to this value. This is useful in testing scenarios where the test would like to instantiate a run-level service without having to instantiate all the others at a certain level- Specified by:
setValidationOverridein interfaceRunLevelController- Parameters:
validationMode- null if there is no override or the value that theRunLevel.mode()value should be
-