Search in sources :

Example 6 with OmKeyArgs

use of org.apache.hadoop.ozone.om.helpers.OmKeyArgs in project ozone by apache.

the class OzoneManagerProtocolClientSideTranslatorPB method commitMultipartUploadPart.

@Override
public OmMultipartCommitUploadPartInfo commitMultipartUploadPart(OmKeyArgs omKeyArgs, long clientId) throws IOException {
    List<OmKeyLocationInfo> locationInfoList = omKeyArgs.getLocationInfoList();
    Preconditions.checkNotNull(locationInfoList);
    MultipartCommitUploadPartRequest.Builder multipartCommitUploadPartRequest = MultipartCommitUploadPartRequest.newBuilder();
    KeyArgs.Builder keyArgs = KeyArgs.newBuilder().setVolumeName(omKeyArgs.getVolumeName()).setBucketName(omKeyArgs.getBucketName()).setKeyName(omKeyArgs.getKeyName()).setMultipartUploadID(omKeyArgs.getMultipartUploadID()).setIsMultipartKey(omKeyArgs.getIsMultipartKey()).setMultipartNumber(omKeyArgs.getMultipartUploadPartNumber()).setDataSize(omKeyArgs.getDataSize()).addAllKeyLocations(locationInfoList.stream().map(info -> info.getProtobuf(ClientVersion.CURRENT_VERSION)).collect(Collectors.toList()));
    multipartCommitUploadPartRequest.setClientID(clientId);
    multipartCommitUploadPartRequest.setKeyArgs(keyArgs.build());
    OMRequest omRequest = createOMRequest(Type.CommitMultiPartUpload).setCommitMultiPartUploadRequest(multipartCommitUploadPartRequest.build()).build();
    MultipartCommitUploadPartResponse response = handleError(submitRequest(omRequest)).getCommitMultiPartUploadResponse();
    OmMultipartCommitUploadPartInfo info = new OmMultipartCommitUploadPartInfo(response.getPartName());
    return info;
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) OmMultipartCommitUploadPartInfo(org.apache.hadoop.ozone.om.helpers.OmMultipartCommitUploadPartInfo) 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) MultipartCommitUploadPartRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.MultipartCommitUploadPartRequest) MultipartCommitUploadPartResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.MultipartCommitUploadPartResponse) OmKeyLocationInfo(org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo)

Example 7 with OmKeyArgs

use of org.apache.hadoop.ozone.om.helpers.OmKeyArgs in project ozone by apache.

the class OzoneManagerProtocolClientSideTranslatorPB method openKey.

/**
 * Create a new open session of the key, then use the returned meta info to
 * talk to data node to actually write the key.
 * @param args the args for the key to be allocated
 * @return a handler to the key, returned client
 * @throws IOException
 */
@Override
public OpenKeySession openKey(OmKeyArgs args) throws IOException {
    CreateKeyRequest.Builder req = CreateKeyRequest.newBuilder();
    KeyArgs.Builder keyArgs = KeyArgs.newBuilder().setVolumeName(args.getVolumeName()).setBucketName(args.getBucketName()).setKeyName(args.getKeyName());
    if (args.getAcls() != null) {
        keyArgs.addAllAcls(args.getAcls().stream().distinct().map(a -> OzoneAcl.toProtobuf(a)).collect(Collectors.toList()));
    }
    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());
    }
    if (args.getDataSize() > 0) {
        keyArgs.setDataSize(args.getDataSize());
    }
    if (args.getMetadata() != null && args.getMetadata().size() > 0) {
        keyArgs.addAllMetadata(KeyValueUtil.toProtobuf(args.getMetadata()));
    }
    req.setKeyArgs(keyArgs.build());
    if (args.getMultipartUploadID() != null) {
        keyArgs.setMultipartUploadID(args.getMultipartUploadID());
    }
    if (args.getMultipartUploadPartNumber() > 0) {
        keyArgs.setMultipartNumber(args.getMultipartUploadPartNumber());
    }
    keyArgs.setIsMultipartKey(args.getIsMultipartKey());
    req.setKeyArgs(keyArgs.build());
    OMRequest omRequest = createOMRequest(Type.CreateKey).setCreateKeyRequest(req).build();
    CreateKeyResponse keyResponse = handleError(submitRequest(omRequest)).getCreateKeyResponse();
    return new OpenKeySession(keyResponse.getID(), OmKeyInfo.getFromProtobuf(keyResponse.getKeyInfo()), keyResponse.getOpenVersion());
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) ECReplicationConfig(org.apache.hadoop.hdds.client.ECReplicationConfig) CreateKeyRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateKeyRequest) 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) CreateKeyResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateKeyResponse) OpenKeySession(org.apache.hadoop.ozone.om.helpers.OpenKeySession)

Example 8 with OmKeyArgs

use of org.apache.hadoop.ozone.om.helpers.OmKeyArgs in project ozone by apache.

the class OzoneManagerProtocolClientSideTranslatorPB method createDirectory.

@Override
public void createDirectory(OmKeyArgs args) throws IOException {
    KeyArgs keyArgs = KeyArgs.newBuilder().setVolumeName(args.getVolumeName()).setBucketName(args.getBucketName()).setKeyName(args.getKeyName()).addAllAcls(args.getAcls().stream().map(a -> OzoneAcl.toProtobuf(a)).collect(Collectors.toList())).build();
    CreateDirectoryRequest request = CreateDirectoryRequest.newBuilder().setKeyArgs(keyArgs).build();
    OMRequest omRequest = createOMRequest(Type.CreateDirectory).setCreateDirectoryRequest(request).build();
    OMResponse omResponse = submitRequest(omRequest);
    if (!omResponse.getStatus().equals(DIRECTORY_ALREADY_EXISTS)) {
        // TODO: If the directory already exists, we should return false to
        // client. For this, the client createDirectory API needs to be
        // changed to return a boolean.
        handleError(omResponse);
    }
}
Also used : GetDelegationTokenResponseProto(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.GetDelegationTokenResponseProto) GetS3VolumeContextResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.GetS3VolumeContextResponse) OmMultipartCommitUploadPartInfo(org.apache.hadoop.ozone.om.helpers.OmMultipartCommitUploadPartInfo) Text(org.apache.hadoop.io.Text) ServiceInfo(org.apache.hadoop.ozone.om.helpers.ServiceInfo) DeleteKeyRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteKeyRequest) TenantAssignUserAccessIdResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.TenantAssignUserAccessIdResponse) OmDeleteKeys(org.apache.hadoop.ozone.om.helpers.OmDeleteKeys) FinalizeUpgradeRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.FinalizeUpgradeRequest) AllocateBlockRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.AllocateBlockRequest) LookupFileRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.LookupFileRequest) ListKeysResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListKeysResponse) TenantListUserResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.TenantListUserResponse) GetFileStatusRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.GetFileStatusRequest) Map(java.util.Map) DBUpdates(org.apache.hadoop.ozone.om.helpers.DBUpdates) OzoneManagerProtocolProtos(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos) GetS3SecretResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.GetS3SecretResponse) TenantUserList(org.apache.hadoop.ozone.om.helpers.TenantUserList) MultipartUploadListPartsRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.MultipartUploadListPartsRequest) OmRenameKeys(org.apache.hadoop.ozone.om.helpers.OmRenameKeys) CancelDelegationTokenRequestProto(org.apache.hadoop.ozone.security.proto.SecurityProtos.CancelDelegationTokenRequestProto) GetS3VolumeContextRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.GetS3VolumeContextRequest) SetBucketPropertyRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.SetBucketPropertyRequest) SetS3SecretResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.SetS3SecretResponse) AddAclRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.AddAclRequest) CommitKeyRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CommitKeyRequest) MultipartCommitUploadPartResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.MultipartCommitUploadPartResponse) OK(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Status.OK) OmBucketInfo(org.apache.hadoop.ozone.om.helpers.OmBucketInfo) MultipartUploadCompleteResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.MultipartUploadCompleteResponse) CreateFileResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateFileResponse) OzoneFileStatusProto(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OzoneFileStatusProto) RevokeS3SecretRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RevokeS3SecretRequest) CheckVolumeAccessRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CheckVolumeAccessRequest) KeyValueUtil(org.apache.hadoop.ozone.om.helpers.KeyValueUtil) SetBucketPropertyResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.SetBucketPropertyResponse) TenantUserInfoValue(org.apache.hadoop.ozone.om.helpers.TenantUserInfoValue) BucketInfo(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.BucketInfo) CancelPrepareResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CancelPrepareResponse) AllocateBlockResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.AllocateBlockResponse) OMPBHelper(org.apache.hadoop.ozone.protocolPB.OMPBHelper) CreateBucketRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateBucketRequest) PrepareResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.PrepareResponse) GetS3SecretRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.GetS3SecretRequest) ExcludeList(org.apache.hadoop.hdds.scm.container.common.helpers.ExcludeList) AddAclResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.AddAclResponse) RenameKeysRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RenameKeysRequest) Type(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type) GetAclResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.GetAclResponse) DeleteTenantRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteTenantRequest) OzoneAclInfo(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OzoneAclInfo) DeleteTenantState(org.apache.hadoop.ozone.om.helpers.DeleteTenantState) MultipartInfoInitiateResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.MultipartInfoInitiateResponse) ListBucketsResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListBucketsResponse) TenantListUserRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.TenantListUserRequest) TenantRevokeAdminRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.TenantRevokeAdminRequest) CreateVolumeRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateVolumeRequest) DeleteVolumeRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteVolumeRequest) RecoverTrashResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RecoverTrashResponse) S3Secret(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.S3Secret) OmMultipartUploadListParts(org.apache.hadoop.ozone.om.helpers.OmMultipartUploadListParts) SetVolumePropertyResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.SetVolumePropertyResponse) TenantAssignAdminRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.TenantAssignAdminRequest) CancelPrepareRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CancelPrepareRequest) S3Auth(org.apache.hadoop.ozone.om.protocol.S3Auth) GetAclRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.GetAclRequest) SetVolumePropertyRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.SetVolumePropertyRequest) InfoVolumeRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.InfoVolumeRequest) ArrayList(java.util.ArrayList) ListMultipartUploadsResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListMultipartUploadsResponse) Strings(com.google.common.base.Strings) RenewDelegationTokenResponseProto(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RenewDelegationTokenResponseProto) SetAclResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.SetAclResponse) OMResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse) DeleteBucketRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteBucketRequest) PrepareRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.PrepareRequest) GetDelegationTokenRequestProto(org.apache.hadoop.ozone.security.proto.SecurityProtos.GetDelegationTokenRequestProto) OmMultipartInfo(org.apache.hadoop.ozone.om.helpers.OmMultipartInfo) CreateTenantRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateTenantRequest) OpenKeySession(org.apache.hadoop.ozone.om.helpers.OpenKeySession) ReplicationConfig(org.apache.hadoop.hdds.client.ReplicationConfig) IOException(java.io.IOException) OmTenantArgs(org.apache.hadoop.ozone.om.helpers.OmTenantArgs) PrepareRequestArgs(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.PrepareRequestArgs) Token(org.apache.hadoop.security.token.Token) ListBucketsRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListBucketsRequest) ListTenantResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListTenantResponse) InterfaceAudience(org.apache.hadoop.hdds.annotation.InterfaceAudience) CreateFileRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateFileRequest) MultipartUploadAbortRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.MultipartUploadAbortRequest) TenantAssignUserAccessIdRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.TenantAssignUserAccessIdRequest) RenewDelegationTokenRequestProto(org.apache.hadoop.ozone.security.proto.SecurityProtos.RenewDelegationTokenRequestProto) RenameKeysArgs(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RenameKeysArgs) SetS3SecretRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.SetS3SecretRequest) Preconditions(com.google.common.base.Preconditions) TenantStateList(org.apache.hadoop.ozone.om.helpers.TenantStateList) OmMultipartUploadCompleteList(org.apache.hadoop.ozone.om.helpers.OmMultipartUploadCompleteList) GetFileStatusResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.GetFileStatusResponse) VolumeInfo(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.VolumeInfo) UpgradeFinalizer(org.apache.hadoop.ozone.upgrade.UpgradeFinalizer) MultipartCommitUploadPartRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.MultipartCommitUploadPartRequest) DeleteTenantResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteTenantResponse) OmKeyArgs(org.apache.hadoop.ozone.om.helpers.OmKeyArgs) ListStatusRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListStatusRequest) CreateDirectoryRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateDirectoryRequest) OzoneFileStatus(org.apache.hadoop.ozone.om.helpers.OzoneFileStatus) ListTrashRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListTrashRequest) StatusAndMessages(org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.StatusAndMessages) TenantRevokeUserAccessIdRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.TenantRevokeUserAccessIdRequest) OzoneTokenIdentifier(org.apache.hadoop.ozone.security.OzoneTokenIdentifier) OzoneAcl(org.apache.hadoop.ozone.OzoneAcl) OmMultipartUpload(org.apache.hadoop.ozone.om.helpers.OmMultipartUpload) TenantGetUserInfoRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.TenantGetUserInfoRequest) S3VolumeContext(org.apache.hadoop.ozone.om.helpers.S3VolumeContext) LookupKeyResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.LookupKeyResponse) ListStatusResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListStatusResponse) OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) TenantGetUserInfoResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.TenantGetUserInfoResponse) ListTrashResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListTrashResponse) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) DBUpdatesResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DBUpdatesResponse) FinalizeUpgradeResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.FinalizeUpgradeResponse) ByteString(com.google.protobuf.ByteString) List(java.util.List) ServiceListRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ServiceListRequest) OMException(org.apache.hadoop.ozone.om.exceptions.OMException) OmMultipartUploadCompleteInfo(org.apache.hadoop.ozone.om.helpers.OmMultipartUploadCompleteInfo) ClientVersion(org.apache.hadoop.ozone.ClientVersion) OzoneObj(org.apache.hadoop.ozone.security.acl.OzoneObj) ListVolumeRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListVolumeRequest) LookupFileResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.LookupFileResponse) MultipartUploadCompleteRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.MultipartUploadCompleteRequest) DIRECTORY_ALREADY_EXISTS(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Status.DIRECTORY_ALREADY_EXISTS) ServiceInfoEx(org.apache.hadoop.ozone.om.helpers.ServiceInfoEx) DeleteKeysRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteKeysRequest) ListTenantRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListTenantRequest) CreateKeyResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateKeyResponse) PrepareStatusRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.PrepareStatusRequest) DeleteKeyArgs(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteKeyArgs) ServiceListResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ServiceListResponse) RenameKeysMap(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RenameKeysMap) LookupKeyRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.LookupKeyRequest) UpgradeFinalizationStatus(org.apache.hadoop.hdds.protocol.proto.HddsProtos.UpgradeFinalizationStatus) ResultCodes(org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes) ACCESS_DENIED(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Status.ACCESS_DENIED) SetAclRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.SetAclRequest) DBUpdatesRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DBUpdatesRequest) OmMultipartUploadList(org.apache.hadoop.ozone.om.helpers.OmMultipartUploadList) InfoBucketRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.InfoBucketRequest) TOKEN_ERROR_OTHER(org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.TOKEN_ERROR_OTHER) OmKeyInfo(org.apache.hadoop.ozone.om.helpers.OmKeyInfo) OmKeyLocationInfo(org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo) S3SecretValue(org.apache.hadoop.ozone.om.helpers.S3SecretValue) MultipartInfoInitiateRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.MultipartInfoInitiateRequest) FinalizeUpgradeProgressRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.FinalizeUpgradeProgressRequest) OmBucketArgs(org.apache.hadoop.ozone.om.helpers.OmBucketArgs) CancelDelegationTokenResponseProto(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CancelDelegationTokenResponseProto) S3Authentication(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.S3Authentication) InfoVolumeResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.InfoVolumeResponse) RecoverTrashRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RecoverTrashRequest) BucketArgs(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.BucketArgs) CreateKeyRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateKeyRequest) InfoBucketResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.InfoBucketResponse) ListKeysRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListKeysRequest) ECReplicationConfig(org.apache.hadoop.hdds.client.ECReplicationConfig) OmVolumeArgs(org.apache.hadoop.ozone.om.helpers.OmVolumeArgs) RenameKeyRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RenameKeyRequest) KeyArgs(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyArgs) MultipartUploadListPartsResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.MultipartUploadListPartsResponse) RepeatedOmKeyInfo(org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo) FinalizeUpgradeProgressResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.FinalizeUpgradeProgressResponse) TracingUtil(org.apache.hadoop.hdds.tracing.TracingUtil) RemoveAclResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RemoveAclResponse) ListVolumeResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListVolumeResponse) PrepareStatusResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.PrepareStatusResponse) VisibleForTesting(com.google.common.annotations.VisibleForTesting) ListMultipartUploadsRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListMultipartUploadsRequest) RemoveAclRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RemoveAclRequest) OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) 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) CreateDirectoryRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateDirectoryRequest) OMResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse)

Example 9 with OmKeyArgs

use of org.apache.hadoop.ozone.om.helpers.OmKeyArgs in project ozone by apache.

the class OzoneManagerProtocolClientSideTranslatorPB method commitKey.

@Override
public void commitKey(OmKeyArgs args, long clientId) throws IOException {
    CommitKeyRequest.Builder req = CommitKeyRequest.newBuilder();
    List<OmKeyLocationInfo> locationInfoList = args.getLocationInfoList();
    Preconditions.checkNotNull(locationInfoList);
    KeyArgs.Builder keyArgsBuilder = KeyArgs.newBuilder().setVolumeName(args.getVolumeName()).setBucketName(args.getBucketName()).setKeyName(args.getKeyName()).setDataSize(args.getDataSize()).addAllKeyLocations(locationInfoList.stream().map(info -> info.getProtobuf(ClientVersion.CURRENT_VERSION)).collect(Collectors.toList()));
    if (args.getReplicationConfig() != null) {
        if (args.getReplicationConfig() instanceof ECReplicationConfig) {
            keyArgsBuilder.setEcReplicationConfig(((ECReplicationConfig) args.getReplicationConfig()).toProto());
        } else {
            keyArgsBuilder.setFactor(ReplicationConfig.getLegacyFactor(args.getReplicationConfig()));
        }
        keyArgsBuilder.setType(args.getReplicationConfig().getReplicationType());
    }
    req.setKeyArgs(keyArgsBuilder.build());
    req.setClientID(clientId);
    OMRequest omRequest = createOMRequest(Type.CommitKey).setCommitKeyRequest(req).build();
    handleError(submitRequest(omRequest));
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) ECReplicationConfig(org.apache.hadoop.hdds.client.ECReplicationConfig) CommitKeyRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CommitKeyRequest) 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) OmKeyLocationInfo(org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo)

Example 10 with OmKeyArgs

use of org.apache.hadoop.ozone.om.helpers.OmKeyArgs in project ozone by apache.

the class TestCloseContainerHandlingByClient method testBlockWritesCloseConsistency.

@Test
public void testBlockWritesCloseConsistency() throws Exception {
    String keyName = getKeyName();
    OzoneOutputStream key = createKey(keyName, ReplicationType.RATIS, 0);
    // write data more than 1 chunk
    byte[] data = ContainerTestHelper.getFixedLengthString(keyString, chunkSize + chunkSize / 2).getBytes(UTF_8);
    key.write(data);
    Assert.assertTrue(key.getOutputStream() instanceof KeyOutputStream);
    // get the name of a valid container
    OmKeyArgs keyArgs = new OmKeyArgs.Builder().setVolumeName(volumeName).setBucketName(bucketName).setReplicationConfig(StandaloneReplicationConfig.getInstance(ONE)).setKeyName(keyName).setRefreshPipeline(true).build();
    waitForContainerClose(key);
    key.close();
    // read the key from OM again and match the length.The length will still
    // be the equal to the original data size.
    OmKeyInfo keyInfo = cluster.getOzoneManager().lookupKey(keyArgs);
    Assert.assertEquals(data.length, keyInfo.getDataSize());
    validateData(keyName, data);
}
Also used : OmKeyInfo(org.apache.hadoop.ozone.om.helpers.OmKeyInfo) OzoneOutputStream(org.apache.hadoop.ozone.client.io.OzoneOutputStream) KeyOutputStream(org.apache.hadoop.ozone.client.io.KeyOutputStream) OmKeyArgs(org.apache.hadoop.ozone.om.helpers.OmKeyArgs) Test(org.junit.Test)

Aggregations

OmKeyArgs (org.apache.hadoop.ozone.om.helpers.OmKeyArgs)112 OmKeyInfo (org.apache.hadoop.ozone.om.helpers.OmKeyInfo)46 Test (org.junit.Test)36 OmKeyLocationInfo (org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo)35 OzoneOutputStream (org.apache.hadoop.ozone.client.io.OzoneOutputStream)28 OpenKeySession (org.apache.hadoop.ozone.om.helpers.OpenKeySession)24 ContainerInfo (org.apache.hadoop.hdds.scm.container.ContainerInfo)21 KeyArgs (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyArgs)19 ArrayList (java.util.ArrayList)18 DatanodeDetails (org.apache.hadoop.hdds.protocol.DatanodeDetails)18 Pipeline (org.apache.hadoop.hdds.scm.pipeline.Pipeline)18 OzoneFileStatus (org.apache.hadoop.ozone.om.helpers.OzoneFileStatus)18 KeyOutputStream (org.apache.hadoop.ozone.client.io.KeyOutputStream)17 DeleteKeyArgs (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteKeyArgs)15 OMRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest)15 RepeatedOmKeyInfo (org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo)14 IOException (java.io.IOException)12 Test (org.junit.jupiter.api.Test)12 OMException (org.apache.hadoop.ozone.om.exceptions.OMException)10 BlockID (org.apache.hadoop.hdds.client.BlockID)9