Search in sources :

Example 1 with InitReplicaRecoveryRequestProto

use of org.apache.hadoop.hdfs.protocol.proto.InterDatanodeProtocolProtos.InitReplicaRecoveryRequestProto in project hadoop by apache.

the class InterDatanodeProtocolTranslatorPB method initReplicaRecovery.

@Override
public ReplicaRecoveryInfo initReplicaRecovery(RecoveringBlock rBlock) throws IOException {
    InitReplicaRecoveryRequestProto req = InitReplicaRecoveryRequestProto.newBuilder().setBlock(PBHelper.convert(rBlock)).build();
    InitReplicaRecoveryResponseProto resp;
    try {
        resp = rpcProxy.initReplicaRecovery(NULL_CONTROLLER, req);
    } catch (ServiceException e) {
        throw ProtobufHelper.getRemoteException(e);
    }
    if (!resp.getReplicaFound()) {
        // No replica found on the remote node.
        return null;
    } else {
        if (!resp.hasBlock() || !resp.hasState()) {
            throw new IOException("Replica was found but missing fields. " + "Req: " + req + "\n" + "Resp: " + resp);
        }
    }
    BlockProto b = resp.getBlock();
    return new ReplicaRecoveryInfo(b.getBlockId(), b.getNumBytes(), b.getGenStamp(), PBHelper.convert(resp.getState()));
}
Also used : InitReplicaRecoveryRequestProto(org.apache.hadoop.hdfs.protocol.proto.InterDatanodeProtocolProtos.InitReplicaRecoveryRequestProto) ServiceException(com.google.protobuf.ServiceException) ReplicaRecoveryInfo(org.apache.hadoop.hdfs.server.protocol.ReplicaRecoveryInfo) InitReplicaRecoveryResponseProto(org.apache.hadoop.hdfs.protocol.proto.InterDatanodeProtocolProtos.InitReplicaRecoveryResponseProto) BlockProto(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.BlockProto) IOException(java.io.IOException)

Aggregations

ServiceException (com.google.protobuf.ServiceException)1 IOException (java.io.IOException)1 BlockProto (org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.BlockProto)1 InitReplicaRecoveryRequestProto (org.apache.hadoop.hdfs.protocol.proto.InterDatanodeProtocolProtos.InitReplicaRecoveryRequestProto)1 InitReplicaRecoveryResponseProto (org.apache.hadoop.hdfs.protocol.proto.InterDatanodeProtocolProtos.InitReplicaRecoveryResponseProto)1 ReplicaRecoveryInfo (org.apache.hadoop.hdfs.server.protocol.ReplicaRecoveryInfo)1