Search in sources :

Example 1 with AppendResponseProto

use of org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos.AppendResponseProto in project hadoop by apache.

the class ClientNamenodeProtocolTranslatorPB method append.

@Override
public LastBlockWithStatus append(String src, String clientName, EnumSetWritable<CreateFlag> flag) throws IOException {
    AppendRequestProto req = AppendRequestProto.newBuilder().setSrc(src).setClientName(clientName).setFlag(PBHelperClient.convertCreateFlag(flag)).build();
    try {
        AppendResponseProto res = rpcProxy.append(null, req);
        LocatedBlock lastBlock = res.hasBlock() ? PBHelperClient.convertLocatedBlockProto(res.getBlock()) : null;
        HdfsFileStatus stat = (res.hasStat()) ? PBHelperClient.convert(res.getStat()) : null;
        return new LastBlockWithStatus(lastBlock, stat);
    } catch (ServiceException e) {
        throw ProtobufHelper.getRemoteException(e);
    }
}
Also used : ServiceException(com.google.protobuf.ServiceException) LastBlockWithStatus(org.apache.hadoop.hdfs.protocol.LastBlockWithStatus) AppendResponseProto(org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos.AppendResponseProto) HdfsFileStatus(org.apache.hadoop.hdfs.protocol.HdfsFileStatus) LocatedBlock(org.apache.hadoop.hdfs.protocol.LocatedBlock) AppendRequestProto(org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos.AppendRequestProto)

Example 2 with AppendResponseProto

use of org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos.AppendResponseProto in project hadoop by apache.

the class ClientNamenodeProtocolServerSideTranslatorPB method append.

@Override
public AppendResponseProto append(RpcController controller, AppendRequestProto req) throws ServiceException {
    try {
        EnumSetWritable<CreateFlag> flags = req.hasFlag() ? PBHelperClient.convertCreateFlag(req.getFlag()) : new EnumSetWritable<>(EnumSet.of(CreateFlag.APPEND));
        LastBlockWithStatus result = server.append(req.getSrc(), req.getClientName(), flags);
        AppendResponseProto.Builder builder = AppendResponseProto.newBuilder();
        if (result.getLastBlock() != null) {
            builder.setBlock(PBHelperClient.convertLocatedBlock(result.getLastBlock()));
        }
        if (result.getFileStatus() != null) {
            builder.setStat(PBHelperClient.convert(result.getFileStatus()));
        }
        return builder.build();
    } catch (IOException e) {
        throw new ServiceException(e);
    }
}
Also used : CreateFlag(org.apache.hadoop.fs.CreateFlag) ServiceException(com.google.protobuf.ServiceException) LastBlockWithStatus(org.apache.hadoop.hdfs.protocol.LastBlockWithStatus) AppendResponseProto(org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos.AppendResponseProto) IOException(java.io.IOException)

Aggregations

ServiceException (com.google.protobuf.ServiceException)2 LastBlockWithStatus (org.apache.hadoop.hdfs.protocol.LastBlockWithStatus)2 AppendResponseProto (org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos.AppendResponseProto)2 IOException (java.io.IOException)1 CreateFlag (org.apache.hadoop.fs.CreateFlag)1 HdfsFileStatus (org.apache.hadoop.hdfs.protocol.HdfsFileStatus)1 LocatedBlock (org.apache.hadoop.hdfs.protocol.LocatedBlock)1 AppendRequestProto (org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos.AppendRequestProto)1