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);
}
}
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);
}
}
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);
}
}
Aggregations