Search in sources :

Example 1 with CreateFileResponse

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());
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) CreateFileResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateFileResponse) 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) CreateFileRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateFileRequest) OpenKeySession(org.apache.hadoop.ozone.om.helpers.OpenKeySession)

Aggregations

OmKeyArgs (org.apache.hadoop.ozone.om.helpers.OmKeyArgs)1 OpenKeySession (org.apache.hadoop.ozone.om.helpers.OpenKeySession)1 CreateFileRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateFileRequest)1 CreateFileResponse (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateFileResponse)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