DaveTeng0 commented on code in PR #6497:
URL: https://github.com/apache/ozone/pull/6497#discussion_r1588265986


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java:
##########
@@ -462,29 +465,47 @@ public List<ContainerInfo> listContainer(long 
startContainerID,
       final ContainerID containerId = ContainerID.valueOf(startContainerID);
       if (state != null) {
         if (factor != null) {
-          return scm.getContainerManager().getContainers(state).stream()
-              .filter(info -> info.containerID().getId() >= startContainerID)
-              //Filtering EC replication type as EC will not have factor.
-              .filter(info -> info
-                  .getReplicationType() != HddsProtos.ReplicationType.EC)
-              .filter(info -> (info.getReplicationFactor() == factor))
-              .sorted().limit(count).collect(Collectors.toList());
+          Stream<ContainerInfo> containerInfoStream =
+              scm.getContainerManager().getContainers(state).stream()
+                .filter(info -> info.containerID().getId() >= startContainerID)
+                //Filtering EC replication type as EC will not have factor.
+                .filter(info -> info
+                    .getReplicationType() != HddsProtos.ReplicationType.EC)
+                .filter(info -> (info.getReplicationFactor() == factor))
+                .sorted();
+          List<ContainerInfo> containerInfos = containerInfoStream.collect(
+              Collectors.toList());
+          return 
Pair.of(containerInfos.stream().limit(count).collect(Collectors.toList()),

Review Comment:
   yeah! refactored two listContainer methods, to make them reuse common code 
as much as possible.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to