kaijchen commented on code in PR #3410:
URL: https://github.com/apache/ozone/pull/3410#discussion_r872165629
##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/storage/ContainerProtocolCalls.java:
##########
@@ -73,6 +75,50 @@ public final class ContainerProtocolCalls {
private ContainerProtocolCalls() {
}
+ /**
+ * Calls the container protocol to list blocks in container.
+ *
+ * @param xceiverClient client to perform call
+ * @param containerID the ID of the container to list block
+ * @param replicaIndex the index of the replica in pipeline
+ * @param startLocalID the localID of the first block to get
+ * @param count max number of blocks to get
+ * @param token a token for this block (may be null)
+ * @return container protocol list block response
+ * @throws IOException if there is an I/O error while performing the call
+ */
+ public static ListBlockResponseProto listBlock(XceiverClientSpi
xceiverClient,
+ long containerID, int replicaIndex, Long startLocalID, int count,
+ Token<? extends TokenIdentifier> token) throws IOException {
+
+ ListBlockRequestProto.Builder listBlockBuilder =
+ ListBlockRequestProto.newBuilder()
+ .setCount(count);
+
+ if (startLocalID != null) {
+ listBlockBuilder.setStartLocalID(startLocalID);
+ }
+
+ String datanodeID = xceiverClient.getPipeline().getNodesInOrder()
+ .get(replicaIndex).getUuidString();
+
+ ContainerCommandRequestProto.Builder builder =
+ ContainerCommandRequestProto.newBuilder()
+ .setCmdType(Type.ListBlock)
+ .setContainerID(containerID)
+ .setDatanodeUuid(datanodeID)
+ .setListBlock(listBlockBuilder.build());
+
+ if (token != null) {
+ builder.setEncodedToken(token.encodeToUrlString());
+ }
+
+ ContainerCommandRequestProto request = builder.build();
+ ContainerCommandResponseProto response =
+ xceiverClient.sendCommand(request, getValidatorList());
Review Comment:
We may need to call `xceiverClient#sendCommandOnAllNodes` here because of
the `sendCommand` node picking strategy. What do you think @umamaheswararao?
https://github.com/apache/ozone/blob/96669856ad44a7571b1dd4267f28f37055b9e4b1/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientGrpc.java#L457-L458
https://github.com/apache/ozone/blob/96669856ad44a7571b1dd4267f28f37055b9e4b1/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientGrpc.java#L141-L142
https://github.com/apache/ozone/blob/96669856ad44a7571b1dd4267f28f37055b9e4b1/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientGrpc.java#L154-L155
##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/storage/ContainerProtocolCalls.java:
##########
@@ -73,6 +75,50 @@ public final class ContainerProtocolCalls {
private ContainerProtocolCalls() {
}
+ /**
+ * Calls the container protocol to list blocks in container.
+ *
+ * @param xceiverClient client to perform call
+ * @param containerID the ID of the container to list block
+ * @param replicaIndex the index of the replica in pipeline
+ * @param startLocalID the localID of the first block to get
+ * @param count max number of blocks to get
+ * @param token a token for this block (may be null)
+ * @return container protocol list block response
+ * @throws IOException if there is an I/O error while performing the call
+ */
+ public static ListBlockResponseProto listBlock(XceiverClientSpi
xceiverClient,
+ long containerID, int replicaIndex, Long startLocalID, int count,
+ Token<? extends TokenIdentifier> token) throws IOException {
+
+ ListBlockRequestProto.Builder listBlockBuilder =
+ ListBlockRequestProto.newBuilder()
+ .setCount(count);
+
+ if (startLocalID != null) {
+ listBlockBuilder.setStartLocalID(startLocalID);
+ }
+
+ String datanodeID = xceiverClient.getPipeline().getNodesInOrder()
+ .get(replicaIndex).getUuidString();
+
+ ContainerCommandRequestProto.Builder builder =
+ ContainerCommandRequestProto.newBuilder()
+ .setCmdType(Type.ListBlock)
+ .setContainerID(containerID)
+ .setDatanodeUuid(datanodeID)
+ .setListBlock(listBlockBuilder.build());
+
+ if (token != null) {
+ builder.setEncodedToken(token.encodeToUrlString());
+ }
+
+ ContainerCommandRequestProto request = builder.build();
+ ContainerCommandResponseProto response =
+ xceiverClient.sendCommand(request, getValidatorList());
Review Comment:
We may need to call `xceiverClient#sendCommandOnAllNodes` here because of
the `sendCommand` node picking strategy. What do you think @umamaheswararao?
https://github.com/apache/ozone/blob/96669856ad44a7571b1dd4267f28f37055b9e4b1/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientGrpc.java#L457-L458
https://github.com/apache/ozone/blob/96669856ad44a7571b1dd4267f28f37055b9e4b1/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientGrpc.java#L141-L142
https://github.com/apache/ozone/blob/96669856ad44a7571b1dd4267f28f37055b9e4b1/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientGrpc.java#L154-L155
--
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]