Class StateContext
java.lang.Object
org.apache.hadoop.ozone.container.common.statemachine.StateContext
Current Context of State Machine.
-
Constructor Summary
ConstructorsConstructorDescriptionStateContext(org.apache.hadoop.hdds.conf.ConfigurationSource conf, DatanodeStateMachine.DatanodeStates state, DatanodeStateMachine parent, String threadNamePrefix) Constructs a StateContext. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCmdStatus(Long key, CommandStatus status) Adds aCommandStatusto the State Machine.voidaddCmdStatus(SCMCommand<?> cmd) Adds aCommandStatusto the State Machine for given SCMCommand.voidaddCommand(SCMCommand<?> command) Adds a command to the State Machine queue.voidaddContainerAction(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerAction containerAction) Adds the ContainerAction to ContainerAction queue.voidaddContainerActionIfAbsent(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerAction containerAction) Add ContainerAction to ContainerAction queue if it's not present.voidaddEndpoint(InetSocketAddress endpoint) voidaddIncrementalReport(com.google.protobuf.Message report) Adds the report to report queue.booleanaddPipelineActionIfAbsent(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.PipelineAction pipelineAction) Add PipelineAction to PipelineAction queue if it's not present.voidvoidvoidexecute(ExecutorService service, long time, TimeUnit unit) Executes the required state function.List<com.google.protobuf.Message> getAllAvailableReports(InetSocketAddress endpoint) Returns all the available reports from the report queue, or empty list if the queue is empty.getCmdStatus(Long key) Returns the nextCommandStatusor null if it is empty.Map<org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMCommandProto.Type, Integer> Get map holding allCommandStatusobjects.com.google.protobuf.MessagelongReturns the count of the Execution.org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReportsProtoGets a point in time snapshot of all containers, any pending incremental container reports (ICR) for containers will be included in this report and this call will drop any pending ICRs.longReturn current heartbeat frequency in ms.SCMCommand<?> Returns the next command or null if it is empty.com.google.protobuf.MessageReturns the DatanodeStateMachine class that holds this state.List<org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerAction> getPendingContainerAction(InetSocketAddress endpoint, int maxLimit) Returns pending ContainerActions from the ContainerAction queue with a max limit on list size, or empty list if the queue is empty.List<org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.PipelineAction> getPendingPipelineAction(InetSocketAddress endpoint, int maxLimit) Returns pending PipelineActions from the PipelineAction queue with a max limit on list size, or empty list if the queue is empty.com.google.protobuf.MessagelongReturn current Datanode to Recon heartbeat frequency in ms.booleanGet shutdownStateMachine.getState()Returns the current state the machine is in.getTask()Returns the next task to get executed by the datanode state machine.booleanisPipelineCloseInProgress(UUID pipelineID) booleanisThreadPoolAvailable(ExecutorService executor) voidputBackReports(List<com.google.protobuf.Message> reportsToPutBack, InetSocketAddress endpoint) Adds the reports which could not be sent by heartbeat back to the reports list.voidrefreshFullReport(com.google.protobuf.Message report) refresh Full report.voidSets the current state of the machine.voidsetTermOfLeaderSCM(long term) booleanupdateCommandStatus(Long cmdId, Consumer<CommandStatus> cmdStatusUpdater) Updates the command status of a pending command.voidupdateTermOfLeaderSCM(long newTerm)
-
Constructor Details
-
StateContext
public StateContext(org.apache.hadoop.hdds.conf.ConfigurationSource conf, DatanodeStateMachine.DatanodeStates state, DatanodeStateMachine parent, String threadNamePrefix) Constructs a StateContext.- Parameters:
conf- - Configurationstate- - Stateparent- Parent State Machine
-
-
Method Details
-
getParent
Returns the DatanodeStateMachine class that holds this state.- Returns:
- DatanodeStateMachine.
-
getState
Returns the current state the machine is in.- Returns:
- state.
-
setState
Sets the current state of the machine.- Parameters:
state- state.
-
getShutdownOnError
public boolean getShutdownOnError()Get shutdownStateMachine.- Returns:
- boolean
-
addIncrementalReport
public void addIncrementalReport(com.google.protobuf.Message report) Adds the report to report queue.- Parameters:
report- report to be added
-
refreshFullReport
public void refreshFullReport(com.google.protobuf.Message report) refresh Full report.- Parameters:
report- report to be refreshed
-
putBackReports
public void putBackReports(List<com.google.protobuf.Message> reportsToPutBack, InetSocketAddress endpoint) Adds the reports which could not be sent by heartbeat back to the reports list.- Parameters:
reportsToPutBack- list of reports which failed to be sent by heartbeat.
-
getAllAvailableReports
Returns all the available reports from the report queue, or empty list if the queue is empty.- Returns:
- List of reports
-
getFullContainerReportDiscardPendingICR
public org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReportsProto getFullContainerReportDiscardPendingICR() throws IOExceptionGets a point in time snapshot of all containers, any pending incremental container reports (ICR) for containers will be included in this report and this call will drop any pending ICRs.- Returns:
- Full Container Report
- Throws:
IOException
-
addContainerAction
public void addContainerAction(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerAction containerAction) Adds the ContainerAction to ContainerAction queue.- Parameters:
containerAction- ContainerAction to be added
-
addContainerActionIfAbsent
public void addContainerActionIfAbsent(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerAction containerAction) Add ContainerAction to ContainerAction queue if it's not present.- Parameters:
containerAction- ContainerAction to be added
-
getPendingContainerAction
public List<org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerAction> getPendingContainerAction(InetSocketAddress endpoint, int maxLimit) Returns pending ContainerActions from the ContainerAction queue with a max limit on list size, or empty list if the queue is empty.- Returns:
- List<ContainerAction>
-
addPipelineActionIfAbsent
public boolean addPipelineActionIfAbsent(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.PipelineAction pipelineAction) Add PipelineAction to PipelineAction queue if it's not present.- Parameters:
pipelineAction- PipelineAction to be added
-
getPendingPipelineAction
public List<org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.PipelineAction> getPendingPipelineAction(InetSocketAddress endpoint, int maxLimit) Returns pending PipelineActions from the PipelineAction queue with a max limit on list size, or empty list if the queue is empty.- Returns:
- List<ContainerAction>
-
getTask
Returns the next task to get executed by the datanode state machine.- Returns:
- A callable that will be executed by the
DatanodeStateMachine
-
isThreadPoolAvailable
-
execute
public void execute(ExecutorService service, long time, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException Executes the required state function.- Parameters:
service- - Executor Servicetime- - seconds to waitunit- - Seconds.- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
updateTermOfLeaderSCM
public void updateTermOfLeaderSCM(long newTerm) -
setTermOfLeaderSCM
public void setTermOfLeaderSCM(long term) -
getTermOfLeaderSCM
-
getNextCommand
Returns the next command or null if it is empty.- Returns:
- SCMCommand or Null.
-
addCommand
Adds a command to the State Machine queue.- Parameters:
command- - SCMCommand.
-
getCommandQueueSummary
-
isPipelineCloseInProgress
-
getExecutionCount
public long getExecutionCount()Returns the count of the Execution.- Returns:
- long
-
getCmdStatus
Returns the nextCommandStatusor null if it is empty.- Returns:
CommandStatusor Null.
-
addCmdStatus
Adds aCommandStatusto the State Machine.- Parameters:
status- -CommandStatus.
-
addCmdStatus
Adds aCommandStatusto the State Machine for given SCMCommand.- Parameters:
cmd- -SCMCommand.
-
getCommandStatusMap
Get map holding allCommandStatusobjects. -
updateCommandStatus
Updates the command status of a pending command.- Parameters:
cmdId- command idcmdStatusUpdater- Consumer to update command status.- Returns:
- true if command status updated successfully else if the command associated with the command id does not exist in the context.
-
configureHeartbeatFrequency
public void configureHeartbeatFrequency() -
getHeartbeatFrequency
public long getHeartbeatFrequency()Return current heartbeat frequency in ms. -
addEndpoint
-
getContainerReports
public com.google.protobuf.Message getContainerReports() -
getNodeReport
public com.google.protobuf.Message getNodeReport() -
getPipelineReports
public com.google.protobuf.Message getPipelineReports() -
configureReconHeartbeatFrequency
public void configureReconHeartbeatFrequency() -
getReconHeartbeatFrequency
public long getReconHeartbeatFrequency()Return current Datanode to Recon heartbeat frequency in ms. -
getPipelineActionQueueSize
-
getContainerActionQueueSize
-
getIncrementalReportQueueSize
-
getQueueMetrics
-
getThreadNamePrefix
-