diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/replicas/chunk/ChunkKeyHandler.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/replicas/chunk/ChunkKeyHandler.java index 213187776563..91f5e87ca447 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/replicas/chunk/ChunkKeyHandler.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/replicas/chunk/ChunkKeyHandler.java @@ -190,9 +190,13 @@ protected void execute(OzoneClient client, OzoneAddress address) } if (isECKey) { - ChunkType blockChunksType = isECParityBlock(keyPipeline, entry.getKey()) ? - ChunkType.PARITY : ChunkType.DATA; - jsonObj.put("chunkType", blockChunksType.name()); + int replicaIndex = keyPipeline.getReplicaIndex(entry.getKey()); + int dataCount = ((ECReplicationConfig) keyPipeline.getReplicationConfig()).getData(); + // Index is 1-based, + // e.g. for RS-3-2 we will have data indexes 1,2,3 and parity indexes 4,5 + ChunkType chunkType = (replicaIndex > dataCount) ? ChunkType.PARITY : ChunkType.DATA; + jsonObj.put("chunkType", chunkType.name()); + jsonObj.put("ecIndex", replicaIndex); } } } catch (InterruptedException e) { @@ -205,11 +209,4 @@ protected void execute(OzoneClient client, OzoneAddress address) System.out.println(prettyJson); } } - - 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(); - } }