xiaoyuyao commented on a change in pull request #934: URL: https://github.com/apache/hadoop-ozone/pull/934#discussion_r428215546
########## 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) { Review comment: Should we continue closing the remaining when hit exception in the middle of the forEach and print out a list of pipeline closed successfully and unsuccessfully at the end? ---------------------------------------------------------------- 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