maobaolong commented on a change in pull request #934: URL: https://github.com/apache/hadoop-ozone/pull/934#discussion_r429128112
########## File path: hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/pipeline/ClosePipelineSubcommand.java ########## @@ -38,14 +40,59 @@ @CommandLine.ParentCommand private PipelineCommands parent; - @CommandLine.Parameters(description = "ID of the pipeline to close") + @CommandLine.Parameters(description = "ID of the pipeline to close," + + "'ALL' means all pipeline") private String pipelineId; + @CommandLine.Option(names = {"-ffc", "--filterByFactor"}, + description = "Filter listed pipelines by Factor(ONE/one)", + defaultValue = "", + required = false) + private String factor; + + @CommandLine.Option(names = {"-fst", "--filterByState"}, + description = "Filter listed pipelines by State(OPEN/CLOSE)", + defaultValue = "", + required = false) + private String state; + @Override public Void call() throws Exception { try (ScmClient scmClient = parent.getParent().createScmClient()) { - scmClient.closePipeline( - HddsProtos.PipelineID.newBuilder().setId(pipelineId).build()); + if (pipelineId.equalsIgnoreCase("ALL")) { + if (Strings.isNullOrEmpty(factor) && Strings.isNullOrEmpty(state)) { + scmClient.listPipelines().forEach(pipeline -> { + try { + scmClient.closePipeline( + HddsProtos.PipelineID.newBuilder() + .setId(pipeline.getId().getId().toString()).build()); + } catch (IOException e) { + throw new IllegalStateException( + "met a exception while closePipeline", e); + } + }); + } else { + scmClient.listPipelines().stream() + .filter(p -> ((Strings.isNullOrEmpty(factor) || Review comment: Yeah, thank you for point it, the first condition is redundancy, remove it. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: ozone-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org