Search in sources :

Example 1 with OmMultipartUpload

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

the class TestKeyManagerUnit method listMultipartUploadsWithPrefix.

@Test
public void listMultipartUploadsWithPrefix() throws IOException {
    // GIVEN
    createBucket(metadataManager, "vol1", "bucket1");
    createBucket(metadataManager, "vol1", "bucket2");
    initMultipartUpload(writeClient, "vol1", "bucket1", "dip/key1");
    initMultipartUpload(writeClient, "vol1", "bucket1", "dir/key1");
    initMultipartUpload(writeClient, "vol1", "bucket1", "dir/key2");
    initMultipartUpload(writeClient, "vol1", "bucket1", "key3");
    initMultipartUpload(writeClient, "vol1", "bucket2", "dir/key1");
    // WHEN
    OmMultipartUploadList omMultipartUploadList = keyManager.listMultipartUploads("vol1", "bucket1", "dir");
    // THEN
    List<OmMultipartUpload> uploads = omMultipartUploadList.getUploads();
    Assert.assertEquals(2, uploads.size());
    Assert.assertEquals("dir/key1", uploads.get(0).getKeyName());
    Assert.assertEquals("dir/key2", uploads.get(1).getKeyName());
}
Also used : OmMultipartUpload(org.apache.hadoop.ozone.om.helpers.OmMultipartUpload) OmMultipartUploadList(org.apache.hadoop.ozone.om.helpers.OmMultipartUploadList) Test(org.junit.Test)

Example 2 with OmMultipartUpload

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

the class TestKeyManagerUnit method listMultipartUploadsWithFewEntriesInCache.

@Test
public void listMultipartUploadsWithFewEntriesInCache() throws IOException {
    String volume = UUID.randomUUID().toString();
    String bucket = UUID.randomUUID().toString();
    // GIVEN
    createBucket(metadataManager, volume, bucket);
    createBucket(metadataManager, volume, bucket);
    // Add few to cache and few to DB.
    addinitMultipartUploadToCache(volume, bucket, "dir/key1");
    initMultipartUpload(writeClient, volume, bucket, "dir/key2");
    addinitMultipartUploadToCache(volume, bucket, "dir/key3");
    initMultipartUpload(writeClient, volume, bucket, "dir/key4");
    // WHEN
    OmMultipartUploadList omMultipartUploadList = keyManager.listMultipartUploads(volume, bucket, "");
    // THEN
    List<OmMultipartUpload> uploads = omMultipartUploadList.getUploads();
    Assert.assertEquals(4, uploads.size());
    Assert.assertEquals("dir/key1", uploads.get(0).getKeyName());
    Assert.assertEquals("dir/key2", uploads.get(1).getKeyName());
    Assert.assertEquals("dir/key3", uploads.get(2).getKeyName());
    Assert.assertEquals("dir/key4", uploads.get(3).getKeyName());
    // Add few more to test prefix.
    // Same way add few to cache and few to DB.
    addinitMultipartUploadToCache(volume, bucket, "dir/ozonekey1");
    initMultipartUpload(writeClient, volume, bucket, "dir/ozonekey2");
    OmMultipartInfo omMultipartInfo3 = addinitMultipartUploadToCache(volume, bucket, "dir/ozonekey3");
    OmMultipartInfo omMultipartInfo4 = initMultipartUpload(writeClient, volume, bucket, "dir/ozonekey4");
    omMultipartUploadList = keyManager.listMultipartUploads(volume, bucket, "dir/ozone");
    // THEN
    uploads = omMultipartUploadList.getUploads();
    Assert.assertEquals(4, uploads.size());
    Assert.assertEquals("dir/ozonekey1", uploads.get(0).getKeyName());
    Assert.assertEquals("dir/ozonekey2", uploads.get(1).getKeyName());
    Assert.assertEquals("dir/ozonekey3", uploads.get(2).getKeyName());
    Assert.assertEquals("dir/ozonekey4", uploads.get(3).getKeyName());
    // Abort multipart upload for key in DB.
    abortMultipart(volume, bucket, "dir/ozonekey4", omMultipartInfo4.getUploadID());
    // Now list.
    omMultipartUploadList = keyManager.listMultipartUploads(volume, bucket, "dir/ozone");
    // THEN
    uploads = omMultipartUploadList.getUploads();
    Assert.assertEquals(3, uploads.size());
    Assert.assertEquals("dir/ozonekey1", uploads.get(0).getKeyName());
    Assert.assertEquals("dir/ozonekey2", uploads.get(1).getKeyName());
    Assert.assertEquals("dir/ozonekey3", uploads.get(2).getKeyName());
    // abort multipart upload for key in cache.
    abortMultipart(volume, bucket, "dir/ozonekey3", omMultipartInfo3.getUploadID());
    // Now list.
    omMultipartUploadList = keyManager.listMultipartUploads(volume, bucket, "dir/ozone");
    // THEN
    uploads = omMultipartUploadList.getUploads();
    Assert.assertEquals(2, uploads.size());
    Assert.assertEquals("dir/ozonekey1", uploads.get(0).getKeyName());
    Assert.assertEquals("dir/ozonekey2", uploads.get(1).getKeyName());
}
Also used : OmMultipartUpload(org.apache.hadoop.ozone.om.helpers.OmMultipartUpload) OmMultipartUploadList(org.apache.hadoop.ozone.om.helpers.OmMultipartUploadList) OmMultipartInfo(org.apache.hadoop.ozone.om.helpers.OmMultipartInfo) Test(org.junit.Test)

Example 3 with OmMultipartUpload

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

the class OzoneManagerProtocolClientSideTranslatorPB method listMultipartUploads.

@Override
public OmMultipartUploadList listMultipartUploads(String volumeName, String bucketName, String prefix) throws IOException {
    ListMultipartUploadsRequest request = ListMultipartUploadsRequest.newBuilder().setVolume(volumeName).setBucket(bucketName).setPrefix(prefix == null ? "" : prefix).build();
    OMRequest omRequest = createOMRequest(Type.ListMultipartUploads).setListMultipartUploadsRequest(request).build();
    ListMultipartUploadsResponse listMultipartUploadsResponse = handleError(submitRequest(omRequest)).getListMultipartUploadsResponse();
    List<OmMultipartUpload> uploadList = listMultipartUploadsResponse.getUploadsListList().stream().map(proto -> new OmMultipartUpload(proto.getVolumeName(), proto.getBucketName(), proto.getKeyName(), proto.getUploadId(), Instant.ofEpochMilli(proto.getCreationTime()), ReplicationConfig.fromProtoTypeAndFactor(proto.getType(), proto.getFactor()))).collect(Collectors.toList());
    OmMultipartUploadList response = new OmMultipartUploadList(uploadList);
    return response;
}
Also used : ListMultipartUploadsResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListMultipartUploadsResponse) GetDelegationTokenResponseProto(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.GetDelegationTokenResponseProto) 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) 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) GetFileStatusRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.GetFileStatusRequest) Map(java.util.Map) DBUpdates(org.apache.hadoop.ozone.om.helpers.DBUpdates) GetS3SecretResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.GetS3SecretResponse) 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) SetBucketPropertyRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.SetBucketPropertyRequest) 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) 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) OzoneAclInfo(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OzoneAclInfo) MultipartInfoInitiateResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.MultipartInfoInitiateResponse) ListBucketsResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListBucketsResponse) 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) OmMultipartUploadListParts(org.apache.hadoop.ozone.om.helpers.OmMultipartUploadListParts) SetVolumePropertyResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.SetVolumePropertyResponse) 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) OpenKeySession(org.apache.hadoop.ozone.om.helpers.OpenKeySession) ReplicationConfig(org.apache.hadoop.hdds.client.ReplicationConfig) IOException(java.io.IOException) 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) 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) RenewDelegationTokenRequestProto(org.apache.hadoop.ozone.security.proto.SecurityProtos.RenewDelegationTokenRequestProto) RenameKeysArgs(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RenameKeysArgs) Preconditions(com.google.common.base.Preconditions) 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) 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) OzoneTokenIdentifier(org.apache.hadoop.ozone.security.OzoneTokenIdentifier) OzoneAcl(org.apache.hadoop.ozone.OzoneAcl) OmMultipartUpload(org.apache.hadoop.ozone.om.helpers.OmMultipartUpload) 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) 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) 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) CreateKeyResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateKeyResponse) PrepareStatusRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.PrepareStatusRequest) CURRENT_VERSION(org.apache.hadoop.ozone.ClientVersions.CURRENT_VERSION) 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) 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) OmMultipartUpload(org.apache.hadoop.ozone.om.helpers.OmMultipartUpload) OmMultipartUploadList(org.apache.hadoop.ozone.om.helpers.OmMultipartUploadList) ListMultipartUploadsRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListMultipartUploadsRequest)

Example 4 with OmMultipartUpload

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

the class TestKeyManagerUnit method listMultipartUploads.

@Test
public void listMultipartUploads() throws IOException {
    // GIVEN
    createBucket(metadataManager, "vol1", "bucket1");
    createBucket(metadataManager, "vol1", "bucket2");
    initMultipartUpload(writeClient, "vol1", "bucket1", "dir/key1");
    initMultipartUpload(writeClient, "vol1", "bucket1", "dir/key2");
    initMultipartUpload(writeClient, "vol1", "bucket2", "dir/key1");
    // WHEN
    OmMultipartUploadList omMultipartUploadList = keyManager.listMultipartUploads("vol1", "bucket1", "");
    // THEN
    List<OmMultipartUpload> uploads = omMultipartUploadList.getUploads();
    Assert.assertEquals(2, uploads.size());
    Assert.assertEquals("dir/key1", uploads.get(0).getKeyName());
    Assert.assertEquals("dir/key2", uploads.get(1).getKeyName());
    Assert.assertNotNull(uploads.get(1));
    Instant creationTime = uploads.get(1).getCreationTime();
    Assert.assertNotNull(creationTime);
    Assert.assertFalse("Creation date is too old: " + creationTime + " < " + startDate, creationTime.isBefore(startDate));
}
Also used : Instant(java.time.Instant) OmMultipartUpload(org.apache.hadoop.ozone.om.helpers.OmMultipartUpload) OmMultipartUploadList(org.apache.hadoop.ozone.om.helpers.OmMultipartUploadList) Test(org.junit.Test)

Example 5 with OmMultipartUpload

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

the class KeyManagerImpl method listMultipartUploads.

@Override
public OmMultipartUploadList listMultipartUploads(String volumeName, String bucketName, String prefix) throws OMException {
    Preconditions.checkNotNull(volumeName);
    Preconditions.checkNotNull(bucketName);
    metadataManager.getLock().acquireReadLock(BUCKET_LOCK, volumeName, bucketName);
    try {
        Set<String> multipartUploadKeys = metadataManager.getMultipartUploadKeys(volumeName, bucketName, prefix);
        List<OmMultipartUpload> collect = multipartUploadKeys.stream().map(OmMultipartUpload::from).peek(upload -> {
            try {
                Table<String, OmMultipartKeyInfo> keyInfoTable = metadataManager.getMultipartInfoTable();
                OmMultipartKeyInfo multipartKeyInfo = keyInfoTable.get(upload.getDbKey());
                upload.setCreationTime(Instant.ofEpochMilli(multipartKeyInfo.getCreationTime()));
                upload.setReplicationConfig(multipartKeyInfo.getReplicationConfig());
            } catch (IOException e) {
                LOG.warn("Open key entry for multipart upload record can be read  {}", metadataManager.getOzoneKey(upload.getVolumeName(), upload.getBucketName(), upload.getKeyName()));
            }
        }).collect(Collectors.toList());
        return new OmMultipartUploadList(collect);
    } catch (IOException ex) {
        LOG.error("List Multipart Uploads Failed: volume: " + volumeName + "bucket: " + bucketName + "prefix: " + prefix, ex);
        throw new OMException(ex.getMessage(), ResultCodes.LIST_MULTIPART_UPLOAD_PARTS_FAILED);
    } finally {
        metadataManager.getLock().releaseReadLock(BUCKET_LOCK, volumeName, bucketName);
    }
}
Also used : Arrays(java.util.Arrays) INTERNAL_ERROR(org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.INTERNAL_ERROR) OzoneFSUtils(org.apache.hadoop.ozone.om.helpers.OzoneFSUtils) StringUtils(org.apache.commons.lang3.StringUtils) GeneralSecurityException(java.security.GeneralSecurityException) OM_KEY_PREFIX(org.apache.hadoop.ozone.OzoneConsts.OM_KEY_PREFIX) HADOOP_SECURITY_KEY_PROVIDER_PATH(org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_SECURITY_KEY_PROVIDER_PATH) Map(java.util.Map) Path(java.nio.file.Path) EnumSet(java.util.EnumSet) OmBucketInfo(org.apache.hadoop.ozone.om.helpers.OmBucketInfo) DFS_CONTAINER_RATIS_ENABLED_DEFAULT(org.apache.hadoop.ozone.OzoneConfigKeys.DFS_CONTAINER_RATIS_ENABLED_DEFAULT) Set(java.util.Set) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction) SecurityUtil(org.apache.hadoop.security.SecurityUtil) OzoneBlockTokenSecretManager(org.apache.hadoop.ozone.security.OzoneBlockTokenSecretManager) VOLUME_NOT_FOUND(org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.VOLUME_NOT_FOUND) CodecRegistry(org.apache.hadoop.hdds.utils.db.CodecRegistry) HDDS_BLOCK_TOKEN_ENABLED(org.apache.hadoop.hdds.HddsConfigKeys.HDDS_BLOCK_TOKEN_ENABLED) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) OZONE_URI_DELIMITER(org.apache.hadoop.ozone.OzoneConsts.OZONE_URI_DELIMITER) OmMultipartUploadListParts(org.apache.hadoop.ozone.om.helpers.OmMultipartUploadListParts) OZONE_BLOCK_DELETING_SERVICE_TIMEOUT_DEFAULT(org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_BLOCK_DELETING_SERVICE_TIMEOUT_DEFAULT) INVALID_KMS_PROVIDER(org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.INVALID_KMS_PROVIDER) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) Time.monotonicNow(org.apache.hadoop.util.Time.monotonicNow) EncryptedKeyVersion(org.apache.hadoop.crypto.key.KeyProviderCryptoExtension.EncryptedKeyVersion) Strings(com.google.common.base.Strings) OMFileRequest(org.apache.hadoop.ozone.om.request.file.OMFileRequest) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) KeyProviderCryptoExtension(org.apache.hadoop.crypto.key.KeyProviderCryptoExtension) OmDirectoryInfo(org.apache.hadoop.ozone.om.helpers.OmDirectoryInfo) OZONE_BLOCK_DELETING_SERVICE_INTERVAL_DEFAULT(org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_BLOCK_DELETING_SERVICE_INTERVAL_DEFAULT) ContainerWithPipeline(org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline) BlockGroup(org.apache.hadoop.ozone.common.BlockGroup) 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) OZONE_BLOCK_DELETING_SERVICE_INTERVAL(org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_BLOCK_DELETING_SERVICE_INTERVAL) FileEncryptionInfo(org.apache.hadoop.fs.FileEncryptionInfo) TreeMap(java.util.TreeMap) OZONE_SCM_BLOCK_SIZE_DEFAULT(org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_SCM_BLOCK_SIZE_DEFAULT) DIRECTORY_NOT_FOUND(org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.DIRECTORY_NOT_FOUND) Paths(java.nio.file.Paths) Table(org.apache.hadoop.hdds.utils.db.Table) CacheKey(org.apache.hadoop.hdds.utils.db.cache.CacheKey) OmPartInfo(org.apache.hadoop.ozone.om.helpers.OmPartInfo) READ(org.apache.hadoop.hdds.protocol.proto.HddsProtos.BlockTokenSecretProto.AccessModeProto.READ) Preconditions(com.google.common.base.Preconditions) TableIterator(org.apache.hadoop.hdds.utils.db.TableIterator) OmMultipartKeyInfo(org.apache.hadoop.ozone.om.helpers.OmMultipartKeyInfo) RequestContext(org.apache.hadoop.ozone.security.acl.RequestContext) LoggerFactory(org.slf4j.LoggerFactory) OmKeyArgs(org.apache.hadoop.ozone.om.helpers.OmKeyArgs) ScmBlockLocationProtocol(org.apache.hadoop.hdds.scm.protocol.ScmBlockLocationProtocol) OZONE_SCM_BLOCK_SIZE(org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_SCM_BLOCK_SIZE) KEY_NOT_FOUND(org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.KEY_NOT_FOUND) OZONE_BLOCK_DELETING_SERVICE_TIMEOUT(org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_BLOCK_DELETING_SERVICE_TIMEOUT) OzoneFileStatus(org.apache.hadoop.ozone.om.helpers.OzoneFileStatus) BucketLayout(org.apache.hadoop.ozone.om.helpers.BucketLayout) CacheValue(org.apache.hadoop.hdds.utils.db.cache.CacheValue) OzoneAcl(org.apache.hadoop.ozone.OzoneAcl) OmMultipartUpload(org.apache.hadoop.ozone.om.helpers.OmMultipartUpload) StorageUnit(org.apache.hadoop.conf.StorageUnit) RatisReplicationConfig(org.apache.hadoop.hdds.client.RatisReplicationConfig) Collection(java.util.Collection) ReplicationFactor(org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor) FILE_NOT_FOUND(org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.FILE_NOT_FOUND) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) OMException(org.apache.hadoop.ozone.om.exceptions.OMException) BUCKET_NOT_FOUND(org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.BUCKET_NOT_FOUND) OZONE_KEY_PREALLOCATION_BLOCKS_MAX(org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_KEY_PREALLOCATION_BLOCKS_MAX) OMClientRequest(org.apache.hadoop.ozone.om.request.OMClientRequest) OzoneObj(org.apache.hadoop.ozone.security.acl.OzoneObj) RDBStore(org.apache.hadoop.hdds.utils.db.RDBStore) OZONE_DIR_DELETING_SERVICE_INTERVAL(org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_DIR_DELETING_SERVICE_INTERVAL) OZONE_DIR_DELETING_SERVICE_INTERVAL_DEFAULT(org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_DIR_DELETING_SERVICE_INTERVAL_DEFAULT) HashMap(java.util.HashMap) BackgroundService(org.apache.hadoop.hdds.utils.BackgroundService) OZONE_CLIENT_LIST_TRASH_KEYS_MAX(org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_CLIENT_LIST_TRASH_KEYS_MAX) OmUtils(org.apache.hadoop.ozone.OmUtils) Stack(java.util.Stack) ResultCodes(org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes) OZONE_KEY_PREALLOCATION_BLOCKS_MAX_DEFAULT(org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_KEY_PREALLOCATION_BLOCKS_MAX_DEFAULT) HashSet(java.util.HashSet) PartKeyInfo(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.PartKeyInfo) OmMultipartUploadList(org.apache.hadoop.ozone.om.helpers.OmMultipartUploadList) OmKeyInfo(org.apache.hadoop.ozone.om.helpers.OmKeyInfo) OmKeyLocationInfo(org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo) OzoneAclUtil(org.apache.hadoop.ozone.om.helpers.OzoneAclUtil) Server(org.apache.hadoop.ipc.Server) HDDS_BLOCK_TOKEN_ENABLED_DEFAULT(org.apache.hadoop.hdds.HddsConfigKeys.HDDS_BLOCK_TOKEN_ENABLED_DEFAULT) DFS_CONTAINER_RATIS_ENABLED_KEY(org.apache.hadoop.ozone.OzoneConfigKeys.DFS_CONTAINER_RATIS_ENABLED_KEY) BUCKET_LOCK(org.apache.hadoop.ozone.om.lock.OzoneManagerLock.Resource.BUCKET_LOCK) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) SCM_GET_PIPELINE_EXCEPTION(org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.SCM_GET_PIPELINE_EXCEPTION) Pipeline(org.apache.hadoop.hdds.scm.pipeline.Pipeline) TimeUnit(java.util.concurrent.TimeUnit) KEY(org.apache.hadoop.ozone.security.acl.OzoneObj.ResourceType.KEY) RepeatedOmKeyInfo(org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo) OmKeyLocationInfoGroup(org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfoGroup) IAccessAuthorizer(org.apache.hadoop.ozone.security.acl.IAccessAuthorizer) StorageContainerLocationProtocol(org.apache.hadoop.hdds.scm.protocol.StorageContainerLocationProtocol) OZONE_CLIENT_LIST_TRASH_KEYS_MAX_DEFAULT(org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_CLIENT_LIST_TRASH_KEYS_MAX_DEFAULT) Time(org.apache.hadoop.util.Time) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Collections(java.util.Collections) Table(org.apache.hadoop.hdds.utils.db.Table) OmMultipartKeyInfo(org.apache.hadoop.ozone.om.helpers.OmMultipartKeyInfo) OmMultipartUpload(org.apache.hadoop.ozone.om.helpers.OmMultipartUpload) OmMultipartUploadList(org.apache.hadoop.ozone.om.helpers.OmMultipartUploadList) IOException(java.io.IOException) OMException(org.apache.hadoop.ozone.om.exceptions.OMException)

Aggregations

OmMultipartUpload (org.apache.hadoop.ozone.om.helpers.OmMultipartUpload)5 OmMultipartUploadList (org.apache.hadoop.ozone.om.helpers.OmMultipartUploadList)5 Instant (java.time.Instant)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 Preconditions (com.google.common.base.Preconditions)2 Strings (com.google.common.base.Strings)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 ReplicationConfig (org.apache.hadoop.hdds.client.ReplicationConfig)2 OmMultipartInfo (org.apache.hadoop.ozone.om.helpers.OmMultipartInfo)2 Test (org.junit.Test)2 ByteString (com.google.protobuf.ByteString)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 GeneralSecurityException (java.security.GeneralSecurityException)1 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)1 Arrays (java.util.Arrays)1