Class SCMCommand<T extends com.google.protobuf.Message>
java.lang.Object
org.apache.hadoop.ozone.protocol.commands.SCMCommand<T>
- Type Parameters:
T-
- All Implemented Interfaces:
org.apache.hadoop.hdds.server.events.IdentifiableEventPayload
- Direct Known Subclasses:
CloseContainerCommand,ClosePipelineCommand,CreatePipelineCommand,DeleteBlocksCommand,DeleteContainerCommand,FinalizeNewLayoutVersionCommand,ReconcileContainerCommand,ReconstructECContainersCommand,RefreshVolumeUsageCommand,ReplicateContainerCommand,ReregisterCommand,SetNodeOperationalStateCommand
public abstract class SCMCommand<T extends com.google.protobuf.Message>
extends Object
implements org.apache.hadoop.hdds.server.events.IdentifiableEventPayload
A class that acts as the base class to convert between Java and SCM
commands in protobuf format.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanlonglonggetId()Gets the commandId of this object.abstract TgetProto()Gets the protobuf message of this object.longgetTerm()Get term of this command.abstract org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMCommandProto.TypegetType()Returns the type of this command.booleanhasExpired(long currentEpochMs) If a deadline has been set to a non zero value, test if the current time passed is beyond the deadline or not.voidsetDeadline(long deadlineMs) Allows a deadline to be set on the command.voidsetEncodedToken(String encodedToken) voidsetTerm(long term) Set term of this command.toString()
-
Method Details
-
getType
public abstract org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMCommandProto.Type getType()Returns the type of this command.- Returns:
- Type
-
getProto
Gets the protobuf message of this object.- Returns:
- A protobuf message.
-
getId
public long getId()Gets the commandId of this object.- Specified by:
getIdin interfaceorg.apache.hadoop.hdds.server.events.IdentifiableEventPayload- Returns:
- uuid.
-
getTerm
public long getTerm()Get term of this command.- Returns:
- term
-
setTerm
public void setTerm(long term) Set term of this command. -
getEncodedToken
-
setEncodedToken
-
setDeadline
public void setDeadline(long deadlineMs) Allows a deadline to be set on the command. The deadline is set as the milliseconds since the epoch when the command must have been completed by. It is up to the code processing the command to enforce the deadline by calling the hasExpired() method, and the code sending the command to set the deadline. The default deadline is zero, which means no deadline.- Parameters:
deadlineMs- The ms since epoch when the command must have completed by.
-
getDeadline
public long getDeadline()- Returns:
- The deadline set for this command, or zero if no command has been set.
-
hasExpired
public boolean hasExpired(long currentEpochMs) If a deadline has been set to a non zero value, test if the current time passed is beyond the deadline or not.- Parameters:
currentEpochMs- current time in milliseconds since the epoch.- Returns:
- false if there is no deadline, or it has not expired. True if the set deadline has expired.
-
contributesToQueueSize
public boolean contributesToQueueSize() -
toString
-