Search in sources :

Example 1 with OzoneMultipartUpload

use of org.apache.hadoop.ozone.client.OzoneMultipartUpload in project ozone by apache.

the class TestOzoneClientMultipartUploadWithFSO method testListMultipartUpload.

@Test
public void testListMultipartUpload() throws Exception {
    String volumeName = UUID.randomUUID().toString();
    String bucketName = UUID.randomUUID().toString();
    String dirName = "dir1/dir2/dir3";
    String key1 = "dir1" + "/key1";
    String key2 = "dir1/dir2" + "/key2";
    String key3 = dirName + "/key3";
    List<String> keys = new ArrayList<>();
    keys.add(key1);
    keys.add(key2);
    keys.add(key3);
    store.createVolume(volumeName);
    OzoneVolume volume = store.getVolume(volumeName);
    volume.createBucket(bucketName);
    OzoneBucket bucket = volume.getBucket(bucketName);
    // Initiate multipart upload
    String uploadID1 = initiateMultipartUpload(bucket, key1, RATIS, ONE);
    String uploadID2 = initiateMultipartUpload(bucket, key2, RATIS, ONE);
    String uploadID3 = initiateMultipartUpload(bucket, key3, RATIS, ONE);
    // Upload Parts
    // Uploading part 1 with less than min size
    uploadPart(bucket, key1, uploadID1, 1, "data".getBytes(UTF_8));
    uploadPart(bucket, key2, uploadID2, 1, "data".getBytes(UTF_8));
    uploadPart(bucket, key3, uploadID3, 1, "data".getBytes(UTF_8));
    OzoneMultipartUploadList listMPUs = bucket.listMultipartUploads("dir1");
    Assert.assertEquals(3, listMPUs.getUploads().size());
    List<String> expectedList = new ArrayList<>(keys);
    for (OzoneMultipartUpload mpu : listMPUs.getUploads()) {
        expectedList.remove(mpu.getKeyName());
    }
    Assert.assertEquals(0, expectedList.size());
    listMPUs = bucket.listMultipartUploads("dir1/dir2");
    Assert.assertEquals(2, listMPUs.getUploads().size());
    expectedList = new ArrayList<>();
    expectedList.add(key2);
    expectedList.add(key3);
    for (OzoneMultipartUpload mpu : listMPUs.getUploads()) {
        expectedList.remove(mpu.getKeyName());
    }
    Assert.assertEquals(0, expectedList.size());
    listMPUs = bucket.listMultipartUploads("dir1/dir2/dir3");
    Assert.assertEquals(1, listMPUs.getUploads().size());
    expectedList = new ArrayList<>();
    expectedList.add(key3);
    for (OzoneMultipartUpload mpu : listMPUs.getUploads()) {
        expectedList.remove(mpu.getKeyName());
    }
    Assert.assertEquals(0, expectedList.size());
    // partial key
    listMPUs = bucket.listMultipartUploads("d");
    Assert.assertEquals(3, listMPUs.getUploads().size());
    expectedList = new ArrayList<>(keys);
    for (OzoneMultipartUpload mpu : listMPUs.getUploads()) {
        expectedList.remove(mpu.getKeyName());
    }
    Assert.assertEquals(0, expectedList.size());
    // partial key
    listMPUs = bucket.listMultipartUploads("");
    Assert.assertEquals(3, listMPUs.getUploads().size());
    expectedList = new ArrayList<>(keys);
    for (OzoneMultipartUpload mpu : listMPUs.getUploads()) {
        expectedList.remove(mpu.getKeyName());
    }
    Assert.assertEquals(0, expectedList.size());
}
Also used : OzoneVolume(org.apache.hadoop.ozone.client.OzoneVolume) OzoneBucket(org.apache.hadoop.ozone.client.OzoneBucket) OzoneMultipartUploadList(org.apache.hadoop.ozone.client.OzoneMultipartUploadList) ArrayList(java.util.ArrayList) OzoneMultipartUpload(org.apache.hadoop.ozone.client.OzoneMultipartUpload) Test(org.junit.Test)

Example 2 with OzoneMultipartUpload

use of org.apache.hadoop.ozone.client.OzoneMultipartUpload in project ozone by apache.

the class RpcClient method listMultipartUploads.

@Override
public OzoneMultipartUploadList listMultipartUploads(String volumeName, String bucketName, String prefix) throws IOException {
    OmMultipartUploadList omMultipartUploadList = ozoneManagerClient.listMultipartUploads(volumeName, bucketName, prefix);
    List<OzoneMultipartUpload> uploads = omMultipartUploadList.getUploads().stream().map(upload -> new OzoneMultipartUpload(upload.getVolumeName(), upload.getBucketName(), upload.getKeyName(), upload.getUploadId(), upload.getCreationTime(), upload.getReplicationConfig())).collect(Collectors.toList());
    OzoneMultipartUploadList result = new OzoneMultipartUploadList(uploads);
    return result;
}
Also used : ScmConfigKeys(org.apache.hadoop.hdds.scm.ScmConfigKeys) Arrays(java.util.Arrays) CryptoOutputStream(org.apache.hadoop.crypto.CryptoOutputStream) Text(org.apache.hadoop.io.Text) ServiceInfo(org.apache.hadoop.ozone.om.helpers.ServiceInfo) SecureRandom(java.security.SecureRandom) OmDeleteKeys(org.apache.hadoop.ozone.om.helpers.OmDeleteKeys) OzoneManagerProtocolClientSideTranslatorPB(org.apache.hadoop.ozone.om.protocolPB.OzoneManagerProtocolClientSideTranslatorPB) Map(java.util.Map) LengthInputStream(org.apache.hadoop.ozone.client.io.LengthInputStream) OmRenameKeys(org.apache.hadoop.ozone.om.helpers.OmRenameKeys) XceiverClientFactory(org.apache.hadoop.hdds.scm.XceiverClientFactory) OmBucketInfo(org.apache.hadoop.ozone.om.helpers.OmBucketInfo) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction) OZONE_CLIENT_KEY_PROVIDER_CACHE_EXPIRY_DEFAULT(org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_CLIENT_KEY_PROVIDER_CACHE_EXPIRY_DEFAULT) StorageUnit(org.apache.hadoop.hdds.conf.StorageUnit) ACLType(org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType) ClientId(org.apache.ratis.protocol.ClientId) OzoneOutputStream(org.apache.hadoop.ozone.client.io.OzoneOutputStream) Strings(org.apache.logging.log4j.util.Strings) InvalidKeyException(java.security.InvalidKeyException) OzoneInputStream(org.apache.hadoop.ozone.client.io.OzoneInputStream) OzoneKey(org.apache.hadoop.ozone.client.OzoneKey) OzoneCryptoInputStream(org.apache.hadoop.ozone.client.io.OzoneCryptoInputStream) OmMultipartUploadListParts(org.apache.hadoop.ozone.om.helpers.OmMultipartUploadListParts) GDPRSymmetricKey(org.apache.hadoop.ozone.security.GDPRSymmetricKey) Callable(java.util.concurrent.Callable) S3Auth(org.apache.hadoop.ozone.om.protocol.S3Auth) KeyInputStream(org.apache.hadoop.ozone.client.io.KeyInputStream) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) ACCESS(org.apache.hadoop.ozone.OzoneAcl.AclScope.ACCESS) BucketArgs(org.apache.hadoop.ozone.client.BucketArgs) OLD_QUOTA_DEFAULT(org.apache.hadoop.ozone.OzoneConsts.OLD_QUOTA_DEFAULT) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) OmTransportFactory(org.apache.hadoop.ozone.om.protocolPB.OmTransportFactory) CipherOutputStream(javax.crypto.CipherOutputStream) OZONE_OM_CLIENT_PROTOCOL_VERSION_KEY(org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_OM_CLIENT_PROTOCOL_VERSION_KEY) OmMultipartInfo(org.apache.hadoop.ozone.om.helpers.OmMultipartInfo) OpenKeySession(org.apache.hadoop.ozone.om.helpers.OpenKeySession) ReplicationConfig(org.apache.hadoop.hdds.client.ReplicationConfig) DatanodeDetails(org.apache.hadoop.hdds.protocol.DatanodeDetails) IOException(java.io.IOException) BucketEncryptionKeyInfo(org.apache.hadoop.ozone.om.helpers.BucketEncryptionKeyInfo) OzoneConsts(org.apache.hadoop.ozone.OzoneConsts) Token(org.apache.hadoop.security.token.Token) FileEncryptionInfo(org.apache.hadoop.fs.FileEncryptionInfo) KeyOutputStream(org.apache.hadoop.ozone.client.io.KeyOutputStream) OmPartInfo(org.apache.hadoop.ozone.om.helpers.OmPartInfo) PipelineID(org.apache.hadoop.hdds.scm.pipeline.PipelineID) Preconditions(com.google.common.base.Preconditions) RemovalListener(com.google.common.cache.RemovalListener) ACLIdentityType(org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLIdentityType) X509Certificate(java.security.cert.X509Certificate) HddsProtos(org.apache.hadoop.hdds.protocol.proto.HddsProtos) OmMultipartUploadCompleteList(org.apache.hadoop.ozone.om.helpers.OmMultipartUploadCompleteList) OzoneManagerProtocol(org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol) LoggerFactory(org.slf4j.LoggerFactory) OzoneManagerClientProtocol(org.apache.hadoop.ozone.om.protocolPB.OzoneManagerClientProtocol) OzoneMultipartUploadList(org.apache.hadoop.ozone.client.OzoneMultipartUploadList) OmKeyArgs(org.apache.hadoop.ozone.om.helpers.OmKeyArgs) OzoneClientConfig(org.apache.hadoop.hdds.scm.OzoneClientConfig) OzoneKeyLocation(org.apache.hadoop.ozone.client.OzoneKeyLocation) ConfigurationSource(org.apache.hadoop.hdds.conf.ConfigurationSource) MultipartCryptoKeyInputStream(org.apache.hadoop.ozone.client.io.MultipartCryptoKeyInputStream) OzoneFileStatus(org.apache.hadoop.ozone.om.helpers.OzoneFileStatus) OzoneVolume(org.apache.hadoop.ozone.client.OzoneVolume) URI(java.net.URI) VolumeArgs(org.apache.hadoop.ozone.client.VolumeArgs) OzoneTokenIdentifier(org.apache.hadoop.ozone.security.OzoneTokenIdentifier) OzoneAcl(org.apache.hadoop.ozone.OzoneAcl) XceiverClientManager(org.apache.hadoop.hdds.scm.XceiverClientManager) OzoneMultipartUpload(org.apache.hadoop.ozone.client.OzoneMultipartUpload) UUID(java.util.UUID) OzoneSecurityUtil(org.apache.hadoop.ozone.OzoneSecurityUtil) Collectors(java.util.stream.Collectors) ReplicationType(org.apache.hadoop.hdds.client.ReplicationType) ComparableVersion(org.apache.hadoop.util.ComparableVersion) List(java.util.List) IOUtils(org.apache.hadoop.hdds.utils.IOUtils) OMException(org.apache.hadoop.ozone.om.exceptions.OMException) OmMultipartUploadCompleteInfo(org.apache.hadoop.ozone.om.helpers.OmMultipartUploadCompleteInfo) OzoneObj(org.apache.hadoop.ozone.security.acl.OzoneObj) OzoneConfigKeys(org.apache.hadoop.ozone.OzoneConfigKeys) ServiceInfoEx(org.apache.hadoop.ozone.om.helpers.ServiceInfoEx) CacheBuilder(com.google.common.cache.CacheBuilder) NotNull(org.jetbrains.annotations.NotNull) StorageType(org.apache.hadoop.hdds.protocol.StorageType) OmTransport(org.apache.hadoop.ozone.om.protocolPB.OmTransport) ClientProtocol(org.apache.hadoop.ozone.client.protocol.ClientProtocol) HashMap(java.util.HashMap) Cipher(javax.crypto.Cipher) Function(java.util.function.Function) CipherInputStream(javax.crypto.CipherInputStream) OzoneBucket(org.apache.hadoop.ozone.client.OzoneBucket) OmMultipartUploadList(org.apache.hadoop.ozone.om.helpers.OmMultipartUploadList) OmKeyInfo(org.apache.hadoop.ozone.om.helpers.OmKeyInfo) OmKeyLocationInfo(org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo) OzoneKeyDetails(org.apache.hadoop.ozone.client.OzoneKeyDetails) S3SecretValue(org.apache.hadoop.ozone.om.helpers.S3SecretValue) Nonnull(javax.annotation.Nonnull) OMConfigKeys(org.apache.hadoop.ozone.om.OMConfigKeys) OzoneAclUtil(org.apache.hadoop.ozone.om.helpers.OzoneAclUtil) OmBucketArgs(org.apache.hadoop.ozone.om.helpers.OmBucketArgs) RemovalNotification(com.google.common.cache.RemovalNotification) Logger(org.slf4j.Logger) OzoneAclConfig(org.apache.hadoop.ozone.security.acl.OzoneAclConfig) Pipeline(org.apache.hadoop.hdds.scm.pipeline.Pipeline) OZONE_CLIENT_KEY_PROVIDER_CACHE_EXPIRY(org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_CLIENT_KEY_PROVIDER_CACHE_EXPIRY) ReplicationFactor(org.apache.hadoop.hdds.client.ReplicationFactor) OmVolumeArgs(org.apache.hadoop.ozone.om.helpers.OmVolumeArgs) TimeUnit(java.util.concurrent.TimeUnit) KeyProvider(org.apache.hadoop.crypto.key.KeyProvider) RepeatedOmKeyInfo(org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo) TracingUtil(org.apache.hadoop.hdds.tracing.TracingUtil) OmKeyLocationInfoGroup(org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfoGroup) HddsClientUtils(org.apache.hadoop.hdds.scm.client.HddsClientUtils) OMRoleInfo(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRoleInfo) OzoneMultipartUploadPartListParts(org.apache.hadoop.ozone.client.OzoneMultipartUploadPartListParts) VisibleForTesting(com.google.common.annotations.VisibleForTesting) CryptoInputStream(org.apache.hadoop.crypto.CryptoInputStream) Cache(com.google.common.cache.Cache) Collections(java.util.Collections) OzoneMultipartUploadList(org.apache.hadoop.ozone.client.OzoneMultipartUploadList) OmMultipartUploadList(org.apache.hadoop.ozone.om.helpers.OmMultipartUploadList) OzoneMultipartUpload(org.apache.hadoop.ozone.client.OzoneMultipartUpload)

Aggregations

ArrayList (java.util.ArrayList)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Preconditions (com.google.common.base.Preconditions)1 Cache (com.google.common.cache.Cache)1 CacheBuilder (com.google.common.cache.CacheBuilder)1 RemovalListener (com.google.common.cache.RemovalListener)1 RemovalNotification (com.google.common.cache.RemovalNotification)1 IOException (java.io.IOException)1 URI (java.net.URI)1 InvalidKeyException (java.security.InvalidKeyException)1 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)1 SecureRandom (java.security.SecureRandom)1 X509Certificate (java.security.cert.X509Certificate)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 UUID (java.util.UUID)1