All Known Implementing Classes:
CloseContainerCommandHandler, ClosePipelineCommandHandler, CreatePipelineCommandHandler, DeleteBlocksCommandHandler, DeleteContainerCommandHandler, FinalizeNewLayoutVersionCommandHandler, ReconcileContainerCommandHandler, ReconstructECContainersCommandHandler, RefreshVolumeUsageCommandHandler, ReplicateContainerCommandHandler, SetNodeOperationalStateCommandHandler

public interface CommandHandler
Generic interface for handlers.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the average time this function takes to run.
    org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMCommandProto.Type
    Returns the command type that this command handler handles.
    int
    Returns number of times this handler has been invoked.
    int
    Returns the queued command count for this handler.
    default int
    Returns the number of threads currently executing tasks in the thread pool for this handler.If the subclass does not override this method, the default implementation will return -1, indicating that the number of active threads is not applicable or not defined.
    default int
    Returns the maximum number of threads allowed in the thread pool for this handler.
    long
    Returns the total time this function takes to run.
    void
    handle(SCMCommand<?> command, OzoneContainer container, StateContext context, SCMConnectionManager connectionManager)
    Handles a given SCM command.
    default void
    Override for any command with an internal threadpool, and stop the executor when this method is invoked.
    default void
    updateCommandStatus(StateContext context, SCMCommand<?> command, Consumer<CommandStatus> cmdStatusUpdater, org.slf4j.Logger log)
    Default implementation for updating command status.
  • Method Details

    • handle

      void handle(SCMCommand<?> command, OzoneContainer container, StateContext context, SCMConnectionManager connectionManager)
      Handles a given SCM command.
      Parameters:
      command - - SCM Command
      container - - Ozone Container.
      context - - Current Context.
      connectionManager - - The SCMs that we are talking to.
    • getCommandType

      org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMCommandProto.Type getCommandType()
      Returns the command type that this command handler handles.
      Returns:
      Type
    • getInvocationCount

      int getInvocationCount()
      Returns number of times this handler has been invoked.
      Returns:
      int
    • getAverageRunTime

      long getAverageRunTime()
      Returns the average time this function takes to run.
      Returns:
      long
    • getTotalRunTime

      long getTotalRunTime()
      Returns the total time this function takes to run.
      Returns:
      long
    • updateCommandStatus

      default void updateCommandStatus(StateContext context, SCMCommand<?> command, Consumer<CommandStatus> cmdStatusUpdater, org.slf4j.Logger log)
      Default implementation for updating command status.
    • stop

      default void stop()
      Override for any command with an internal threadpool, and stop the executor when this method is invoked.
    • getQueuedCount

      int getQueuedCount()
      Returns the queued command count for this handler.
      Returns:
      The number of queued commands inside this handler.
    • getThreadPoolMaxPoolSize

      default int getThreadPoolMaxPoolSize()
      Returns the maximum number of threads allowed in the thread pool for this handler. If the subclass does not override this method, the default implementation will return -1, indicating that the maximum pool size is not applicable or not defined.
      Returns:
      The maximum number of threads allowed in the thread pool, or -1 if not applicable or not defined.
    • getThreadPoolActivePoolSize

      default int getThreadPoolActivePoolSize()
      Returns the number of threads currently executing tasks in the thread pool for this handler.If the subclass does not override this method, the default implementation will return -1, indicating that the number of active threads is not applicable or not defined.
      Returns:
      The number of threads currently executing tasks in the thread pool, or -1 if not applicable or not defined.