nandakumar131 commented on a change in pull request #692: HDDS-3168. Improve
read efficiency by merging a lot of RPC call getContainerWithPipeline into one
URL: https://github.com/apache/hadoop-ozone/pull/692#discussion_r395261613
##########
File path:
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java
##########
@@ -275,6 +275,66 @@ public ContainerWithPipeline
getContainerWithPipeline(long containerID)
}
}
+ @Override
+ public List<ContainerWithPipeline> getContainerWithPipelineBatch(
+ List<Long> containerIDs) throws IOException {
+ getScm().checkAdminAccess(null);
+
+ List<ContainerWithPipeline> cpList = new ArrayList<>();
+
+ for (Long containerID : containerIDs) {
+ final ContainerID cid = ContainerID.valueof(containerID);
+ try {
+ final ContainerInfo container = scm.getContainerManager()
+ .getContainer(cid);
+
+ if (safeModePrecheck.isInSafeMode()) {
+ if (container.isOpen()) {
+ if (!hasRequiredReplicas(container)) {
+ throw new SCMException("Open container " + containerID
+ + " doesn't have enough replicas to service this"
+ + " operation in Safe mode.",
+ ResultCodes.SAFE_MODE_EXCEPTION);
+ }
+ }
+ }
+
+ Pipeline pipeline;
+ try {
+ pipeline = container.isOpen() ? scm.getPipelineManager()
+ .getPipeline(container.getPipelineID()) : null;
+ } catch (PipelineNotFoundException ex) {
+ // The pipeline is destroyed.
+ pipeline = null;
+ }
+
+ if (pipeline == null) {
+ pipeline = scm.getPipelineManager().createPipeline(
+ HddsProtos.ReplicationType.STAND_ALONE,
+ container.getReplicationFactor(),
+ scm.getContainerManager()
+ .getContainerReplicas(cid).stream()
+ .map(ContainerReplica::getDatanodeDetails)
+ .collect(Collectors.toList()));
+ }
Review comment:
This logic can be extracted into a separate method and can be reused by
`getContainerWithPipeline` and `getContainerWithPipelineBatch`
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]