Tejaskriya commented on code in PR #8248:
URL: https://github.com/apache/ozone/pull/8248#discussion_r2071190466


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/replicas/Checksums.java:
##########


Review Comment:
   I think this was supposed to be deleted (ChecksumsVerifer is the 
replacement).



##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/replicas/BlockExistenceVerifier.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.debug.replicas;
+
+import static 
org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor.ONE;
+
+import java.io.IOException;
+import java.util.Collections;
+import org.apache.hadoop.hdds.client.StandaloneReplicationConfig;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.hdds.protocol.DatanodeDetails;
+import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos;
+import org.apache.hadoop.hdds.scm.XceiverClientManager;
+import org.apache.hadoop.hdds.scm.XceiverClientSpi;
+import org.apache.hadoop.hdds.scm.cli.ContainerOperationClient;
+import org.apache.hadoop.hdds.scm.pipeline.Pipeline;
+import org.apache.hadoop.hdds.scm.storage.ContainerProtocolCalls;
+import org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo;
+
+/**
+ * Verifies block existence by making getBlock calls to the datanode.
+ */
+public class BlockExistenceVerifier implements ReplicaVerifier {
+  private final ContainerOperationClient containerClient;
+  private final XceiverClientManager xceiverClientManager;
+  private static final String CHECK_TYPE = "blockExistence";
+
+  @Override
+  public String getType() {
+    return CHECK_TYPE;
+  }
+
+  public BlockExistenceVerifier(OzoneConfiguration conf) throws IOException {
+    this.containerClient = new ContainerOperationClient(conf);
+    this.xceiverClientManager = containerClient.getXceiverClientManager();
+  }
+
+  @Override
+  public BlockVerificationResult verifyBlock(DatanodeDetails datanode, 
OmKeyLocationInfo keyLocation,
+                                             int replicaIndex) {
+    try {
+      Pipeline pipeline = Pipeline.newBuilder(keyLocation.getPipeline())
+          .setReplicationConfig(StandaloneReplicationConfig.getInstance(ONE))
+          .setNodes(Collections.singletonList(datanode))
+          .setReplicaIndexes(Collections.singletonMap(datanode, replicaIndex))
+          .build();
+
+      XceiverClientSpi client = 
xceiverClientManager.acquireClientForReadData(pipeline);

Review Comment:
   It would be safer to close this client (in a finally block) after using 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.

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