sadanand48 commented on code in PR #4661:
URL: https://github.com/apache/ozone/pull/4661#discussion_r1187155328


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ChunkKeyHandler.java:
##########
@@ -71,124 +72,130 @@ public class ChunkKeyHandler extends KeyHandler implements
   private XceiverClientSpi xceiverClient;
   private OzoneManagerProtocol ozoneManagerClient;
 
+  @CommandLine.ParentCommand
+  private OzoneDebug parent;
+
   private String getChunkLocationPath(String containerLocation) {
     return containerLocation + File.separator + OzoneConsts.STORAGE_DIR_CHUNKS;
   }
 
   @Override
   protected void execute(OzoneClient client, OzoneAddress address)
           throws IOException, OzoneClientException {
-    containerOperationClient = new
-            ContainerOperationClient(createOzoneConfiguration());
-    xceiverClientManager = containerOperationClient
-            .getXceiverClientManager();
-    ozoneManagerClient = client.getObjectStore().getClientProxy()
-            .getOzoneManagerClient();
-    address.ensureKeyAddress();
-    JsonElement element;
-    JsonObject result = new JsonObject();
-    String volumeName = address.getVolumeName();
-    String bucketName = address.getBucketName();
-    String keyName = address.getKeyName();
-    List<ContainerProtos.ChunkInfo> tempchunks = null;
-    List<ChunkDetails> chunkDetailsList = new ArrayList<ChunkDetails>();
-    HashSet<String> chunkPaths = new HashSet<>();
-    OmKeyArgs keyArgs = new OmKeyArgs.Builder()
-            .setVolumeName(volumeName)
-            .setBucketName(bucketName)
-            .setKeyName(keyName)
-            .build();
-    OmKeyInfo keyInfo = ozoneManagerClient.lookupKey(keyArgs);
-    // querying  the keyLocations.The OM is queried to get containerID and
-    // localID pertaining to a given key
-    List<OmKeyLocationInfo> locationInfos = keyInfo
-            .getLatestVersionLocations().getBlocksLatestVersionOnly();
-    // for zero-sized key
-    if (locationInfos.isEmpty()) {
-      System.out.println("No Key Locations Found");
-      return;
-    }
-    ContainerLayoutVersion containerLayoutVersion = ContainerLayoutVersion
-            .getConfiguredVersion(getConf());
-    JsonArray responseArrayList = new JsonArray();
-    for (OmKeyLocationInfo keyLocation:locationInfos) {
-      ContainerChunkInfo containerChunkInfoVerbose = new ContainerChunkInfo();
-      ContainerChunkInfo containerChunkInfo = new ContainerChunkInfo();
-      long containerId = keyLocation.getContainerID();
-      chunkPaths.clear();
-      Pipeline pipeline = keyLocation.getPipeline();
-      if (pipeline.getType() != HddsProtos.ReplicationType.STAND_ALONE) {
-        pipeline = Pipeline.newBuilder(pipeline)
-            .setReplicationConfig(StandaloneReplicationConfig.getInstance(ONE))
-            .build();
-      }
-      xceiverClient = xceiverClientManager
-              .acquireClientForReadData(pipeline);
-      // Datanode is queried to get chunk information.Thus querying the
-      // OM,SCM and datanode helps us get chunk location information
-      ContainerProtos.DatanodeBlockID datanodeBlockID = 
keyLocation.getBlockID()
-              .getDatanodeBlockIDProtobuf();
-      // doing a getBlock on all nodes
-      HashMap<DatanodeDetails, ContainerProtos.GetBlockResponseProto>
-              responses = null;
-      try {
-        responses = ContainerProtocolCalls.getBlockFromAllNodes(
-            xceiverClient, datanodeBlockID, keyLocation.getToken());
-      } catch (InterruptedException e) {
-        LOG.error("Execution interrupted due to " + e);
-        Thread.currentThread().interrupt();
+    try {
+      containerOperationClient = new ContainerOperationClient(
+          parent.getOzoneConf());

Review Comment:
   Done.



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