Class HddsDispatcher
java.lang.Object
org.apache.hadoop.ozone.container.common.impl.HddsDispatcher
- All Implemented Interfaces:
org.apache.hadoop.ozone.audit.Auditor,ContainerDispatcher
public class HddsDispatcher
extends Object
implements ContainerDispatcher, org.apache.hadoop.ozone.audit.Auditor
Ozone Container dispatcher takes a call from the netty server and routes it
to the right handler function.
-
Constructor Summary
ConstructorsConstructorDescriptionHddsDispatcher(org.apache.hadoop.hdds.conf.ConfigurationSource config, ContainerSet contSet, VolumeSet volumes, Map<org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerType, Handler> handlers, StateContext context, ContainerMetrics metrics, org.apache.hadoop.hdds.security.token.TokenVerifier tokenVerifier) Constructs an OzoneContainer that receives calls from XceiverServerHandler. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.hadoop.ozone.audit.AuditMessagebuildAuditMessageForFailure(org.apache.hadoop.ozone.audit.AuditAction op, Map<String, String> auditMap, Throwable throwable) org.apache.hadoop.ozone.audit.AuditMessagebuildAuditMessageForPerformance(org.apache.hadoop.ozone.audit.AuditAction op, Map<String, String> auditMap, org.apache.hadoop.ozone.audit.AuditLogger.PerformanceStringBuilder performance) org.apache.hadoop.ozone.audit.AuditMessagebuildAuditMessageForSuccess(org.apache.hadoop.ozone.audit.AuditAction op, Map<String, String> auditMap) voidbuildMissingContainerSetAndValidate(Map<Long, Long> container2BCSIDMap) finds and builds the missing containers in case of a lost disk etc in the ContainerSet.org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandResponseProtodispatch(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandRequestProto msg, DispatcherContext dispatcherContext) Dispatches commands to container layer.getContainer(long containerID) getHandler(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerType containerType) Returns the handler for the specified containerType.org.apache.ratis.statemachine.StateMachine.DataChannelgetStreamDataChannel(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandRequestProto msg) When uploading using stream, get StreamDataChannel.voidinit()Initialize the Dispatcher.voidsetClusterId(String clusterId) If cluster ID is not set, this will set cluster ID, otherwise it is a no-op.voidsetMetricsForTesting(ContainerMetrics containerMetrics) voidshutdown()Shutdown Dispatcher services.voidvalidateContainerCommand(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandRequestProto msg) This will be called as a part of creating the log entry during startTransaction in Ratis on the leader node.
-
Constructor Details
-
HddsDispatcher
public HddsDispatcher(org.apache.hadoop.hdds.conf.ConfigurationSource config, ContainerSet contSet, VolumeSet volumes, Map<org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerType, Handler> handlers, StateContext context, ContainerMetrics metrics, org.apache.hadoop.hdds.security.token.TokenVerifier tokenVerifier) Constructs an OzoneContainer that receives calls from XceiverServerHandler.
-
-
Method Details
-
init
public void init()Description copied from interface:ContainerDispatcherInitialize the Dispatcher.- Specified by:
initin interfaceContainerDispatcher
-
shutdown
public void shutdown()Description copied from interface:ContainerDispatcherShutdown Dispatcher services.- Specified by:
shutdownin interfaceContainerDispatcher
-
buildMissingContainerSetAndValidate
Description copied from interface:ContainerDispatcherfinds and builds the missing containers in case of a lost disk etc in the ContainerSet. It also validates the BCSID of the containers found.- Specified by:
buildMissingContainerSetAndValidatein interfaceContainerDispatcher
-
dispatch
public org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandResponseProto dispatch(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandRequestProto msg, DispatcherContext dispatcherContext) Description copied from interface:ContainerDispatcherDispatches commands to container layer.- Specified by:
dispatchin interfaceContainerDispatcher- Parameters:
msg- - Command RequestdispatcherContext- - Context info related to ContainerStateMachine- Returns:
- Command Response
-
validateContainerCommand
public void validateContainerCommand(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandRequestProto msg) throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException This will be called as a part of creating the log entry during startTransaction in Ratis on the leader node. In such cases, if the container is not in open state for writing we should just fail. Leader will propagate the exception to client.- Specified by:
validateContainerCommandin interfaceContainerDispatcher- Parameters:
msg- container command proto- Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException- In case container state is open for write requests and in invalid state for read requests.
-
getHandler
public Handler getHandler(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerType containerType) Description copied from interface:ContainerDispatcherReturns the handler for the specified containerType.- Specified by:
getHandlerin interfaceContainerDispatcher- Parameters:
containerType-
-
setClusterId
Description copied from interface:ContainerDispatcherIf cluster ID is not set, this will set cluster ID, otherwise it is a no-op.- Specified by:
setClusterIdin interfaceContainerDispatcher- Parameters:
clusterId-
-
getContainer
-
getMissingContainerSet
-
setMetricsForTesting
-
buildAuditMessageForPerformance
-
buildAuditMessageForSuccess
public org.apache.hadoop.ozone.audit.AuditMessage buildAuditMessageForSuccess(org.apache.hadoop.ozone.audit.AuditAction op, Map<String, String> auditMap) - Specified by:
buildAuditMessageForSuccessin interfaceorg.apache.hadoop.ozone.audit.Auditor
-
buildAuditMessageForFailure
public org.apache.hadoop.ozone.audit.AuditMessage buildAuditMessageForFailure(org.apache.hadoop.ozone.audit.AuditAction op, Map<String, String> auditMap, Throwable throwable) - Specified by:
buildAuditMessageForFailurein interfaceorg.apache.hadoop.ozone.audit.Auditor
-
getStreamDataChannel
public org.apache.ratis.statemachine.StateMachine.DataChannel getStreamDataChannel(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandRequestProto msg) throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException Description copied from interface:ContainerDispatcherWhen uploading using stream, get StreamDataChannel.- Specified by:
getStreamDataChannelin interfaceContainerDispatcher- Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-