use of org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.GetBlockResponseProto in project ozone by apache.
the class ContainerProtocolCalls method getBlockFromAllNodes.
public static HashMap<DatanodeDetails, GetBlockResponseProto> getBlockFromAllNodes(XceiverClientSpi xceiverClient, DatanodeBlockID datanodeBlockID, Token<OzoneBlockTokenIdentifier> token) throws IOException, InterruptedException {
GetBlockRequestProto.Builder readBlockRequest = GetBlockRequestProto.newBuilder().setBlockID(datanodeBlockID);
HashMap<DatanodeDetails, GetBlockResponseProto> datanodeToResponseMap = new HashMap<>();
String id = xceiverClient.getPipeline().getFirstNode().getUuidString();
ContainerCommandRequestProto.Builder builder = ContainerCommandRequestProto.newBuilder().setCmdType(Type.GetBlock).setContainerID(datanodeBlockID.getContainerID()).setDatanodeUuid(id).setGetBlock(readBlockRequest);
if (token != null) {
builder.setEncodedToken(token.encodeToUrlString());
}
ContainerCommandRequestProto request = builder.build();
Map<DatanodeDetails, ContainerCommandResponseProto> responses = xceiverClient.sendCommandOnAllNodes(request);
for (Map.Entry<DatanodeDetails, ContainerCommandResponseProto> entry : responses.entrySet()) {
datanodeToResponseMap.put(entry.getKey(), entry.getValue().getGetBlock());
}
return datanodeToResponseMap;
}
use of org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.GetBlockResponseProto in project ozone by apache.
the class BlockInputStream method getChunkInfos.
/**
* Send RPC call to get the block info from the container.
* @return List of chunks in this block.
*/
protected List<ChunkInfo> getChunkInfos() throws IOException {
// protocol.
if (pipeline.getType() != HddsProtos.ReplicationType.STAND_ALONE) {
pipeline = Pipeline.newBuilder(pipeline).setReplicationConfig(StandaloneReplicationConfig.getInstance(ReplicationConfig.getLegacyFactor(pipeline.getReplicationConfig()))).build();
}
acquireClient();
boolean success = false;
List<ChunkInfo> chunks;
try {
if (LOG.isDebugEnabled()) {
LOG.debug("Initializing BlockInputStream for get key to access {}", blockID.getContainerID());
}
DatanodeBlockID datanodeBlockID = blockID.getDatanodeBlockIDProtobuf();
GetBlockResponseProto response = ContainerProtocolCalls.getBlock(xceiverClient, datanodeBlockID, token);
chunks = response.getBlockData().getChunksList();
success = true;
} finally {
if (!success) {
xceiverClientFactory.releaseClientForReadData(xceiverClient, false);
}
}
return chunks;
}
Aggregations