Search in sources :

Example 1 with OmMultipartUploadListParts

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

the class RpcClient method listParts.

@Override
public OzoneMultipartUploadPartListParts listParts(String volumeName, String bucketName, String keyName, String uploadID, int partNumberMarker, int maxParts) throws IOException {
    verifyVolumeName(volumeName);
    verifyBucketName(bucketName);
    HddsClientUtils.checkNotNull(uploadID);
    Preconditions.checkArgument(maxParts > 0, "Max Parts Should be greater " + "than zero");
    Preconditions.checkArgument(partNumberMarker >= 0, "Part Number Marker " + "Should be greater than or equal to zero, as part numbers starts from" + " 1 and ranges till 10000");
    OmMultipartUploadListParts omMultipartUploadListParts = ozoneManagerClient.listParts(volumeName, bucketName, keyName, uploadID, partNumberMarker, maxParts);
    OzoneMultipartUploadPartListParts ozoneMultipartUploadPartListParts = new OzoneMultipartUploadPartListParts(omMultipartUploadListParts.getReplicationConfig(), omMultipartUploadListParts.getNextPartNumberMarker(), omMultipartUploadListParts.isTruncated());
    for (OmPartInfo omPartInfo : omMultipartUploadListParts.getPartInfoList()) {
        ozoneMultipartUploadPartListParts.addPart(new OzoneMultipartUploadPartListParts.PartInfo(omPartInfo.getPartNumber(), omPartInfo.getPartName(), omPartInfo.getModificationTime(), omPartInfo.getSize()));
    }
    return ozoneMultipartUploadPartListParts;
}
Also used : OzoneMultipartUploadPartListParts(org.apache.hadoop.ozone.client.OzoneMultipartUploadPartListParts) OmMultipartUploadListParts(org.apache.hadoop.ozone.om.helpers.OmMultipartUploadListParts) OmPartInfo(org.apache.hadoop.ozone.om.helpers.OmPartInfo)

Example 2 with OmMultipartUploadListParts

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

the class TestKeyManagerUnit method listMultipartUploadPartsWithZeroUpload.

@Test
public void listMultipartUploadPartsWithZeroUpload() throws IOException {
    // GIVEN
    createBucket(metadataManager, "vol1", "bucket1");
    OmMultipartInfo omMultipartInfo = initMultipartUpload(writeClient, "vol1", "bucket1", "dir/key1");
    // WHEN
    OmMultipartUploadListParts omMultipartUploadListParts = keyManager.listParts("vol1", "bucket1", "dir/key1", omMultipartInfo.getUploadID(), 0, 10);
    Assert.assertEquals(0, omMultipartUploadListParts.getPartInfoList().size());
}
Also used : OmMultipartUploadListParts(org.apache.hadoop.ozone.om.helpers.OmMultipartUploadListParts) OmMultipartInfo(org.apache.hadoop.ozone.om.helpers.OmMultipartInfo) Test(org.junit.Test)

Example 3 with OmMultipartUploadListParts

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

the class OzoneManager method listParts.

@Override
public OmMultipartUploadListParts listParts(final String volumeName, final String bucketName, String keyName, String uploadID, int partNumberMarker, int maxParts) throws IOException {
    ResolvedBucket bucket = resolveBucketLink(Pair.of(volumeName, bucketName));
    Map<String, String> auditMap = bucket.audit();
    auditMap.put(OzoneConsts.KEY, keyName);
    auditMap.put(OzoneConsts.UPLOAD_ID, uploadID);
    auditMap.put(OzoneConsts.PART_NUMBER_MARKER, Integer.toString(partNumberMarker));
    auditMap.put(OzoneConsts.MAX_PARTS, Integer.toString(maxParts));
    metrics.incNumListMultipartUploadParts();
    try {
        OmMultipartUploadListParts omMultipartUploadListParts = keyManager.listParts(bucket.realVolume(), bucket.realBucket(), keyName, uploadID, partNumberMarker, maxParts);
        AUDIT.logWriteSuccess(buildAuditMessageForSuccess(OMAction.LIST_MULTIPART_UPLOAD_PARTS, auditMap));
        return omMultipartUploadListParts;
    } catch (IOException ex) {
        metrics.incNumListMultipartUploadPartFails();
        AUDIT.logWriteFailure(buildAuditMessageForFailure(OMAction.LIST_MULTIPART_UPLOAD_PARTS, auditMap, ex));
        throw ex;
    }
}
Also used : OmMultipartUploadListParts(org.apache.hadoop.ozone.om.helpers.OmMultipartUploadListParts) CertificateSignRequest.getEncodedString(org.apache.hadoop.hdds.security.x509.certificates.utils.CertificateSignRequest.getEncodedString) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException)

Example 4 with OmMultipartUploadListParts

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

the class OzoneManagerRequestHandler method listParts.

private MultipartUploadListPartsResponse listParts(MultipartUploadListPartsRequest multipartUploadListPartsRequest) throws IOException {
    MultipartUploadListPartsResponse.Builder response = MultipartUploadListPartsResponse.newBuilder();
    OmMultipartUploadListParts omMultipartUploadListParts = impl.listParts(multipartUploadListPartsRequest.getVolume(), multipartUploadListPartsRequest.getBucket(), multipartUploadListPartsRequest.getKey(), multipartUploadListPartsRequest.getUploadID(), multipartUploadListPartsRequest.getPartNumbermarker(), multipartUploadListPartsRequest.getMaxParts());
    List<OmPartInfo> omPartInfoList = omMultipartUploadListParts.getPartInfoList();
    List<PartInfo> partInfoList = new ArrayList<>();
    omPartInfoList.forEach(partInfo -> partInfoList.add(partInfo.getProto()));
    response.setType(omMultipartUploadListParts.getReplicationConfig().getReplicationType());
    response.setFactor(ReplicationConfig.getLegacyFactor(omMultipartUploadListParts.getReplicationConfig()));
    response.setNextPartNumberMarker(omMultipartUploadListParts.getNextPartNumberMarker());
    response.setIsTruncated(omMultipartUploadListParts.isTruncated());
    return response.addAllPartsList(partInfoList).build();
}
Also used : OmMultipartUploadListParts(org.apache.hadoop.ozone.om.helpers.OmMultipartUploadListParts) ArrayList(java.util.ArrayList) MultipartUploadListPartsResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.MultipartUploadListPartsResponse) PartInfo(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.PartInfo) OmPartInfo(org.apache.hadoop.ozone.om.helpers.OmPartInfo) OmPartInfo(org.apache.hadoop.ozone.om.helpers.OmPartInfo)

Example 5 with OmMultipartUploadListParts

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

the class OzoneManagerProtocolClientSideTranslatorPB method listParts.

@Override
public OmMultipartUploadListParts listParts(String volumeName, String bucketName, String keyName, String uploadID, int partNumberMarker, int maxParts) throws IOException {
    MultipartUploadListPartsRequest.Builder multipartUploadListPartsRequest = MultipartUploadListPartsRequest.newBuilder();
    multipartUploadListPartsRequest.setVolume(volumeName).setBucket(bucketName).setKey(keyName).setUploadID(uploadID).setPartNumbermarker(partNumberMarker).setMaxParts(maxParts);
    OMRequest omRequest = createOMRequest(Type.ListMultiPartUploadParts).setListMultipartUploadPartsRequest(multipartUploadListPartsRequest.build()).build();
    MultipartUploadListPartsResponse response = handleError(submitRequest(omRequest)).getListMultipartUploadPartsResponse();
    OmMultipartUploadListParts omMultipartUploadListParts = new OmMultipartUploadListParts(ReplicationConfig.fromProtoTypeAndFactor(response.getType(), response.getFactor()), response.getNextPartNumberMarker(), response.getIsTruncated());
    omMultipartUploadListParts.addProtoPartList(response.getPartsListList());
    return omMultipartUploadListParts;
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) MultipartUploadListPartsRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.MultipartUploadListPartsRequest) OmMultipartUploadListParts(org.apache.hadoop.ozone.om.helpers.OmMultipartUploadListParts) MultipartUploadListPartsResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.MultipartUploadListPartsResponse)

Aggregations

OmMultipartUploadListParts (org.apache.hadoop.ozone.om.helpers.OmMultipartUploadListParts)6 OmPartInfo (org.apache.hadoop.ozone.om.helpers.OmPartInfo)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 MultipartUploadListPartsResponse (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.MultipartUploadListPartsResponse)2 UncheckedIOException (java.io.UncheckedIOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 RatisReplicationConfig (org.apache.hadoop.hdds.client.RatisReplicationConfig)1 ReplicationConfig (org.apache.hadoop.hdds.client.ReplicationConfig)1 CertificateSignRequest.getEncodedString (org.apache.hadoop.hdds.security.x509.certificates.utils.CertificateSignRequest.getEncodedString)1 OzoneMultipartUploadPartListParts (org.apache.hadoop.ozone.client.OzoneMultipartUploadPartListParts)1 OMException (org.apache.hadoop.ozone.om.exceptions.OMException)1 BucketLayout (org.apache.hadoop.ozone.om.helpers.BucketLayout)1 OmBucketInfo (org.apache.hadoop.ozone.om.helpers.OmBucketInfo)1 OmKeyInfo (org.apache.hadoop.ozone.om.helpers.OmKeyInfo)1 OmMultipartInfo (org.apache.hadoop.ozone.om.helpers.OmMultipartInfo)1 OmMultipartKeyInfo (org.apache.hadoop.ozone.om.helpers.OmMultipartKeyInfo)1 RepeatedOmKeyInfo (org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo)1