org.ow2.clif.supervisor.api
Class BladeState

java.lang.Object
  extended by org.ow2.clif.supervisor.api.BladeState
All Implemented Interfaces:
java.io.Serializable

public class BladeState
extends java.lang.Object
implements java.io.Serializable

Representation of a blade state and utility methods to determine a global state resulting from individual blades states.

Author:
Bruno Dillenseger, Joan Chaumont
See Also:
Serialized Form

Field Summary
static BladeState ABORTED
           
protected  int code
          integer value uniquely representing a blade state
static BladeState COMPLETED
           
static BladeState DEPLOYED
           
static BladeState DEPLOYING
           
static BladeState INCOHERENT
           
static BladeState INITIALIZED
           
static BladeState INITIALIZING
           
protected  java.lang.String label
          an explicit state name (running, stopping, stopped...)
static BladeState NONE
           
static BladeState RESUMING
           
static BladeState RUNNING
           
static BladeState STARTING
           
static BladeState STOPPED
           
static BladeState STOPPING
           
static BladeState SUSPENDED
           
static BladeState SUSPENDING
           
static BladeState UNDEPLOYED
           
 
Constructor Summary
protected BladeState(java.lang.String label)
          Creates a BladeState instance with the provided state label (unique name), and associates a unique code to this object.
 
Method Summary
 boolean equals(java.lang.Object obj)
          equality is based on the state code value
static BladeState get(int code)
          Gets the blade state instance associated to a state code
 int getCode()
          Gets the unique code representing this blade state.
static BladeState getGlobalState(java.util.Collection<BladeState> states)
          Return the global state resulting from some individual states.
static boolean isRunning(java.util.Collection<BladeState> states)
          Determines if the global state resulting from some individual states is "running", i.e. if at least one state is "running" and the others are either running or terminated (stopped, completed or aborted).
static boolean isStationaryState(java.util.Collection<BladeState> states)
          Determines if the global state resulting from some individual states is a stationary state or a transitional state.
 java.lang.String toString()
          Gets the explicit name of this state (e.g. running, stopped, etc.)
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNDEPLOYED

public static final BladeState UNDEPLOYED

DEPLOYING

public static final BladeState DEPLOYING

DEPLOYED

public static final BladeState DEPLOYED

INITIALIZING

public static final BladeState INITIALIZING

INITIALIZED

public static final BladeState INITIALIZED

STARTING

public static final BladeState STARTING

RUNNING

public static final BladeState RUNNING

SUSPENDING

public static final BladeState SUSPENDING

SUSPENDED

public static final BladeState SUSPENDED

RESUMING

public static final BladeState RESUMING

COMPLETED

public static final BladeState COMPLETED

STOPPING

public static final BladeState STOPPING

STOPPED

public static final BladeState STOPPED

ABORTED

public static final BladeState ABORTED

INCOHERENT

public static final BladeState INCOHERENT

NONE

public static final BladeState NONE

code

protected int code
integer value uniquely representing a blade state


label

protected transient java.lang.String label
an explicit state name (running, stopping, stopped...)

Constructor Detail

BladeState

protected BladeState(java.lang.String label)
Creates a BladeState instance with the provided state label (unique name), and associates a unique code to this object. Also adds this new instance to an internal instances array, using the unique code as index. Not to be called directly, unless if extending the BladeState class to add other states. Get instances through get(int) instead.

Parameters:
label - an explicit, and preferably unique and short, name describing this state.
Method Detail

get

public static BladeState get(int code)
Gets the blade state instance associated to a state code

Parameters:
code - the code representing a blade state
Returns:
the blade state object associated to the provided code. This object is immutable and unique (the same object is always returned by subsequent calls with the same state code).

getGlobalState

public static BladeState getGlobalState(java.util.Collection<BladeState> states)
Return the global state resulting from some individual states.

Parameters:
states - individual states.
Returns:
the state object representing the global state

isStationaryState

public static boolean isStationaryState(java.util.Collection<BladeState> states)
Determines if the global state resulting from some individual states is a stationary state or a transitional state.

Parameters:
states - individual states
Returns:
true if the global state is stationary, false if it is transitional

isRunning

public static boolean isRunning(java.util.Collection<BladeState> states)
Determines if the global state resulting from some individual states is "running", i.e. if at least one state is "running" and the others are either running or terminated (stopped, completed or aborted).

Parameters:
states - individual states
Returns:
true if at least one blade is running and the others are stopped, completed or aborted, false otherwise

toString

public java.lang.String toString()
Gets the explicit name of this state (e.g. running, stopped, etc.)

Overrides:
toString in class java.lang.Object
Returns:
this state's explicit name

getCode

public int getCode()
Gets the unique code representing this blade state.

Returns:
the state code

equals

public boolean equals(java.lang.Object obj)
equality is based on the state code value

Overrides:
equals in class java.lang.Object