Search in sources :

Example 51 with ServiceException

use of com.google.protobuf.ServiceException in project hadoop by apache.

the class DatanodeProtocolClientSideTranslatorPB method registerDatanode.

@Override
public DatanodeRegistration registerDatanode(DatanodeRegistration registration) throws IOException {
    RegisterDatanodeRequestProto.Builder builder = RegisterDatanodeRequestProto.newBuilder().setRegistration(PBHelper.convert(registration));
    RegisterDatanodeResponseProto resp;
    try {
        resp = rpcProxy.registerDatanode(NULL_CONTROLLER, builder.build());
    } catch (ServiceException se) {
        throw ProtobufHelper.getRemoteException(se);
    }
    return PBHelper.convert(resp.getRegistration());
}
Also used : RegisterDatanodeRequestProto(org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.RegisterDatanodeRequestProto) ServiceException(com.google.protobuf.ServiceException) RegisterDatanodeResponseProto(org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.RegisterDatanodeResponseProto)

Example 52 with ServiceException

use of com.google.protobuf.ServiceException in project hadoop by apache.

the class DatanodeProtocolClientSideTranslatorPB method reportBadBlocks.

@Override
public void reportBadBlocks(LocatedBlock[] blocks) throws IOException {
    ReportBadBlocksRequestProto.Builder builder = ReportBadBlocksRequestProto.newBuilder();
    for (int i = 0; i < blocks.length; i++) {
        builder.addBlocks(i, PBHelperClient.convertLocatedBlock(blocks[i]));
    }
    ReportBadBlocksRequestProto req = builder.build();
    try {
        rpcProxy.reportBadBlocks(NULL_CONTROLLER, req);
    } catch (ServiceException se) {
        throw ProtobufHelper.getRemoteException(se);
    }
}
Also used : ServiceException(com.google.protobuf.ServiceException) ReportBadBlocksRequestProto(org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.ReportBadBlocksRequestProto)

Example 53 with ServiceException

use of com.google.protobuf.ServiceException in project hadoop by apache.

the class DatanodeProtocolServerSideTranslatorPB method reportBadBlocks.

@Override
public ReportBadBlocksResponseProto reportBadBlocks(RpcController controller, ReportBadBlocksRequestProto request) throws ServiceException {
    List<LocatedBlockProto> lbps = request.getBlocksList();
    LocatedBlock[] blocks = new LocatedBlock[lbps.size()];
    for (int i = 0; i < lbps.size(); i++) {
        blocks[i] = PBHelperClient.convertLocatedBlockProto(lbps.get(i));
    }
    try {
        impl.reportBadBlocks(blocks);
    } catch (IOException e) {
        throw new ServiceException(e);
    }
    return VOID_REPORT_BAD_BLOCK_RESPONSE;
}
Also used : ServiceException(com.google.protobuf.ServiceException) LocatedBlockProto(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.LocatedBlockProto) LocatedBlock(org.apache.hadoop.hdfs.protocol.LocatedBlock) IOException(java.io.IOException)

Example 54 with ServiceException

use of com.google.protobuf.ServiceException in project hadoop by apache.

the class DatanodeProtocolServerSideTranslatorPB method sendHeartbeat.

@Override
public HeartbeatResponseProto sendHeartbeat(RpcController controller, HeartbeatRequestProto request) throws ServiceException {
    HeartbeatResponse response;
    try {
        final StorageReport[] report = PBHelperClient.convertStorageReports(request.getReportsList());
        VolumeFailureSummary volumeFailureSummary = request.hasVolumeFailureSummary() ? PBHelper.convertVolumeFailureSummary(request.getVolumeFailureSummary()) : null;
        response = impl.sendHeartbeat(PBHelper.convert(request.getRegistration()), report, request.getCacheCapacity(), request.getCacheUsed(), request.getXmitsInProgress(), request.getXceiverCount(), request.getFailedVolumes(), volumeFailureSummary, request.getRequestFullBlockReportLease(), PBHelper.convertSlowPeerInfo(request.getSlowPeersList()));
    } catch (IOException e) {
        throw new ServiceException(e);
    }
    HeartbeatResponseProto.Builder builder = HeartbeatResponseProto.newBuilder();
    DatanodeCommand[] cmds = response.getCommands();
    if (cmds != null) {
        for (int i = 0; i < cmds.length; i++) {
            if (cmds[i] != null) {
                builder.addCmds(PBHelper.convert(cmds[i]));
            }
        }
    }
    builder.setHaStatus(PBHelper.convert(response.getNameNodeHaState()));
    RollingUpgradeStatus rollingUpdateStatus = response.getRollingUpdateStatus();
    if (rollingUpdateStatus != null) {
        // V2 is always set for newer datanodes.
        // To be compatible with older datanodes, V1 is set to null
        //  if the RU was finalized.
        RollingUpgradeStatusProto rus = PBHelperClient.convertRollingUpgradeStatus(rollingUpdateStatus);
        builder.setRollingUpgradeStatusV2(rus);
        if (!rollingUpdateStatus.isFinalized()) {
            builder.setRollingUpgradeStatus(rus);
        }
    }
    builder.setFullBlockReportLeaseId(response.getFullBlockReportLeaseId());
    return builder.build();
}
Also used : HeartbeatResponse(org.apache.hadoop.hdfs.server.protocol.HeartbeatResponse) RollingUpgradeStatusProto(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.RollingUpgradeStatusProto) RollingUpgradeStatus(org.apache.hadoop.hdfs.protocol.RollingUpgradeStatus) StorageReport(org.apache.hadoop.hdfs.server.protocol.StorageReport) IOException(java.io.IOException) VolumeFailureSummary(org.apache.hadoop.hdfs.server.protocol.VolumeFailureSummary) DatanodeCommand(org.apache.hadoop.hdfs.server.protocol.DatanodeCommand) ServiceException(com.google.protobuf.ServiceException) HeartbeatResponseProto(org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.HeartbeatResponseProto)

Example 55 with ServiceException

use of com.google.protobuf.ServiceException in project hadoop by apache.

the class DatanodeProtocolServerSideTranslatorPB method commitBlockSynchronization.

@Override
public CommitBlockSynchronizationResponseProto commitBlockSynchronization(RpcController controller, CommitBlockSynchronizationRequestProto request) throws ServiceException {
    List<DatanodeIDProto> dnprotos = request.getNewTaragetsList();
    DatanodeID[] dns = new DatanodeID[dnprotos.size()];
    for (int i = 0; i < dnprotos.size(); i++) {
        dns[i] = PBHelperClient.convert(dnprotos.get(i));
    }
    final List<String> sidprotos = request.getNewTargetStoragesList();
    final String[] storageIDs = sidprotos.toArray(new String[sidprotos.size()]);
    try {
        impl.commitBlockSynchronization(PBHelperClient.convert(request.getBlock()), request.getNewGenStamp(), request.getNewLength(), request.getCloseFile(), request.getDeleteBlock(), dns, storageIDs);
    } catch (IOException e) {
        throw new ServiceException(e);
    }
    return VOID_COMMIT_BLOCK_SYNCHRONIZATION_RESPONSE_PROTO;
}
Also used : DatanodeID(org.apache.hadoop.hdfs.protocol.DatanodeID) ServiceException(com.google.protobuf.ServiceException) IOException(java.io.IOException) DatanodeIDProto(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.DatanodeIDProto)

Aggregations

ServiceException (com.google.protobuf.ServiceException)139 IOException (java.io.IOException)66 Test (org.junit.Test)22 ArrayList (java.util.ArrayList)12 Configuration (org.apache.hadoop.conf.Configuration)11 FsPermission (org.apache.hadoop.fs.permission.FsPermission)5 Table (org.apache.hadoop.hbase.client.Table)5 CoprocessorRpcChannel (org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel)5 InetSocketAddress (java.net.InetSocketAddress)4 DatanodeCommand (org.apache.hadoop.hdfs.server.protocol.DatanodeCommand)4 ByteString (com.google.protobuf.ByteString)3 InterruptedIOException (java.io.InterruptedIOException)3 ConnectException (java.net.ConnectException)3 SocketTimeoutException (java.net.SocketTimeoutException)3 Callable (java.util.concurrent.Callable)3 ExecutionException (java.util.concurrent.ExecutionException)3 ExecutorService (java.util.concurrent.ExecutorService)3 EncryptionZone (org.apache.hadoop.hdfs.protocol.EncryptionZone)3 LocatedBlock (org.apache.hadoop.hdfs.protocol.LocatedBlock)3 Server (org.apache.hadoop.ipc.Server)3