Search in sources :

Example 96 with OmKeyArgs

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

the class TestTrashService method createAndDeleteKey.

private void createAndDeleteKey(String keyName) throws IOException {
    OMRequestTestUtils.addVolumeToOM(keyManager.getMetadataManager(), OmVolumeArgs.newBuilder().setOwnerName("owner").setAdminName("admin").setVolume(volumeName).build());
    OMRequestTestUtils.addBucketToOM(keyManager.getMetadataManager(), OmBucketInfo.newBuilder().setVolumeName(volumeName).setBucketName(bucketName).build());
    OmKeyArgs keyArgs = new OmKeyArgs.Builder().setVolumeName(volumeName).setBucketName(bucketName).setKeyName(keyName).setAcls(Collections.emptyList()).setLocationInfoList(new ArrayList<>()).setReplicationConfig(StandaloneReplicationConfig.getInstance(HddsProtos.ReplicationFactor.ONE)).build();
    /* Create and delete key in the Key Manager. */
    OpenKeySession session = writeClient.openKey(keyArgs);
    writeClient.commitKey(keyArgs, session.getId());
    writeClient.deleteKey(keyArgs);
}
Also used : OpenKeySession(org.apache.hadoop.ozone.om.helpers.OpenKeySession) OmKeyArgs(org.apache.hadoop.ozone.om.helpers.OmKeyArgs)

Example 97 with OmKeyArgs

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

the class TestKeyManagerUnit method initMultipartUpload.

private OmMultipartInfo initMultipartUpload(OzoneManagerProtocol omtest, String volume, String bucket, String key) throws IOException {
    OmKeyArgs key1 = new Builder().setVolumeName(volume).setBucketName(bucket).setKeyName(key).setReplicationConfig(RatisReplicationConfig.getInstance(ReplicationFactor.THREE)).setAcls(new ArrayList<>()).build();
    OmMultipartInfo omMultipartInfo = omtest.initiateMultipartUpload(key1);
    return omMultipartInfo;
}
Also used : Builder(org.apache.hadoop.ozone.om.helpers.OmKeyArgs.Builder) ArrayList(java.util.ArrayList) OmMultipartInfo(org.apache.hadoop.ozone.om.helpers.OmMultipartInfo) OmKeyArgs(org.apache.hadoop.ozone.om.helpers.OmKeyArgs)

Example 98 with OmKeyArgs

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

the class OmKeyGenerator method createKey.

private void createKey(long counter) throws Exception {
    UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
    OmKeyArgs keyArgs = new Builder().setBucketName(bucketName).setVolumeName(volumeName).setReplicationConfig(RatisReplicationConfig.getInstance(factor)).setKeyName(generateObjectName(counter)).setLocationInfoList(new ArrayList<>()).setAcls(OzoneAclUtil.getAclList(ugi.getUserName(), ugi.getGroupNames(), ALL, ALL)).build();
    timer.time(() -> {
        OpenKeySession openKeySession = ozoneManagerClient.openKey(keyArgs);
        ozoneManagerClient.commitKey(keyArgs, openKeySession.getId());
        return null;
    });
}
Also used : Builder(org.apache.hadoop.ozone.om.helpers.OmKeyArgs.Builder) OpenKeySession(org.apache.hadoop.ozone.om.helpers.OpenKeySession) OmKeyArgs(org.apache.hadoop.ozone.om.helpers.OmKeyArgs) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Example 99 with OmKeyArgs

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

the class OzoneManagerProtocolClientSideTranslatorPB method deleteKey.

/**
 * Deletes an existing key.
 *
 * @param args the args of the key.
 * @throws IOException
 */
@Override
public void deleteKey(OmKeyArgs args) throws IOException {
    DeleteKeyRequest.Builder req = DeleteKeyRequest.newBuilder();
    KeyArgs keyArgs = KeyArgs.newBuilder().setVolumeName(args.getVolumeName()).setBucketName(args.getBucketName()).setKeyName(args.getKeyName()).setRecursive(args.isRecursive()).build();
    req.setKeyArgs(keyArgs);
    OMRequest omRequest = createOMRequest(Type.DeleteKey).setDeleteKeyRequest(req).build();
    handleError(submitRequest(omRequest));
}
Also used : 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) DeleteKeyRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteKeyRequest)

Example 100 with OmKeyArgs

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

the class OzoneManagerProtocolClientSideTranslatorPB method abortMultipartUpload.

@Override
public void abortMultipartUpload(OmKeyArgs omKeyArgs) throws IOException {
    KeyArgs.Builder keyArgs = KeyArgs.newBuilder().setVolumeName(omKeyArgs.getVolumeName()).setBucketName(omKeyArgs.getBucketName()).setKeyName(omKeyArgs.getKeyName()).setMultipartUploadID(omKeyArgs.getMultipartUploadID());
    MultipartUploadAbortRequest.Builder multipartUploadAbortRequest = MultipartUploadAbortRequest.newBuilder();
    multipartUploadAbortRequest.setKeyArgs(keyArgs);
    OMRequest omRequest = createOMRequest(Type.AbortMultiPartUpload).setAbortMultiPartUploadRequest(multipartUploadAbortRequest.build()).build();
    handleError(submitRequest(omRequest));
}
Also used : MultipartUploadAbortRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.MultipartUploadAbortRequest) 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)

Aggregations

OmKeyArgs (org.apache.hadoop.ozone.om.helpers.OmKeyArgs)106 Test (org.junit.Test)46 OmKeyInfo (org.apache.hadoop.ozone.om.helpers.OmKeyInfo)45 OmKeyLocationInfo (org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo)33 OzoneOutputStream (org.apache.hadoop.ozone.client.io.OzoneOutputStream)28 OpenKeySession (org.apache.hadoop.ozone.om.helpers.OpenKeySession)23 ContainerInfo (org.apache.hadoop.hdds.scm.container.ContainerInfo)20 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 KeyOutputStream (org.apache.hadoop.ozone.client.io.KeyOutputStream)17 OzoneFileStatus (org.apache.hadoop.ozone.om.helpers.OzoneFileStatus)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)13 IOException (java.io.IOException)10 OMException (org.apache.hadoop.ozone.om.exceptions.OMException)9 BlockID (org.apache.hadoop.hdds.client.BlockID)8 OzoneBucket (org.apache.hadoop.ozone.client.OzoneBucket)8