Package org.metricshub.ipmi.core.sm
Class StateMachine
java.lang.Object
org.metricshub.ipmi.core.sm.StateMachine
- All Implemented Interfaces:
UdpListener
State machine for connecting and acquiring session with the remote host via
IPMI v.2.0.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddoExternalAction(StateMachineAction action) Sends a notification of an action to allMachineObservers.voiddoTransition(StateMachineEvent event) Performs aStatetransition according to the event andcurrentstate.intbooleanisActive()voidnotifyMessage(UdpMessage message) Notifies listener of the UDP message that was received.voidregister(MachineObserver observer) Registers the listener in theStateMachineso it will be notified of theStateMachineActions performed viadoExternalAction(StateMachineAction)voidsendMessage(byte[] message) Sends message viamessengerto the managed system.voidsetCurrent(State current) voidstart(InetAddress address, int port) Sets the State Machine in the initial state.voidstop()Cleans up the machine resources and leaves the current state: a stopped machine no longer reports a valid session.
-
Constructor Details
-
StateMachine
Initializes the State Machine- Parameters:
messenger- -Messengerconnected to theConstants.IPMI_PORT
-
-
Method Details
-
getCurrent
-
setCurrent
-
sendMessage
Sends message viamessengerto the managed system.- Parameters:
message- - the encoded message- Throws:
IOException- - when sending of the message fails
-
getRemoteMachineAddress
-
getRemoteMachinePort
public int getRemoteMachinePort() -
doExternalAction
Sends a notification of an action to allMachineObservers. AMessageActionemitted by a state while the lock is held is deferred until the transition releases it; the other actions are published at once.- Parameters:
action- - aStateMachineActionto perform
-
start
Sets the State Machine in the initial state.- Parameters:
address- - IP address of the remote machine.port- - UDP remoteMachinePort of the remote machine- See Also:
-
stop
public void stop()Cleans up the machine resources and leaves the current state: a stopped machine no longer reports a valid session.- See Also:
-
isActive
public boolean isActive()- Returns:
- true if
StateMachineis initialized, false otherwise. - See Also:
-
doTransition
Performs aStatetransition according to the event andcurrentstate. Transitions and received messages are serialized, so a late reply cannot interleave with the timeout or close of the request it answers; the in-session messages are dispatched once the lock is released.- Parameters:
event- -StateMachineEventinvoking the transition- Throws:
NullPointerException- - when machine was not yet started- See Also:
-
notifyMessage
Description copied from interface:UdpListenerNotifies listener of the UDP message that was received.- Specified by:
notifyMessagein interfaceUdpListener- Parameters:
message- - message received
-
register
Registers the listener in theStateMachineso it will be notified of theStateMachineActions performed viadoExternalAction(StateMachineAction)- Parameters:
observer- -MachineObserverto register
-