Search in sources :

Example 1 with GetBlockResponseProto

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;
}
Also used : HashMap(java.util.HashMap) GetBlockRequestProto(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.GetBlockRequestProto) ByteString(org.apache.ratis.thirdparty.com.google.protobuf.ByteString) ContainerCommandResponseProto(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandResponseProto) DatanodeDetails(org.apache.hadoop.hdds.protocol.DatanodeDetails) GetBlockResponseProto(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.GetBlockResponseProto) ContainerCommandRequestProto(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandRequestProto) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with GetBlockResponseProto

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;
}
Also used : ChunkInfo(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ChunkInfo) GetBlockResponseProto(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.GetBlockResponseProto) DatanodeBlockID(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.DatanodeBlockID)

Aggregations

GetBlockResponseProto (org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.GetBlockResponseProto)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 DatanodeDetails (org.apache.hadoop.hdds.protocol.DatanodeDetails)1 ChunkInfo (org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ChunkInfo)1 ContainerCommandRequestProto (org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandRequestProto)1 ContainerCommandResponseProto (org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandResponseProto)1 DatanodeBlockID (org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.DatanodeBlockID)1 GetBlockRequestProto (org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.GetBlockRequestProto)1 ByteString (org.apache.ratis.thirdparty.com.google.protobuf.ByteString)1