JBoss Modular Service Container 1.1.2.Final

org.jboss.msc.service
Class StabilityMonitor

java.lang.Object
  extended by org.jboss.msc.service.StabilityMonitor

public final class StabilityMonitor
extends Object

A stability detection utility. It can be used to detect if all the registered controllers with StabilityMonitor are in REST state. The following controller substates are considered to be in REST state:

Sample bulk usage:
 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 state
 
Sample 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
 

Author:
David M. Lloyd, Richard Opalka
See Also:
StabilityStatistics

Constructor Summary
StabilityMonitor()
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StabilityMonitor

public StabilityMonitor()
Method Detail

addController

public void addController(ServiceController<?> controller)
Register controller with this monitor.

Parameters:
controller - to be registered for stability detection.

removeController

public void removeController(ServiceController<?> controller)
Unregister controller with this monitor.

Parameters:
controller - to be unregistered from stability detection.

clear

public void clear()
Removes all the registered controllers in this monitor. The monitor can be later reused for stability detection again.


awaitStability

public void awaitStability()
                    throws InterruptedException
Causes the current thread to wait until the monitor is stable.

Throws:
InterruptedException - if the current thread is interrupted while waiting

awaitStability

public void awaitStability(StabilityStatistics statistics)
                    throws InterruptedException
Causes the current thread to wait until the monitor is stable.

Parameters:
statistics - stability statistics report to fill in
Throws:
InterruptedException - if the current thread is interrupted while waiting

awaitStability

public boolean awaitStability(long timeout,
                              TimeUnit unit)
                       throws InterruptedException
Causes the current thread to wait until the monitor is stable.

Parameters:
timeout - the maximum time to wait
unit - the time unit of the timeout argument
Returns:
true if this monitor achieved stability, false if the timeout elapsed before stability
Throws:
InterruptedException - if the current thread is interrupted while waiting

awaitStability

public boolean awaitStability(long timeout,
                              TimeUnit unit,
                              StabilityStatistics statistics)
                       throws InterruptedException
Causes the current thread to wait until the monitor is stable.

Parameters:
timeout - the maximum time to wait
unit - the time unit of the timeout argument
statistics - stability statistics report to fill in
Returns:
true if this monitor achieved stability, false if the timeout elapsed before stability
Throws:
InterruptedException - if the current thread is interrupted while waiting

awaitStability

public void awaitStability(Set<? super ServiceController<?>> failed,
                           Set<? super ServiceController<?>> problems)
                    throws InterruptedException
Causes the current thread to wait until the monitor is stable.

Parameters:
failed - a set into which failed services should be copied
problems - a set into which problem services should be copied
Throws:
InterruptedException - if the current thread is interrupted while waiting

awaitStability

public boolean awaitStability(long timeout,
                              TimeUnit unit,
                              Set<? super ServiceController<?>> failed,
                              Set<? super ServiceController<?>> problems)
                       throws InterruptedException
Causes the current thread to wait until the monitor is stable.

Parameters:
timeout - the maximum time to wait
unit - the time unit of the timeout argument
failed - a set into which failed services should be copied
problems - a set into which problem services should be copied
Returns:
true if this monitor achieved stability, false if the timeout elapsed before stability
Throws:
InterruptedException - if the current thread is interrupted while waiting

awaitStability

public void awaitStability(Set<? super ServiceController<?>> failed,
                           Set<? super ServiceController<?>> problems,
                           StabilityStatistics statistics)
                    throws InterruptedException
Causes the current thread to wait until the monitor is stable.

Parameters:
failed - a set into which failed services should be copied
problems - a set into which problem services should be copied
statistics - stability statistics report to fill in
Throws:
InterruptedException - if the current thread is interrupted while waiting

awaitStability

public boolean awaitStability(long timeout,
                              TimeUnit unit,
                              Set<? super ServiceController<?>> failed,
                              Set<? super ServiceController<?>> problems,
                              StabilityStatistics statistics)
                       throws InterruptedException
Causes the current thread to wait until the monitor is stable.

Parameters:
timeout - the maximum time to wait
unit - the time unit of the timeout argument
failed - a set into which failed services should be copied
problems - a set into which problem services should be copied
statistics - stability statistics report to fill in
Returns:
true if this monitor achieved stability, false if the timeout elapsed before stability
Throws:
InterruptedException - if the current thread is interrupted while waiting

JBoss Modular Service Container 1.1.2.Final

Copyright © 2012 JBoss, a division of Red Hat, Inc.