Search in sources :

Example 1 with CloseContainerEventHandler

use of org.apache.hadoop.hdds.scm.container.CloseContainerEventHandler in project ozone by apache.

the class TestBlockManager method setUp.

@Before
public void setUp() throws Exception {
    conf = SCMTestUtils.getConf();
    numContainerPerOwnerInPipeline = conf.getInt(ScmConfigKeys.OZONE_SCM_PIPELINE_OWNER_CONTAINER_COUNT, ScmConfigKeys.OZONE_SCM_PIPELINE_OWNER_CONTAINER_COUNT_DEFAULT);
    conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, folder.newFolder().toString());
    conf.setBoolean(HddsConfigKeys.HDDS_SCM_SAFEMODE_PIPELINE_CREATION, false);
    conf.setTimeDuration(HddsConfigKeys.HDDS_PIPELINE_REPORT_INTERVAL, 5, TimeUnit.SECONDS);
    // Override the default Node Manager and SCMHAManager
    // in SCM with the Mock one.
    nodeManager = new MockNodeManager(true, 10);
    scmHAManager = MockSCMHAManager.getInstance(true);
    eventQueue = new EventQueue();
    scmContext = SCMContext.emptyContext();
    serviceManager = new SCMServiceManager();
    scmMetadataStore = new SCMMetadataStoreImpl(conf);
    scmMetadataStore.start(conf);
    sequenceIdGen = new SequenceIdGenerator(conf, scmHAManager, scmMetadataStore.getSequenceIdTable());
    pipelineManager = PipelineManagerImpl.newPipelineManager(conf, scmHAManager, nodeManager, scmMetadataStore.getPipelineTable(), eventQueue, scmContext, serviceManager);
    PipelineProvider mockRatisProvider = new MockRatisPipelineProvider(nodeManager, pipelineManager.getStateManager(), conf, eventQueue);
    pipelineManager.setPipelineProvider(HddsProtos.ReplicationType.RATIS, mockRatisProvider);
    ContainerManager containerManager = new ContainerManagerImpl(conf, scmHAManager, sequenceIdGen, pipelineManager, scmMetadataStore.getContainerTable());
    SCMSafeModeManager safeModeManager = new SCMSafeModeManager(conf, containerManager.getContainers(), containerManager, pipelineManager, eventQueue, serviceManager, scmContext) {

        @Override
        public void emitSafeModeStatus() {
        // skip
        }
    };
    SCMConfigurator configurator = new SCMConfigurator();
    configurator.setScmNodeManager(nodeManager);
    configurator.setPipelineManager(pipelineManager);
    configurator.setContainerManager(containerManager);
    configurator.setScmSafeModeManager(safeModeManager);
    configurator.setMetadataStore(scmMetadataStore);
    configurator.setSCMHAManager(scmHAManager);
    configurator.setScmContext(scmContext);
    scm = HddsTestUtils.getScm(conf, configurator);
    // Initialize these fields so that the tests can pass.
    mapping = scm.getContainerManager();
    blockManager = (BlockManagerImpl) scm.getScmBlockManager();
    DatanodeCommandHandler handler = new DatanodeCommandHandler();
    eventQueue.addHandler(SCMEvents.DATANODE_COMMAND, handler);
    CloseContainerEventHandler closeContainerHandler = new CloseContainerEventHandler(pipelineManager, mapping, scmContext);
    eventQueue.addHandler(SCMEvents.CLOSE_CONTAINER, closeContainerHandler);
    replicationConfig = RatisReplicationConfig.getInstance(ReplicationFactor.THREE);
    scm.getScmContext().updateSafeModeStatus(new SafeModeStatus(false, true));
}
Also used : ContainerManager(org.apache.hadoop.hdds.scm.container.ContainerManager) StorageContainerManager(org.apache.hadoop.hdds.scm.server.StorageContainerManager) MockRatisPipelineProvider(org.apache.hadoop.hdds.scm.pipeline.MockRatisPipelineProvider) PipelineProvider(org.apache.hadoop.hdds.scm.pipeline.PipelineProvider) MockNodeManager(org.apache.hadoop.hdds.scm.container.MockNodeManager) EventQueue(org.apache.hadoop.hdds.server.events.EventQueue) SCMSafeModeManager(org.apache.hadoop.hdds.scm.safemode.SCMSafeModeManager) ContainerManagerImpl(org.apache.hadoop.hdds.scm.container.ContainerManagerImpl) CloseContainerEventHandler(org.apache.hadoop.hdds.scm.container.CloseContainerEventHandler) SCMMetadataStoreImpl(org.apache.hadoop.hdds.scm.metadata.SCMMetadataStoreImpl) MockRatisPipelineProvider(org.apache.hadoop.hdds.scm.pipeline.MockRatisPipelineProvider) SequenceIdGenerator(org.apache.hadoop.hdds.scm.ha.SequenceIdGenerator) SafeModeStatus(org.apache.hadoop.hdds.scm.safemode.SCMSafeModeManager.SafeModeStatus) SCMServiceManager(org.apache.hadoop.hdds.scm.ha.SCMServiceManager) SCMConfigurator(org.apache.hadoop.hdds.scm.server.SCMConfigurator) Before(org.junit.Before)

Example 2 with CloseContainerEventHandler

use of org.apache.hadoop.hdds.scm.container.CloseContainerEventHandler in project ozone by apache.

the class StorageContainerManager method initializeEventHandlers.

private void initializeEventHandlers() {
    CloseContainerEventHandler closeContainerHandler = new CloseContainerEventHandler(pipelineManager, containerManager, scmContext);
    NodeReportHandler nodeReportHandler = new NodeReportHandler(scmNodeManager);
    PipelineReportHandler pipelineReportHandler = new PipelineReportHandler(scmSafeModeManager, pipelineManager, scmContext, configuration);
    CommandStatusReportHandler cmdStatusReportHandler = new CommandStatusReportHandler();
    NewNodeHandler newNodeHandler = new NewNodeHandler(pipelineManager, scmDecommissionManager, configuration, serviceManager);
    StaleNodeHandler staleNodeHandler = new StaleNodeHandler(scmNodeManager, pipelineManager, configuration);
    DeadNodeHandler deadNodeHandler = new DeadNodeHandler(scmNodeManager, pipelineManager, containerManager);
    StartDatanodeAdminHandler datanodeStartAdminHandler = new StartDatanodeAdminHandler(scmNodeManager, pipelineManager);
    ReadOnlyHealthyToHealthyNodeHandler readOnlyHealthyToHealthyNodeHandler = new ReadOnlyHealthyToHealthyNodeHandler(configuration, serviceManager);
    HealthyReadOnlyNodeHandler healthyReadOnlyNodeHandler = new HealthyReadOnlyNodeHandler(scmNodeManager, pipelineManager, configuration);
    ContainerActionsHandler actionsHandler = new ContainerActionsHandler();
    ContainerReportHandler containerReportHandler = new ContainerReportHandler(scmNodeManager, containerManager, scmContext, configuration);
    IncrementalContainerReportHandler incrementalContainerReportHandler = new IncrementalContainerReportHandler(scmNodeManager, containerManager, scmContext);
    PipelineActionHandler pipelineActionHandler = new PipelineActionHandler(pipelineManager, scmContext, configuration);
    CRLStatusReportHandler crlStatusReportHandler = new CRLStatusReportHandler(certificateStore, configuration);
    eventQueue.addHandler(SCMEvents.DATANODE_COMMAND, scmNodeManager);
    eventQueue.addHandler(SCMEvents.RETRIABLE_DATANODE_COMMAND, scmNodeManager);
    eventQueue.addHandler(SCMEvents.NODE_REPORT, nodeReportHandler);
    // Use the same executor for both ICR and FCR.
    // The Executor maps the event to a thread for DN.
    // Dispatcher should always dispatch FCR first followed by ICR
    List<ThreadPoolExecutor> executors = FixedThreadPoolWithAffinityExecutor.initializeExecutorPool(SCMEvents.CONTAINER_REPORT.getName() + "_OR_" + SCMEvents.INCREMENTAL_CONTAINER_REPORT.getName());
    EventExecutor<ContainerReportFromDatanode> containerReportExecutors = new FixedThreadPoolWithAffinityExecutor<>(EventQueue.getExecutorName(SCMEvents.CONTAINER_REPORT, containerReportHandler), executors);
    EventExecutor<IncrementalContainerReportFromDatanode> incrementalReportExecutors = new FixedThreadPoolWithAffinityExecutor<>(EventQueue.getExecutorName(SCMEvents.INCREMENTAL_CONTAINER_REPORT, incrementalContainerReportHandler), executors);
    eventQueue.addHandler(SCMEvents.CONTAINER_REPORT, containerReportExecutors, containerReportHandler);
    eventQueue.addHandler(SCMEvents.INCREMENTAL_CONTAINER_REPORT, incrementalReportExecutors, incrementalContainerReportHandler);
    eventQueue.addHandler(SCMEvents.CONTAINER_ACTIONS, actionsHandler);
    eventQueue.addHandler(SCMEvents.CLOSE_CONTAINER, closeContainerHandler);
    eventQueue.addHandler(SCMEvents.NEW_NODE, newNodeHandler);
    eventQueue.addHandler(SCMEvents.STALE_NODE, staleNodeHandler);
    eventQueue.addHandler(SCMEvents.HEALTHY_READONLY_TO_HEALTHY_NODE, readOnlyHealthyToHealthyNodeHandler);
    eventQueue.addHandler(SCMEvents.HEALTHY_READONLY_NODE, healthyReadOnlyNodeHandler);
    eventQueue.addHandler(SCMEvents.DEAD_NODE, deadNodeHandler);
    eventQueue.addHandler(SCMEvents.START_ADMIN_ON_NODE, datanodeStartAdminHandler);
    eventQueue.addHandler(SCMEvents.CMD_STATUS_REPORT, cmdStatusReportHandler);
    eventQueue.addHandler(SCMEvents.DELETE_BLOCK_STATUS, (DeletedBlockLogImpl) scmBlockManager.getDeletedBlockLog());
    eventQueue.addHandler(SCMEvents.PIPELINE_ACTIONS, pipelineActionHandler);
    eventQueue.addHandler(SCMEvents.PIPELINE_REPORT, pipelineReportHandler);
    eventQueue.addHandler(SCMEvents.CRL_STATUS_REPORT, crlStatusReportHandler);
}
Also used : NodeReportHandler(org.apache.hadoop.hdds.scm.node.NodeReportHandler) PipelineActionHandler(org.apache.hadoop.hdds.scm.pipeline.PipelineActionHandler) FixedThreadPoolWithAffinityExecutor(org.apache.hadoop.hdds.server.events.FixedThreadPoolWithAffinityExecutor) IncrementalContainerReportHandler(org.apache.hadoop.hdds.scm.container.IncrementalContainerReportHandler) ContainerReportHandler(org.apache.hadoop.hdds.scm.container.ContainerReportHandler) DeadNodeHandler(org.apache.hadoop.hdds.scm.node.DeadNodeHandler) HealthyReadOnlyNodeHandler(org.apache.hadoop.hdds.scm.node.HealthyReadOnlyNodeHandler) ContainerReportFromDatanode(org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.ContainerReportFromDatanode) IncrementalContainerReportFromDatanode(org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.IncrementalContainerReportFromDatanode) CloseContainerEventHandler(org.apache.hadoop.hdds.scm.container.CloseContainerEventHandler) CommandStatusReportHandler(org.apache.hadoop.hdds.scm.command.CommandStatusReportHandler) PipelineReportHandler(org.apache.hadoop.hdds.scm.pipeline.PipelineReportHandler) ContainerActionsHandler(org.apache.hadoop.hdds.scm.container.ContainerActionsHandler) StartDatanodeAdminHandler(org.apache.hadoop.hdds.scm.node.StartDatanodeAdminHandler) StaleNodeHandler(org.apache.hadoop.hdds.scm.node.StaleNodeHandler) ReadOnlyHealthyToHealthyNodeHandler(org.apache.hadoop.hdds.scm.node.ReadOnlyHealthyToHealthyNodeHandler) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) CRLStatusReportHandler(org.apache.hadoop.hdds.scm.crl.CRLStatusReportHandler) IncrementalContainerReportFromDatanode(org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.IncrementalContainerReportFromDatanode) NewNodeHandler(org.apache.hadoop.hdds.scm.node.NewNodeHandler) IncrementalContainerReportHandler(org.apache.hadoop.hdds.scm.container.IncrementalContainerReportHandler)

Aggregations

CloseContainerEventHandler (org.apache.hadoop.hdds.scm.container.CloseContainerEventHandler)2 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 CommandStatusReportHandler (org.apache.hadoop.hdds.scm.command.CommandStatusReportHandler)1 ContainerActionsHandler (org.apache.hadoop.hdds.scm.container.ContainerActionsHandler)1 ContainerManager (org.apache.hadoop.hdds.scm.container.ContainerManager)1 ContainerManagerImpl (org.apache.hadoop.hdds.scm.container.ContainerManagerImpl)1 ContainerReportHandler (org.apache.hadoop.hdds.scm.container.ContainerReportHandler)1 IncrementalContainerReportHandler (org.apache.hadoop.hdds.scm.container.IncrementalContainerReportHandler)1 MockNodeManager (org.apache.hadoop.hdds.scm.container.MockNodeManager)1 CRLStatusReportHandler (org.apache.hadoop.hdds.scm.crl.CRLStatusReportHandler)1 SCMServiceManager (org.apache.hadoop.hdds.scm.ha.SCMServiceManager)1 SequenceIdGenerator (org.apache.hadoop.hdds.scm.ha.SequenceIdGenerator)1 SCMMetadataStoreImpl (org.apache.hadoop.hdds.scm.metadata.SCMMetadataStoreImpl)1 DeadNodeHandler (org.apache.hadoop.hdds.scm.node.DeadNodeHandler)1 HealthyReadOnlyNodeHandler (org.apache.hadoop.hdds.scm.node.HealthyReadOnlyNodeHandler)1 NewNodeHandler (org.apache.hadoop.hdds.scm.node.NewNodeHandler)1 NodeReportHandler (org.apache.hadoop.hdds.scm.node.NodeReportHandler)1 ReadOnlyHealthyToHealthyNodeHandler (org.apache.hadoop.hdds.scm.node.ReadOnlyHealthyToHealthyNodeHandler)1 StaleNodeHandler (org.apache.hadoop.hdds.scm.node.StaleNodeHandler)1 StartDatanodeAdminHandler (org.apache.hadoop.hdds.scm.node.StartDatanodeAdminHandler)1