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());
}
Aggregations