[GitHub] [hadoop-ozone] maobaolong commented on a change in pull request #934: HDDS-3605. Support close all pipelines.

2020-05-22 Thread GitBox


maobaolong commented on a change in pull request #934:
URL: https://github.com/apache/hadoop-ozone/pull/934#discussion_r429128650



##
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"},

Review comment:
   I've got some help from @timmylicheng 





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



[GitHub] [hadoop-ozone] maobaolong commented on a change in pull request #934: HDDS-3605. Support close all pipelines.

2020-05-22 Thread GitBox


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



[GitHub] [hadoop-ozone] maobaolong commented on a change in pull request #934: HDDS-3605. Support close all pipelines.

2020-05-21 Thread GitBox


maobaolong commented on a change in pull request #934:
URL: https://github.com/apache/hadoop-ozone/pull/934#discussion_r429032742



##
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"},

Review comment:
   Is there some examples for me to reference? I'd like to follow our test 
framework.





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