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 @@ -27,6 +27,7 @@
import java.util.function.Consumer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;

import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.scm.pipeline.Pipeline;
Expand Down Expand Up @@ -345,19 +346,24 @@ public StorageContainerLocationProtocol createStorageContainerLocationClient(
return HAUtils.getScmContainerClient(ozoneConf);
}

@SuppressWarnings("java:S3864") // Stream.peek (for debug)
public static Pipeline findPipelineForTest(String pipelineId,
StorageContainerLocationProtocol client, Logger log) throws IOException {
List<Pipeline> pipelines = client.listPipelines();
Stream<Pipeline> pipelines = client.listPipelines().stream();
Pipeline pipeline;
if (log.isDebugEnabled()) {
pipelines = pipelines
.peek(p -> log.debug("Found pipeline {}", p.getId().getId()));
}
if (pipelineId != null && pipelineId.length() > 0) {
pipeline = pipelines.stream()
pipeline = pipelines
.filter(p -> p.getId().toString().equals(pipelineId))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException(
"Pipeline ID is defined, but there is no such pipeline: "
+ pipelineId));
} else {
pipeline = pipelines.stream()
pipeline = pipelines
.filter(p -> p.getReplicationConfig().getRequiredNodes() == 3)
.findFirst()
.orElseThrow(() -> new IllegalArgumentException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@

import java.io.IOException;
import java.util.concurrent.Callable;
import java.util.stream.Stream;

import org.apache.hadoop.hdds.cli.HddsVersionProvider;
import org.apache.hadoop.hdds.client.ReplicationConfig;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos;
import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandRequestProto;
import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandResponseProto;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
import org.apache.hadoop.hdds.scm.XceiverClientManager;
import org.apache.hadoop.hdds.scm.XceiverClientSpi;
import org.apache.hadoop.hdds.scm.pipeline.Pipeline;
Expand Down Expand Up @@ -79,7 +76,6 @@ public class DatanodeChunkValidator extends BaseFreonGenerator


@Override
@SuppressWarnings("java:S3864") // Stream.peek (for debug)
public Void call() throws Exception {

init();
Expand All @@ -91,33 +87,9 @@ public Void call() throws Exception {
);
}

try (StorageContainerLocationProtocol scmLocationClient =
try (StorageContainerLocationProtocol scmClient =
createStorageContainerLocationClient(ozoneConf)) {
Stream<Pipeline> pipelines = scmLocationClient.listPipelines().stream();
if (LOG.isDebugEnabled()) {
pipelines = pipelines
.peek(p -> LOG.debug("Found pipeline {}", p.getId()));
}
Pipeline pipeline;
if (pipelineId != null && pipelineId.length() > 0) {
pipeline = pipelines
.filter(p -> p.getId().getId().toString().equals(pipelineId))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException(
"Pipeline ID is defined, but there is no such pipeline: "
+ pipelineId));

} else {
pipeline = pipelines
.filter(
p -> ReplicationConfig.getLegacyFactor(p.getReplicationConfig())
== HddsProtos.ReplicationFactor.THREE)
.findFirst()
.orElseThrow(() -> new IllegalArgumentException(
"Pipeline ID is NOT defined, and no pipeline " +
"has been found with factor=THREE"));
LOG.info("Using pipeline {}", pipeline.getId());
}
Pipeline pipeline = findPipelineForTest(pipelineId, scmClient, LOG);

try (XceiverClientManager xceiverClientManager =
new XceiverClientManager(ozoneConf)) {
Expand Down