Class StateMachineFactory<OPERAND,STATE extends Enum<STATE>,EVENTTYPE extends Enum<EVENTTYPE>,EVENT>

java.lang.Object
org.apache.hadoop.yarn.state.StateMachineFactory<OPERAND,STATE,EVENTTYPE,EVENT>
Type Parameters:
OPERAND - The object type on which this state machine operates.
STATE - The state of the entity.
EVENTTYPE - The external eventType to be handled.
EVENT - The event object.

@Public @Evolving public final class StateMachineFactory<OPERAND,STATE extends Enum<STATE>,EVENTTYPE extends Enum<EVENTTYPE>,EVENT> extends Object
State machine topology. This object is semantically immutable. If you have a StateMachineFactory there's no operation in the API that changes its semantic properties.
  • Constructor Details

    • StateMachineFactory

      public StateMachineFactory(STATE defaultInitialState)
      Constructor This is the only constructor in the API.
      Parameters:
      defaultInitialState - default initial state.
  • Method Details

    • addTransition

      public StateMachineFactory<OPERAND,STATE,EVENTTYPE,EVENT> addTransition(STATE preState, STATE postState, EVENTTYPE eventType)
      Parameters:
      preState - pre-transition state
      postState - post-transition state
      eventType - stimulus for the transition
      Returns:
      a NEW StateMachineFactory just like this with the current transition added as a new legal transition. This overload has no hook object. Note that the returned StateMachineFactory is a distinct object. This method is part of the API.
    • addTransition

      public StateMachineFactory<OPERAND,STATE,EVENTTYPE,EVENT> addTransition(STATE preState, STATE postState, Set<EVENTTYPE> eventTypes)
      Parameters:
      preState - pre-transition state
      postState - post-transition state
      eventTypes - List of stimuli for the transitions
      Returns:
      a NEW StateMachineFactory just like this with the current transition added as a new legal transition. This overload has no hook object. Note that the returned StateMachineFactory is a distinct object. This method is part of the API.
    • addTransition

      public StateMachineFactory<OPERAND,STATE,EVENTTYPE,EVENT> addTransition(STATE preState, STATE postState, Set<EVENTTYPE> eventTypes, SingleArcTransition<OPERAND,EVENT> hook)
      Parameters:
      preState - pre-transition state
      postState - post-transition state
      eventTypes - List of stimuli for the transitions
      hook - transition hook
      Returns:
      a NEW StateMachineFactory just like this with the current transition added as a new legal transition Note that the returned StateMachineFactory is a distinct object. This method is part of the API.
    • addTransition

      public StateMachineFactory<OPERAND,STATE,EVENTTYPE,EVENT> addTransition(STATE preState, STATE postState, EVENTTYPE eventType, SingleArcTransition<OPERAND,EVENT> hook)
      Parameters:
      preState - pre-transition state
      postState - post-transition state
      eventType - stimulus for the transition
      hook - transition hook
      Returns:
      a NEW StateMachineFactory just like this with the current transition added as a new legal transition Note that the returned StateMachineFactory is a distinct object. This method is part of the API.
    • addTransition

      public StateMachineFactory<OPERAND,STATE,EVENTTYPE,EVENT> addTransition(STATE preState, Set<STATE> postStates, EVENTTYPE eventType, MultipleArcTransition<OPERAND,EVENT,STATE> hook)
      Parameters:
      preState - pre-transition state
      postStates - valid post-transition states
      eventType - stimulus for the transition
      hook - transition hook
      Returns:
      a NEW StateMachineFactory just like this with the current transition added as a new legal transition Note that the returned StateMachineFactory is a distinct object. This method is part of the API.
    • installTopology

      public StateMachineFactory<OPERAND,STATE,EVENTTYPE,EVENT> installTopology()
      Returns:
      a StateMachineFactory just like this, except that if you won't need any synchronization to build a state machine Note that the returned StateMachineFactory is a distinct object. This method is part of the API. The only way you could distinguish the returned StateMachineFactory from this would be by measuring the performance of the derived StateMachine you can get from it. Calling this is optional. It doesn't change the semantics of the factory, if you call it then when you use the factory there is no synchronization.
    • make

      public StateMachine<STATE,EVENTTYPE,EVENT> make(OPERAND operand, STATE initialState, StateTransitionListener<OPERAND,EVENT,STATE> listener)
      A StateMachine that accepts a transition listener.
      Parameters:
      operand - the object upon which the returned StateMachine will operate.
      initialState - the state in which the returned StateMachine will start.
      listener - An implementation of a StateTransitionListener.
      Returns:
      A (@link StateMachine}.
    • make

      public StateMachine<STATE,EVENTTYPE,EVENT> make(OPERAND operand, STATE initialState)
    • make

      public StateMachine<STATE,EVENTTYPE,EVENT> make(OPERAND operand)
    • generateStateGraph

      public org.apache.hadoop.yarn.state.Graph generateStateGraph(String name)
      Generate a graph represents the state graph of this StateMachine
      Parameters:
      name - graph name
      Returns:
      Graph object generated