Class DatanodeStateMachine

java.lang.Object
org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine
All Implemented Interfaces:
Closeable, AutoCloseable

public class DatanodeStateMachine extends Object implements Closeable
State Machine Class.
  • 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 datanode
      conf - - 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

      public SCMConnectionManager getConnectionManager()
      Returns the Connection manager for this state machine.
      Returns:
      - SCMConnectionManager.
    • getContainer

      public OzoneContainer getContainer()
    • handleFatalVolumeFailures

      public void handleFatalVolumeFailures()
    • getContext

      public StateContext getContext()
      Gets the current context.
      Returns:
      StateContext
    • setContext

      public void setContext(StateContext context)
      Sets the current context.
      Parameters:
      context - - Context
    • close

      public void close() throws IOException
      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 the Closeable as closed, prior to throwing the IOException.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      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

      public void join() throws InterruptedException
      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

      public CommandDispatcher getCommandDispatcher()
      returns the Command Dispatcher.
      Returns:
      CommandDispatcher
    • getSupervisor

      public ReplicationSupervisor getSupervisor()
    • getLayoutVersionManager

      public org.apache.hadoop.hdds.upgrade.HDDSLayoutVersionManager getLayoutVersionManager()
    • getLayoutStorage

      public DatanodeLayoutStorage 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

      public org.apache.hadoop.ozone.upgrade.UpgradeFinalizer<DatanodeStateMachine> getUpgradeFinalizer()
    • getConf

      public org.apache.hadoop.hdds.conf.ConfigurationSource getConf()
    • getQueueMetrics

      public DatanodeQueueMetrics getQueueMetrics()
    • getReconfigurationHandler

      public org.apache.hadoop.hdds.conf.ReconfigurationHandler getReconfigurationHandler()
    • getStateMachineThread

      public Thread getStateMachineThread()
    • getCmdProcessThread

      public Thread getCmdProcessThread()
    • getVolumeChoosingPolicy

      public VolumeChoosingPolicy getVolumeChoosingPolicy()