Search in sources :

Example 1 with ReplicationType

use of org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationType in project ozone by apache.

the class TestPipelineStateManagerImpl method testGetPipelinesByTypeAndFactor.

@Test
public void testGetPipelinesByTypeAndFactor() throws IOException {
    Set<HddsProtos.Pipeline> pipelines = new HashSet<>();
    for (HddsProtos.ReplicationType type : new ReplicationType[] { ReplicationType.RATIS, ReplicationType.STAND_ALONE }) {
        for (HddsProtos.ReplicationFactor factor : HddsProtos.ReplicationFactor.values()) {
            for (int i = 0; i < 5; i++) {
                // 5 pipelines in allocated state for each type and factor
                HddsProtos.Pipeline pipeline = createDummyPipeline(type, factor, factor.getNumber()).getProtobufMessage(ClientVersions.CURRENT_VERSION);
                stateManager.addPipeline(pipeline);
                pipelines.add(pipeline);
                // 5 pipelines in open state for each type and factor
                pipeline = createDummyPipeline(type, factor, factor.getNumber()).getProtobufMessage(ClientVersions.CURRENT_VERSION);
                stateManager.addPipeline(pipeline);
                pipelines.add(pipeline);
                // 5 pipelines in closed state for each type and factor
                pipeline = createDummyPipeline(type, factor, factor.getNumber()).getProtobufMessage(ClientVersions.CURRENT_VERSION);
                stateManager.addPipeline(pipeline);
                pipelines.add(pipeline);
            }
        }
    }
    for (HddsProtos.ReplicationType type : new ReplicationType[] { ReplicationType.RATIS, ReplicationType.STAND_ALONE }) {
        for (HddsProtos.ReplicationFactor factor : HddsProtos.ReplicationFactor.values()) {
            // verify pipelines received
            List<Pipeline> pipelines1 = stateManager.getPipelines(ReplicationConfig.fromProtoTypeAndFactor(type, factor));
            Assert.assertEquals(15, pipelines1.size());
            pipelines1.stream().forEach(p -> {
                Assert.assertEquals(type, p.getType());
            });
        }
    }
    // clean up
    for (HddsProtos.Pipeline pipeline : pipelines) {
        finalizePipeline(pipeline);
        removePipeline(pipeline);
    }
}
Also used : ReplicationType(org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationType) HddsProtos(org.apache.hadoop.hdds.protocol.proto.HddsProtos) ReplicationFactor(org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor) ReplicationType(org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationType) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with ReplicationType

use of org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationType in project ozone by apache.

the class TestPipelineStateManagerImpl method testGetPipelinesByTypeFactorAndState.

@Test
public void testGetPipelinesByTypeFactorAndState() throws IOException {
    Set<HddsProtos.Pipeline> pipelines = new HashSet<>();
    for (HddsProtos.ReplicationType type : new ReplicationType[] { ReplicationType.RATIS, ReplicationType.STAND_ALONE }) {
        for (HddsProtos.ReplicationFactor factor : HddsProtos.ReplicationFactor.values()) {
            for (int i = 0; i < 5; i++) {
                // 5 pipelines in allocated state for each type and factor
                HddsProtos.Pipeline pipeline = createDummyPipeline(type, factor, factor.getNumber()).getProtobufMessage(ClientVersions.CURRENT_VERSION);
                stateManager.addPipeline(pipeline);
                pipelines.add(pipeline);
                // 5 pipelines in open state for each type and factor
                pipeline = createDummyPipeline(type, factor, factor.getNumber()).getProtobufMessage(ClientVersions.CURRENT_VERSION);
                stateManager.addPipeline(pipeline);
                openPipeline(pipeline);
                pipelines.add(pipeline);
                // 5 pipelines in dormant state for each type and factor
                pipeline = createDummyPipeline(type, factor, factor.getNumber()).getProtobufMessage(ClientVersions.CURRENT_VERSION);
                stateManager.addPipeline(pipeline);
                openPipeline(pipeline);
                deactivatePipeline(pipeline);
                pipelines.add(pipeline);
                // 5 pipelines in closed state for each type and factor
                pipeline = createDummyPipeline(type, factor, factor.getNumber()).getProtobufMessage(ClientVersions.CURRENT_VERSION);
                stateManager.addPipeline(pipeline);
                finalizePipeline(pipeline);
                pipelines.add(pipeline);
            }
        }
    }
    for (HddsProtos.ReplicationType type : new HddsProtos.ReplicationType[] { ReplicationType.RATIS, ReplicationType.STAND_ALONE }) {
        for (HddsProtos.ReplicationFactor factor : HddsProtos.ReplicationFactor.values()) {
            for (Pipeline.PipelineState state : Pipeline.PipelineState.values()) {
                // verify pipelines received
                List<Pipeline> pipelines1 = stateManager.getPipelines(ReplicationConfig.fromProtoTypeAndFactor(type, factor), state);
                Assert.assertEquals(5, pipelines1.size());
                pipelines1.forEach(p -> {
                    Assert.assertEquals(type, p.getType());
                    Assert.assertEquals(state, p.getPipelineState());
                });
            }
        }
    }
    // clean up
    for (HddsProtos.Pipeline pipeline : pipelines) {
        finalizePipeline(pipeline);
        removePipeline(pipeline);
    }
}
Also used : ReplicationType(org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationType) HddsProtos(org.apache.hadoop.hdds.protocol.proto.HddsProtos) ReplicationFactor(org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor) ReplicationType(org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationType) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with ReplicationType

use of org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationType in project ozone by apache.

the class TestReconPipelineManager method testStubbedReconPipelineFactory.

@Test
public void testStubbedReconPipelineFactory() throws IOException {
    NodeManager nodeManagerMock = mock(NodeManager.class);
    ReconPipelineManager reconPipelineManager = ReconPipelineManager.newReconPipelineManager(conf, nodeManagerMock, ReconSCMDBDefinition.PIPELINES.getTable(store), new EventQueue(), scmhaManager, scmContext);
    PipelineFactory pipelineFactory = reconPipelineManager.getPipelineFactory();
    assertTrue(pipelineFactory instanceof ReconPipelineFactory);
    ReconPipelineFactory reconPipelineFactory = (ReconPipelineFactory) pipelineFactory;
    assertTrue(reconPipelineFactory.getProviders().isEmpty());
    for (ReplicationType type : reconPipelineFactory.getProviders().keySet()) {
        PipelineProvider pipelineProvider = reconPipelineFactory.getProviders().get(type);
        assertTrue(pipelineProvider instanceof ReconPipelineProvider);
    }
}
Also used : NodeManager(org.apache.hadoop.hdds.scm.node.NodeManager) SCMNodeManager(org.apache.hadoop.hdds.scm.node.SCMNodeManager) ReplicationType(org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationType) PipelineFactory(org.apache.hadoop.hdds.scm.pipeline.PipelineFactory) ReconPipelineProvider(org.apache.hadoop.ozone.recon.scm.ReconPipelineFactory.ReconPipelineProvider) ReconPipelineProvider(org.apache.hadoop.ozone.recon.scm.ReconPipelineFactory.ReconPipelineProvider) PipelineProvider(org.apache.hadoop.hdds.scm.pipeline.PipelineProvider) EventQueue(org.apache.hadoop.hdds.server.events.EventQueue) Test(org.junit.Test)

Aggregations

ReplicationType (org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationType)3 Test (org.junit.Test)3 HashSet (java.util.HashSet)2 HddsProtos (org.apache.hadoop.hdds.protocol.proto.HddsProtos)2 ReplicationFactor (org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor)2 NodeManager (org.apache.hadoop.hdds.scm.node.NodeManager)1 SCMNodeManager (org.apache.hadoop.hdds.scm.node.SCMNodeManager)1 PipelineFactory (org.apache.hadoop.hdds.scm.pipeline.PipelineFactory)1 PipelineProvider (org.apache.hadoop.hdds.scm.pipeline.PipelineProvider)1 EventQueue (org.apache.hadoop.hdds.server.events.EventQueue)1 ReconPipelineProvider (org.apache.hadoop.ozone.recon.scm.ReconPipelineFactory.ReconPipelineProvider)1