Search in sources :

Example 1 with AllocateBlockResponse

use of org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.AllocateBlockResponse in project ozone by apache.

the class OzoneManagerProtocolClientSideTranslatorPB method allocateBlock.

@Override
public OmKeyLocationInfo allocateBlock(OmKeyArgs args, long clientId, ExcludeList excludeList) throws IOException {
    AllocateBlockRequest.Builder req = AllocateBlockRequest.newBuilder();
    KeyArgs.Builder keyArgs = KeyArgs.newBuilder().setVolumeName(args.getVolumeName()).setBucketName(args.getBucketName()).setKeyName(args.getKeyName()).setDataSize(args.getDataSize());
    if (args.getReplicationConfig() != null) {
        if (args.getReplicationConfig() instanceof ECReplicationConfig) {
            keyArgs.setEcReplicationConfig(((ECReplicationConfig) args.getReplicationConfig()).toProto());
        } else {
            keyArgs.setFactor(ReplicationConfig.getLegacyFactor(args.getReplicationConfig()));
        }
        keyArgs.setType(args.getReplicationConfig().getReplicationType());
    }
    req.setKeyArgs(keyArgs);
    req.setClientID(clientId);
    req.setExcludeList(excludeList.getProtoBuf());
    OMRequest omRequest = createOMRequest(Type.AllocateBlock).setAllocateBlockRequest(req).build();
    AllocateBlockResponse resp = handleError(submitRequest(omRequest)).getAllocateBlockResponse();
    return OmKeyLocationInfo.getFromProtobuf(resp.getKeyLocation());
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) ECReplicationConfig(org.apache.hadoop.hdds.client.ECReplicationConfig) AllocateBlockResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.AllocateBlockResponse) OmKeyArgs(org.apache.hadoop.ozone.om.helpers.OmKeyArgs) DeleteKeyArgs(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteKeyArgs) KeyArgs(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyArgs) AllocateBlockRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.AllocateBlockRequest)

Aggregations

ECReplicationConfig (org.apache.hadoop.hdds.client.ECReplicationConfig)1 OmKeyArgs (org.apache.hadoop.ozone.om.helpers.OmKeyArgs)1 AllocateBlockRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.AllocateBlockRequest)1 AllocateBlockResponse (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.AllocateBlockResponse)1 DeleteKeyArgs (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteKeyArgs)1 KeyArgs (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyArgs)1 OMRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest)1