This is an automated email from the ASF dual-hosted git repository. sammichen pushed a commit to branch ozone-0.6.0 in repository https://gitbox.apache.org/repos/asf/hadoop-ozone.git
commit 9709b26ea96cfd0eecbf4419f18e58d72e0edc06 Author: hemanthboyina <[email protected]> AuthorDate: Thu Jul 9 21:45:01 2020 +0530 HDDS-3747. Redundancy if condition code in ListPipelinesSubcommand (#1051) (cherry picked from commit d85c7e334c568a9df571b7b779d119a0a1566751) --- .../scm/cli/pipeline/ListPipelinesSubcommand.java | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/pipeline/ListPipelinesSubcommand.java b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/pipeline/ListPipelinesSubcommand.java index f8ac1d4..729daea 100644 --- a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/pipeline/ListPipelinesSubcommand.java +++ b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/pipeline/ListPipelinesSubcommand.java @@ -21,9 +21,11 @@ package org.apache.hadoop.hdds.scm.cli.pipeline; import com.google.common.base.Strings; import org.apache.hadoop.hdds.cli.HddsVersionProvider; import org.apache.hadoop.hdds.scm.client.ScmClient; +import org.apache.hadoop.hdds.scm.pipeline.Pipeline; import picocli.CommandLine; import java.util.concurrent.Callable; +import java.util.stream.Stream; /** * Handler of list pipelines command. @@ -54,17 +56,16 @@ public class ListPipelinesSubcommand implements Callable<Void> { @Override public Void call() throws Exception { try (ScmClient scmClient = parent.getParent().createScmClient()) { - if (Strings.isNullOrEmpty(factor) && Strings.isNullOrEmpty(state)) { - scmClient.listPipelines().forEach(System.out::println); - } else { - scmClient.listPipelines().stream() - .filter(p -> ((Strings.isNullOrEmpty(factor) || - (p.getFactor().toString().compareToIgnoreCase(factor) == 0)) - && (Strings.isNullOrEmpty(state) || - (p.getPipelineState().toString().compareToIgnoreCase(state) - == 0)))) - .forEach(System.out::println); + Stream<Pipeline> stream = scmClient.listPipelines().stream(); + if (!Strings.isNullOrEmpty(factor)) { + stream = stream.filter( + p -> p.getFactor().toString().compareToIgnoreCase(factor) == 0); } + if (!Strings.isNullOrEmpty(state)) { + stream = stream.filter(p -> p.getPipelineState().toString() + .compareToIgnoreCase(state) == 0); + } + stream.forEach(System.out::println); return null; } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
