This is an automated email from the ASF dual-hosted git repository.

adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 7bda567a45 HDDS-8615. Explicitly show EC block type in 'ozone debug 
chunkinfo' command output (#4706)
7bda567a45 is described below

commit 7bda567a45c0ae552d052ecb4af83e78f7072585
Author: Cyrill <[email protected]>
AuthorDate: Mon May 15 15:35:30 2023 +0300

    HDDS-8615. Explicitly show EC block type in 'ozone debug chunkinfo' command 
output (#4706)
---
 .../apache/hadoop/ozone/debug/ChunkKeyHandler.java | 34 +++++++++++++++++-----
 .../org/apache/hadoop/ozone/debug/ChunkType.java   | 24 +++++++++++++++
 .../hadoop/ozone/debug/ContainerChunkInfo.java     |  8 ++++-
 3 files changed, 58 insertions(+), 8 deletions(-)

diff --git 
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ChunkKeyHandler.java
 
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ChunkKeyHandler.java
index 38845eb81e..21bd114551 100644
--- 
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ChunkKeyHandler.java
+++ 
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ChunkKeyHandler.java
@@ -31,6 +31,7 @@ import com.google.gson.JsonObject;
 import com.google.gson.JsonArray;
 import com.google.gson.JsonElement;
 import org.apache.hadoop.hdds.cli.SubcommandWithParent;
+import org.apache.hadoop.hdds.client.ECReplicationConfig;
 import org.apache.hadoop.hdds.client.StandaloneReplicationConfig;
 import org.apache.hadoop.hdds.protocol.DatanodeDetails;
 import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos;
@@ -67,7 +68,7 @@ import static 
org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor
 public class ChunkKeyHandler extends KeyHandler implements
     SubcommandWithParent {
 
-  private  XceiverClientManager xceiverClientManager;
+  private XceiverClientManager xceiverClientManager;
   private XceiverClientSpi xceiverClient;
   private OzoneManagerProtocol ozoneManagerClient;
 
@@ -115,11 +116,17 @@ public class ChunkKeyHandler extends KeyHandler implements
         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)
+        Pipeline keyPipeline = keyLocation.getPipeline();
+        boolean isECKey =
+            keyPipeline.getReplicationConfig().getReplicationType() ==
+                HddsProtos.ReplicationType.EC;
+        Pipeline pipeline;
+        if (keyPipeline.getType() != HddsProtos.ReplicationType.STAND_ALONE) {
+          pipeline = Pipeline.newBuilder(keyPipeline)
               .setReplicationConfig(StandaloneReplicationConfig
                   .getInstance(ONE)).build();
+        } else {
+          pipeline = keyPipeline;
         }
         xceiverClient = 
xceiverClientManager.acquireClientForReadData(pipeline);
         // Datanode is queried to get chunk information.Thus querying the
@@ -161,11 +168,17 @@ public class ChunkKeyHandler extends KeyHandler implements
           }
           containerChunkInfoVerbose.setContainerPath(containerData
               .getContainerPath());
-          containerChunkInfoVerbose.setPipeline(keyLocation.getPipeline());
+          containerChunkInfoVerbose.setPipeline(keyPipeline);
           containerChunkInfoVerbose.setChunkInfos(chunkDetailsList);
           containerChunkInfo.setFiles(chunkPaths);
-          containerChunkInfo.setPipelineID(
-              keyLocation.getPipeline().getId().getId());
+          containerChunkInfo.setPipelineID(keyPipeline.getId().getId());
+          if (isECKey) {
+            ChunkType blockChunksType =
+                isECParityBlock(keyPipeline, entry.getKey()) ?
+                    ChunkType.PARITY : ChunkType.DATA;
+            containerChunkInfoVerbose.setChunkType(blockChunksType);
+            containerChunkInfo.setChunkType(blockChunksType);
+          }
           Gson gson = new GsonBuilder().create();
           if (isVerbose()) {
             element = gson.toJsonTree(containerChunkInfoVerbose);
@@ -192,6 +205,13 @@ public class ChunkKeyHandler extends KeyHandler implements
     }
   }
 
+  private boolean isECParityBlock(Pipeline pipeline, DatanodeDetails dn) {
+    //index is 1-based,
+    //e.g. for RS-3-2 we will have data indexes 1,2,3 and parity indexes 4,5
+    return pipeline.getReplicaIndex(dn) >
+        ((ECReplicationConfig) pipeline.getReplicationConfig()).getData();
+  }
+
   @Override
   public Class<?> getParentType() {
     return OzoneDebug.class;
diff --git 
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ChunkType.java 
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ChunkType.java
new file mode 100644
index 0000000000..610eab54d6
--- /dev/null
+++ 
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ChunkType.java
@@ -0,0 +1,24 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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;
+
+/**
+ * The type of chunks of an Erasure Coded key.
+ */
+public enum ChunkType {
+  DATA, PARITY
+}
diff --git 
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ContainerChunkInfo.java
 
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ContainerChunkInfo.java
index cf57d95397..f88e08413d 100644
--- 
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ContainerChunkInfo.java
+++ 
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ContainerChunkInfo.java
@@ -35,6 +35,7 @@ public class ContainerChunkInfo {
   private HashSet<String> files;
   private UUID pipelineID;
   private Pipeline pipeline;
+  private ChunkType chunkType;
 
   public void setFiles(HashSet<String> files) {
     this.files = files;
@@ -60,6 +61,9 @@ public class ContainerChunkInfo {
     this.chunkInfos = chunkInfos;
   }
 
+  public void setChunkType(ChunkType chunkType) {
+    this.chunkType = chunkType;
+  }
 
   @Override
   public String toString() {
@@ -75,6 +79,8 @@ public class ContainerChunkInfo {
             + "files="
             + files
             + "PipelineID="
-            + pipelineID;
+            + pipelineID
+            + "ChunkType="
+            + chunkType;
   }
 }


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

Reply via email to