Class DatanodeStateMachine
java.lang.Object
org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine
- All Implemented Interfaces:
Closeable,AutoCloseable
State Machine Class.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumStates that a datanode can be in. -
Constructor Summary
ConstructorsConstructorDescriptionDatanodeStateMachine(org.apache.hadoop.hdds.protocol.DatanodeDetails datanodeDetails, org.apache.hadoop.hdds.conf.ConfigurationSource conf) DatanodeStateMachine(HddsDatanodeService hddsDatanodeService, org.apache.hadoop.hdds.protocol.DatanodeDetails datanodeDetails, org.apache.hadoop.hdds.conf.ConfigurationSource conf, org.apache.hadoop.hdds.security.x509.certificate.client.CertificateClient certClient, org.apache.hadoop.hdds.security.symmetric.SecretKeyClient secretKeyClient, HddsDatanodeStopService hddsDatanodeStopService, org.apache.hadoop.hdds.conf.ReconfigurationHandler reconfigurationHandler) Constructs a datanode state machine. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this stream and releases any system resources associated with it.org.apache.hadoop.ozone.upgrade.UpgradeFinalization.StatusAndMessagesreturns the Command Dispatcher.org.apache.hadoop.hdds.conf.ConfigurationSourcegetConf()Returns the Connection manager for this state machine.Gets the current context.org.apache.hadoop.hdds.protocol.DatanodeDetailsReturn DatanodeDetails if set, return null otherwise.org.apache.hadoop.hdds.upgrade.HDDSLayoutVersionManagerMap<org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMCommandProto.Type, Integer> Returns a summary of the commands queued in the datanode.org.apache.hadoop.hdds.conf.ReconfigurationHandlerorg.apache.hadoop.ozone.upgrade.UpgradeFinalizer<DatanodeStateMachine> voidbooleanbooleanCheck if the datanode state machine daemon is stopped.voidjoin()Waits for DatanodeStateMachine to exit.org.apache.hadoop.ozone.upgrade.UpgradeFinalization.StatusAndMessagesvoidsetContext(StateContext context) Sets the current context.voidStart datanode state machine as a single thread daemon.voidStop the daemon thread of the datanode state machine.voidCalling this will immediately trigger a heartbeat to the SCMs.
-
Constructor Details
-
DatanodeStateMachine
public DatanodeStateMachine(HddsDatanodeService hddsDatanodeService, org.apache.hadoop.hdds.protocol.DatanodeDetails datanodeDetails, org.apache.hadoop.hdds.conf.ConfigurationSource conf, org.apache.hadoop.hdds.security.x509.certificate.client.CertificateClient certClient, org.apache.hadoop.hdds.security.symmetric.SecretKeyClient secretKeyClient, HddsDatanodeStopService hddsDatanodeStopService, org.apache.hadoop.hdds.conf.ReconfigurationHandler reconfigurationHandler) throws IOException Constructs a datanode state machine.- Parameters:
datanodeDetails- - DatanodeDetails used to identify a datanodeconf- - Configuration.certClient- - Datanode Certificate client, required if security is enabled- Throws:
IOException
-
DatanodeStateMachine
public DatanodeStateMachine(org.apache.hadoop.hdds.protocol.DatanodeDetails datanodeDetails, org.apache.hadoop.hdds.conf.ConfigurationSource conf) throws IOException - Throws:
IOException
-
-
Method Details
-
getDatanodeDetails
public org.apache.hadoop.hdds.protocol.DatanodeDetails getDatanodeDetails()Return DatanodeDetails if set, return null otherwise.- Returns:
- DatanodeDetails
-
getConnectionManager
Returns the Connection manager for this state machine.- Returns:
- - SCMConnectionManager.
-
getContainer
-
handleFatalVolumeFailures
public void handleFatalVolumeFailures() -
getContext
Gets the current context.- Returns:
- StateContext
-
setContext
Sets the current context.- Parameters:
context- - Context
-
close
Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.As noted in
AutoCloseable.close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark theCloseableas closed, prior to throwing theIOException.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- if an I/O error occurs
-
startDaemon
public void startDaemon()Start datanode state machine as a single thread daemon. -
triggerHeartbeat
public void triggerHeartbeat()Calling this will immediately trigger a heartbeat to the SCMs. This heartbeat will also include all the reports which are ready to be sent by datanode. -
join
Waits for DatanodeStateMachine to exit.- Throws:
InterruptedException
-
getQueuedCommandCount
public Map<org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMCommandProto.Type,Integer> getQueuedCommandCount()Returns a summary of the commands queued in the datanode. Commands are queued in two places. In the CommandQueue inside the StateContext object. A single thread picks commands from there and hands the command to the CommandDispatcher. This finds the handler for the command based on its command type and either executes the command immediately in the current (single) thread, or queues it in the handler where a thread pool executor will process it. The total commands queued in the datanode is therefore the sum those in the CommandQueue and the dispatcher queues.- Returns:
- A map containing a count for each known command.
-
stopDaemon
public void stopDaemon()Stop the daemon thread of the datanode state machine. -
isDaemonStarted
public boolean isDaemonStarted() -
isDaemonStopped
public boolean isDaemonStopped()Check if the datanode state machine daemon is stopped.- Returns:
- True if datanode state machine daemon is stopped and false otherwise.
-
getCommandDispatcher
returns the Command Dispatcher.- Returns:
- CommandDispatcher
-
getSupervisor
-
getLayoutVersionManager
public org.apache.hadoop.hdds.upgrade.HDDSLayoutVersionManager getLayoutVersionManager() -
getLayoutStorage
-
finalizeUpgrade
public org.apache.hadoop.ozone.upgrade.UpgradeFinalization.StatusAndMessages finalizeUpgrade() throws IOException- Throws:
IOException
-
queryUpgradeStatus
public org.apache.hadoop.ozone.upgrade.UpgradeFinalization.StatusAndMessages queryUpgradeStatus() throws IOException- Throws:
IOException
-
getUpgradeFinalizer
-
getConf
public org.apache.hadoop.hdds.conf.ConfigurationSource getConf() -
getQueueMetrics
-
getReconfigurationHandler
public org.apache.hadoop.hdds.conf.ReconfigurationHandler getReconfigurationHandler() -
getStateMachineThread
-
getCmdProcessThread
-
getVolumeChoosingPolicy
-