Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
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;
Expand Down Expand Up @@ -67,7 +68,7 @@
public class ChunkKeyHandler extends KeyHandler implements
SubcommandWithParent {

private XceiverClientManager xceiverClientManager;
private XceiverClientManager xceiverClientManager;
private XceiverClientSpi xceiverClient;
private OzoneManagerProtocol ozoneManagerClient;

Expand Down Expand Up @@ -115,11 +116,17 @@ protected void execute(OzoneClient client, OzoneAddress address)
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
Expand Down Expand Up @@ -161,11 +168,17 @@ protected void execute(OzoneClient client, OzoneAddress address)
}
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);
Expand All @@ -192,6 +205,13 @@ protected void execute(OzoneClient client, OzoneAddress address)
}
}

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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -60,6 +61,9 @@ public void setChunkInfos(List<ChunkDetails> chunkInfos) {
this.chunkInfos = chunkInfos;
}

public void setChunkType(ChunkType chunkType) {
this.chunkType = chunkType;
}

@Override
public String toString() {
Expand All @@ -75,6 +79,8 @@ public String toString() {
+ "files="
+ files
+ "PipelineID="
+ pipelineID;
+ pipelineID
+ "ChunkType="
+ chunkType;
}
}