Interface CommandHandler
- 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 TypeMethodDescriptionlongReturns the average time this function takes to run.org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMCommandProto.TypeReturns the command type that this command handler handles.intReturns number of times this handler has been invoked.intReturns the queued command count for this handler.default intReturns 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 intReturns the maximum number of threads allowed in the thread pool for this handler.longReturns the total time this function takes to run.voidhandle(SCMCommand<?> command, OzoneContainer container, StateContext context, SCMConnectionManager connectionManager) Handles a given SCM command.default voidstop()Override for any command with an internal threadpool, and stop the executor when this method is invoked.default voidupdateCommandStatus(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 Commandcontainer- - 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.
-