Search in sources :

Example 6 with PipelineManagerImpl

use of org.apache.hadoop.hdds.scm.pipeline.PipelineManagerImpl in project ozone by apache.

the class TestHealthyPipelineSafeModeRule method testHealthyPipelineSafeModeRuleWithNoPipelines.

@Test
public void testHealthyPipelineSafeModeRuleWithNoPipelines() throws Exception {
    EventQueue eventQueue = new EventQueue();
    SCMServiceManager serviceManager = new SCMServiceManager();
    SCMContext scmContext = SCMContext.emptyContext();
    List<ContainerInfo> containers = new ArrayList<>(HddsTestUtils.getContainerInfo(1));
    String storageDir = GenericTestUtils.getTempPath(TestHealthyPipelineSafeModeRule.class.getName() + UUID.randomUUID());
    OzoneConfiguration config = new OzoneConfiguration();
    MockNodeManager nodeManager = new MockNodeManager(true, 0);
    config.set(HddsConfigKeys.OZONE_METADATA_DIRS, storageDir);
    // enable pipeline check
    config.setBoolean(HddsConfigKeys.HDDS_SCM_SAFEMODE_PIPELINE_AVAILABILITY_CHECK, true);
    config.setBoolean(HddsConfigKeys.HDDS_SCM_SAFEMODE_PIPELINE_CREATION, false);
    SCMMetadataStore scmMetadataStore = new SCMMetadataStoreImpl(config);
    try {
        PipelineManagerImpl pipelineManager = PipelineManagerImpl.newPipelineManager(config, MockSCMHAManager.getInstance(true), nodeManager, scmMetadataStore.getPipelineTable(), eventQueue, scmContext, serviceManager);
        PipelineProvider mockRatisProvider = new MockRatisPipelineProvider(nodeManager, pipelineManager.getStateManager(), config);
        pipelineManager.setPipelineProvider(HddsProtos.ReplicationType.RATIS, mockRatisProvider);
        SCMSafeModeManager scmSafeModeManager = new SCMSafeModeManager(config, containers, null, pipelineManager, eventQueue, serviceManager, scmContext);
        HealthyPipelineSafeModeRule healthyPipelineSafeModeRule = scmSafeModeManager.getHealthyPipelineSafeModeRule();
        // This should be immediately satisfied, as no pipelines are there yet.
        Assert.assertTrue(healthyPipelineSafeModeRule.validate());
    } finally {
        scmMetadataStore.getStore().close();
        FileUtil.fullyDelete(new File(storageDir));
    }
}
Also used : ArrayList(java.util.ArrayList) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) MockRatisPipelineProvider(org.apache.hadoop.hdds.scm.pipeline.MockRatisPipelineProvider) PipelineProvider(org.apache.hadoop.hdds.scm.pipeline.PipelineProvider) EventQueue(org.apache.hadoop.hdds.server.events.EventQueue) MockNodeManager(org.apache.hadoop.hdds.scm.container.MockNodeManager) SCMContext(org.apache.hadoop.hdds.scm.ha.SCMContext) SCMMetadataStoreImpl(org.apache.hadoop.hdds.scm.metadata.SCMMetadataStoreImpl) PipelineManagerImpl(org.apache.hadoop.hdds.scm.pipeline.PipelineManagerImpl) MockRatisPipelineProvider(org.apache.hadoop.hdds.scm.pipeline.MockRatisPipelineProvider) SCMServiceManager(org.apache.hadoop.hdds.scm.ha.SCMServiceManager) ContainerInfo(org.apache.hadoop.hdds.scm.container.ContainerInfo) SCMMetadataStore(org.apache.hadoop.hdds.scm.metadata.SCMMetadataStore) File(java.io.File) Test(org.junit.Test)

Example 7 with PipelineManagerImpl

use of org.apache.hadoop.hdds.scm.pipeline.PipelineManagerImpl in project ozone by apache.

the class TestHealthyPipelineSafeModeRule method testHealthyPipelineSafeModeRuleWithPipelines.

@Test
public void testHealthyPipelineSafeModeRuleWithPipelines() throws Exception {
    String storageDir = GenericTestUtils.getTempPath(TestHealthyPipelineSafeModeRule.class.getName() + UUID.randomUUID());
    EventQueue eventQueue = new EventQueue();
    SCMServiceManager serviceManager = new SCMServiceManager();
    SCMContext scmContext = SCMContext.emptyContext();
    List<ContainerInfo> containers = new ArrayList<>(HddsTestUtils.getContainerInfo(1));
    OzoneConfiguration config = new OzoneConfiguration();
    // In Mock Node Manager, first 8 nodes are healthy, next 2 nodes are
    // stale and last one is dead, and this repeats. So for a 12 node, 9
    // healthy, 2 stale and one dead.
    MockNodeManager nodeManager = new MockNodeManager(true, 12);
    config.set(HddsConfigKeys.OZONE_METADATA_DIRS, storageDir);
    // enable pipeline check
    config.setBoolean(HddsConfigKeys.HDDS_SCM_SAFEMODE_PIPELINE_AVAILABILITY_CHECK, true);
    config.setBoolean(HddsConfigKeys.HDDS_SCM_SAFEMODE_PIPELINE_CREATION, false);
    SCMMetadataStore scmMetadataStore = new SCMMetadataStoreImpl(config);
    try {
        PipelineManagerImpl pipelineManager = PipelineManagerImpl.newPipelineManager(config, MockSCMHAManager.getInstance(true), nodeManager, scmMetadataStore.getPipelineTable(), eventQueue, scmContext, serviceManager);
        PipelineProvider mockRatisProvider = new MockRatisPipelineProvider(nodeManager, pipelineManager.getStateManager(), config);
        pipelineManager.setPipelineProvider(HddsProtos.ReplicationType.RATIS, mockRatisProvider);
        // Create 3 pipelines
        Pipeline pipeline1 = pipelineManager.createPipeline(RatisReplicationConfig.getInstance(ReplicationFactor.THREE));
        pipelineManager.openPipeline(pipeline1.getId());
        Pipeline pipeline2 = pipelineManager.createPipeline(RatisReplicationConfig.getInstance(ReplicationFactor.THREE));
        pipelineManager.openPipeline(pipeline2.getId());
        Pipeline pipeline3 = pipelineManager.createPipeline(RatisReplicationConfig.getInstance(ReplicationFactor.THREE));
        pipelineManager.openPipeline(pipeline3.getId());
        // Mark pipeline healthy
        pipeline1 = pipelineManager.getPipeline(pipeline1.getId());
        MockRatisPipelineProvider.markPipelineHealthy(pipeline1);
        pipeline2 = pipelineManager.getPipeline(pipeline2.getId());
        MockRatisPipelineProvider.markPipelineHealthy(pipeline2);
        pipeline3 = pipelineManager.getPipeline(pipeline3.getId());
        MockRatisPipelineProvider.markPipelineHealthy(pipeline3);
        SCMSafeModeManager scmSafeModeManager = new SCMSafeModeManager(config, containers, null, pipelineManager, eventQueue, serviceManager, scmContext);
        HealthyPipelineSafeModeRule healthyPipelineSafeModeRule = scmSafeModeManager.getHealthyPipelineSafeModeRule();
        // No datanodes have sent pipelinereport from datanode
        Assert.assertFalse(healthyPipelineSafeModeRule.validate());
        // Fire pipeline report from all datanodes in first pipeline, as here we
        // have 3 pipelines, 10% is 0.3, when doing ceil it is 1. So, we should
        // validate should return true after fire pipeline event
        // Here testing with out pipelinereport handler, so not moving created
        // pipelines to allocated state, as pipelines changing to healthy is
        // handled by pipeline report handler. So, leaving pipeline's in pipeline
        // manager in open state for test case simplicity.
        firePipelineEvent(pipeline1, eventQueue);
        GenericTestUtils.waitFor(() -> healthyPipelineSafeModeRule.validate(), 1000, 5000);
    } finally {
        scmMetadataStore.getStore().close();
        FileUtil.fullyDelete(new File(storageDir));
    }
}
Also used : ArrayList(java.util.ArrayList) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) MockRatisPipelineProvider(org.apache.hadoop.hdds.scm.pipeline.MockRatisPipelineProvider) PipelineProvider(org.apache.hadoop.hdds.scm.pipeline.PipelineProvider) EventQueue(org.apache.hadoop.hdds.server.events.EventQueue) MockNodeManager(org.apache.hadoop.hdds.scm.container.MockNodeManager) Pipeline(org.apache.hadoop.hdds.scm.pipeline.Pipeline) SCMContext(org.apache.hadoop.hdds.scm.ha.SCMContext) SCMMetadataStoreImpl(org.apache.hadoop.hdds.scm.metadata.SCMMetadataStoreImpl) PipelineManagerImpl(org.apache.hadoop.hdds.scm.pipeline.PipelineManagerImpl) MockRatisPipelineProvider(org.apache.hadoop.hdds.scm.pipeline.MockRatisPipelineProvider) SCMServiceManager(org.apache.hadoop.hdds.scm.ha.SCMServiceManager) ContainerInfo(org.apache.hadoop.hdds.scm.container.ContainerInfo) SCMMetadataStore(org.apache.hadoop.hdds.scm.metadata.SCMMetadataStore) File(java.io.File) Test(org.junit.Test)

Aggregations

PipelineManagerImpl (org.apache.hadoop.hdds.scm.pipeline.PipelineManagerImpl)7 MockNodeManager (org.apache.hadoop.hdds.scm.container.MockNodeManager)6 MockRatisPipelineProvider (org.apache.hadoop.hdds.scm.pipeline.MockRatisPipelineProvider)6 PipelineProvider (org.apache.hadoop.hdds.scm.pipeline.PipelineProvider)6 Pipeline (org.apache.hadoop.hdds.scm.pipeline.Pipeline)5 Test (org.junit.Test)5 File (java.io.File)4 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)4 ContainerInfo (org.apache.hadoop.hdds.scm.container.ContainerInfo)4 ArrayList (java.util.ArrayList)3 SCMContext (org.apache.hadoop.hdds.scm.ha.SCMContext)3 SCMServiceManager (org.apache.hadoop.hdds.scm.ha.SCMServiceManager)3 SCMMetadataStore (org.apache.hadoop.hdds.scm.metadata.SCMMetadataStore)3 SCMMetadataStoreImpl (org.apache.hadoop.hdds.scm.metadata.SCMMetadataStoreImpl)3 EventQueue (org.apache.hadoop.hdds.server.events.EventQueue)3 SCMException (org.apache.hadoop.hdds.scm.exceptions.SCMException)1 GenericTestUtils (org.apache.ozone.test.GenericTestUtils)1 Ignore (org.junit.Ignore)1