use of org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateFileResponse in project ozone by apache.
the class OzoneManagerProtocolClientSideTranslatorPB method createFile.
@Override
public OpenKeySession createFile(OmKeyArgs args, boolean overWrite, boolean recursive) throws IOException {
KeyArgs.Builder keyArgsBuilder = KeyArgs.newBuilder().setVolumeName(args.getVolumeName()).setBucketName(args.getBucketName()).setKeyName(args.getKeyName()).setDataSize(args.getDataSize()).addAllAcls(args.getAcls().stream().map(a -> OzoneAcl.toProtobuf(a)).collect(Collectors.toList()));
if (args.getReplicationConfig() != null) {
keyArgsBuilder.setFactor(ReplicationConfig.getLegacyFactor(args.getReplicationConfig()));
keyArgsBuilder.setType(args.getReplicationConfig().getReplicationType());
}
CreateFileRequest createFileRequest = CreateFileRequest.newBuilder().setKeyArgs(keyArgsBuilder.build()).setIsOverwrite(overWrite).setIsRecursive(recursive).build();
OMRequest omRequest = createOMRequest(Type.CreateFile).setCreateFileRequest(createFileRequest).build();
CreateFileResponse resp = handleError(submitRequest(omRequest)).getCreateFileResponse();
return new OpenKeySession(resp.getID(), OmKeyInfo.getFromProtobuf(resp.getKeyInfo()), resp.getOpenVersion());
}
Aggregations