Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package org.apache.hadoop.hdds.scm.pipeline;

import org.apache.commons.collections.iterators.LoopingIterator;
import org.apache.hadoop.hdds.conf.ConfigurationSource;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
import org.apache.hadoop.hdds.scm.ScmConfigKeys;
Expand All @@ -26,6 +27,8 @@
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
Expand Down Expand Up @@ -109,35 +112,43 @@ private void createPipelines() {
ScmConfigKeys.OZONE_SCM_PIPELINE_AUTO_CREATE_FACTOR_ONE,
ScmConfigKeys.OZONE_SCM_PIPELINE_AUTO_CREATE_FACTOR_ONE_DEFAULT);

List<HddsProtos.ReplicationFactor> list =
new ArrayList<>();
for (HddsProtos.ReplicationFactor factor : HddsProtos.ReplicationFactor
.values()) {
if (skipCreation(factor, type, autoCreateFactorOne)) {
// Skip this iteration for creating pipeline
continue;
}

list.add(factor);
if (!pipelineManager.getSafeModeStatus()) {
try {
pipelineManager.scrubPipeline(type, factor);
} catch (IOException e) {
LOG.error("Error while scrubbing pipelines {}", e);
}
}
}

while (true) {
try {
if (scheduler.isClosed()) {
break;
}
pipelineManager.createPipeline(type, factor);
} catch (IOException ioe) {
break;
} catch (Throwable t) {
LOG.error("Error while creating pipelines", t);
LoopingIterator it = new LoopingIterator(list);
while (it.hasNext()) {
HddsProtos.ReplicationFactor factor =
(HddsProtos.ReplicationFactor) it.next();

try {
if (scheduler.isClosed()) {
break;
}
pipelineManager.createPipeline(type, factor);
} catch (IOException ioe) {
it.remove();
} catch (Throwable t) {
LOG.error("Error while creating pipelines", t);
it.remove();
}
}

isPipelineCreatorRunning.set(false);
LOG.debug("BackgroundPipelineCreator createPipelines finished.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.hadoop.hdds.scm.node;

import static org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor.THREE;
import static org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor.ONE;
import static org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationType.RATIS;

import java.io.File;
Expand Down Expand Up @@ -162,7 +163,9 @@ public void testOnMessage() throws Exception {
LambdaTestUtils.await(120000, 1000,
() -> {
pipelineManager.triggerPipelineCreation();
return pipelineManager.getPipelines(RATIS, THREE).size() == 3;
System.out.println(pipelineManager.getPipelines(RATIS, THREE).size());
System.out.println(pipelineManager.getPipelines(RATIS, ONE).size());
return pipelineManager.getPipelines(RATIS, THREE).size() > 3;
});
TestUtils.openAllRatisPipelines(pipelineManager);

Expand Down