public final class StabilityMonitor extends Object
StabilityMonitor
are in REST state.
The following controller substates are considered to be in REST state:
ServiceController.Substate.NEW
ServiceController.Substate.CANCELLED
ServiceController.Substate.WAITING
ServiceController.Substate.WONT_START
ServiceController.Substate.PROBLEM
ServiceController.Substate.START_FAILED
ServiceController.Substate.UP
ServiceController.Substate.REMOVED
Set<ServiceController<?>> controllers = ... StabilityMonitor monitor = new StabilityMonitor(); for (ServiceController<?> controller : controllers) { monitor.addController(controller); } try { monitor.awaitStability(); } finally { monitor.clear(); // since now on the monitor can be reused for another stability detection } // do something after all the controllers are in REST stateSample simple usage:
ServiceController<?> controller = ... StabilityMonitor monitor = new StabilityMonitor(); monitor.addController(controller); controller.setMode(REMOVE); try { monitor.awaitStability(); } finally { monitor.removeController(controller); } // do something after controller have been removed from container
StabilityStatistics
Constructor and Description |
---|
StabilityMonitor() |
Modifier and Type | Method and Description |
---|---|
void |
addController(ServiceController<?> controller)
Register controller with this monitor.
|
void |
awaitStability()
Causes the current thread to wait until the monitor is stable.
|
boolean |
awaitStability(long timeout,
TimeUnit unit)
Causes the current thread to wait until the monitor is stable.
|
boolean |
awaitStability(long timeout,
TimeUnit unit,
Set<? super ServiceController<?>> failed,
Set<? super ServiceController<?>> problems)
Causes the current thread to wait until the monitor is stable.
|
boolean |
awaitStability(long timeout,
TimeUnit unit,
Set<? super ServiceController<?>> failed,
Set<? super ServiceController<?>> problems,
StabilityStatistics statistics)
Causes the current thread to wait until the monitor is stable.
|
boolean |
awaitStability(long timeout,
TimeUnit unit,
StabilityStatistics statistics)
Causes the current thread to wait until the monitor is stable.
|
void |
awaitStability(Set<? super ServiceController<?>> failed,
Set<? super ServiceController<?>> problems)
Causes the current thread to wait until the monitor is stable.
|
void |
awaitStability(Set<? super ServiceController<?>> failed,
Set<? super ServiceController<?>> problems,
StabilityStatistics statistics)
Causes the current thread to wait until the monitor is stable.
|
void |
awaitStability(StabilityStatistics statistics)
Causes the current thread to wait until the monitor is stable.
|
void |
clear()
Removes all the registered controllers in this monitor.
|
void |
removeController(ServiceController<?> controller)
Unregister controller with this monitor.
|
public void addController(ServiceController<?> controller) throws IllegalArgumentException, IllegalStateException
controller
- to be registered for stability detection.IllegalArgumentException
- if controller
is nullIllegalStateException
- if controller
s lock is held by current threadpublic void removeController(ServiceController<?> controller) throws IllegalArgumentException, IllegalStateException
controller
- to be unregistered from stability detection.IllegalArgumentException
- if controller
is nullIllegalStateException
- if controller
s lock is held by current threadpublic void clear()
public void awaitStability() throws InterruptedException
InterruptedException
- if the current thread is interrupted
while waitingpublic void awaitStability(StabilityStatistics statistics) throws InterruptedException
statistics
- stability statistics report to fill inInterruptedException
- if the current thread is interrupted
while waitingpublic boolean awaitStability(long timeout, TimeUnit unit) throws InterruptedException
timeout
- the maximum time to waitunit
- the time unit of the timeout
argumentInterruptedException
- if the current thread is interrupted
while waitingpublic boolean awaitStability(long timeout, TimeUnit unit, StabilityStatistics statistics) throws InterruptedException
timeout
- the maximum time to waitunit
- the time unit of the timeout
argumentstatistics
- stability statistics report to fill inInterruptedException
- if the current thread is interrupted
while waitingpublic void awaitStability(Set<? super ServiceController<?>> failed, Set<? super ServiceController<?>> problems) throws InterruptedException
failed
- a set into which failed services should be copiedproblems
- a set into which problem services should be copiedInterruptedException
- if the current thread is interrupted
while waitingpublic boolean awaitStability(long timeout, TimeUnit unit, Set<? super ServiceController<?>> failed, Set<? super ServiceController<?>> problems) throws InterruptedException
timeout
- the maximum time to waitunit
- the time unit of the timeout
argumentfailed
- a set into which failed services should be copiedproblems
- a set into which problem services should be copiedInterruptedException
- if the current thread is interrupted
while waitingpublic void awaitStability(Set<? super ServiceController<?>> failed, Set<? super ServiceController<?>> problems, StabilityStatistics statistics) throws InterruptedException
failed
- a set into which failed services should be copiedproblems
- a set into which problem services should be copiedstatistics
- stability statistics report to fill inInterruptedException
- if the current thread is interrupted
while waitingpublic boolean awaitStability(long timeout, TimeUnit unit, Set<? super ServiceController<?>> failed, Set<? super ServiceController<?>> problems, StabilityStatistics statistics) throws InterruptedException
timeout
- the maximum time to waitunit
- the time unit of the timeout
argumentfailed
- a set into which failed services should be copiedproblems
- a set into which problem services should be copiedstatistics
- stability statistics report to fill inInterruptedException
- if the current thread is interrupted
while waitingCopyright © 2018 JBoss by Red Hat. All rights reserved.