Search in sources :

Example 1 with OzoneMultipartUploadPartListParts

use of org.apache.hadoop.ozone.client.OzoneMultipartUploadPartListParts 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 OzoneMultipartUploadPartListParts

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

the class TestOzoneManagerHAWithData method validateListParts.

/**
 * Validate parts uploaded to a MPU Key.
 * @param ozoneBucket
 * @param keyName
 * @param uploadID
 * @param partsMap
 * @throws Exception
 */
private void validateListParts(OzoneBucket ozoneBucket, String keyName, String uploadID, Map<Integer, String> partsMap) throws Exception {
    OzoneMultipartUploadPartListParts ozoneMultipartUploadPartListParts = ozoneBucket.listParts(keyName, uploadID, 0, 1000);
    List<OzoneMultipartUploadPartListParts.PartInfo> partInfoList = ozoneMultipartUploadPartListParts.getPartInfoList();
    Assert.assertTrue(partInfoList.size() == partsMap.size());
    for (int i = 0; i < partsMap.size(); i++) {
        Assert.assertEquals(partsMap.get(partInfoList.get(i).getPartNumber()), partInfoList.get(i).getPartName());
    }
    Assert.assertFalse(ozoneMultipartUploadPartListParts.isTruncated());
}
Also used : OzoneMultipartUploadPartListParts(org.apache.hadoop.ozone.client.OzoneMultipartUploadPartListParts)

Example 3 with OzoneMultipartUploadPartListParts

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

the class TestOzoneRpcClientAbstract method testListPartsInvalidMaxParts.

@Test
public void testListPartsInvalidMaxParts() throws Exception {
    try {
        String volumeName = UUID.randomUUID().toString();
        String bucketName = UUID.randomUUID().toString();
        String keyName = UUID.randomUUID().toString();
        store.createVolume(volumeName);
        OzoneVolume volume = store.getVolume(volumeName);
        volume.createBucket(bucketName);
        OzoneBucket bucket = volume.getBucket(bucketName);
        OzoneMultipartUploadPartListParts ozoneMultipartUploadPartListParts = bucket.listParts(keyName, "random", 1, -1);
    } catch (IllegalArgumentException ex) {
        GenericTestUtils.assertExceptionContains("Max Parts Should be greater " + "than zero", ex);
    }
}
Also used : OzoneVolume(org.apache.hadoop.ozone.client.OzoneVolume) OzoneBucket(org.apache.hadoop.ozone.client.OzoneBucket) OzoneMultipartUploadPartListParts(org.apache.hadoop.ozone.client.OzoneMultipartUploadPartListParts) Test(org.junit.Test)

Example 4 with OzoneMultipartUploadPartListParts

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

the class TestOzoneRpcClientAbstract method testListMultipartUploadPartsWithContinuation.

@Test
public void testListMultipartUploadPartsWithContinuation() throws Exception {
    String volumeName = UUID.randomUUID().toString();
    String bucketName = UUID.randomUUID().toString();
    String keyName = UUID.randomUUID().toString();
    store.createVolume(volumeName);
    OzoneVolume volume = store.getVolume(volumeName);
    volume.createBucket(bucketName);
    OzoneBucket bucket = volume.getBucket(bucketName);
    Map<Integer, String> partsMap = new TreeMap<>();
    String uploadID = initiateMultipartUpload(bucket, keyName, RATIS, ONE);
    String partName1 = uploadPart(bucket, keyName, uploadID, 1, generateData(OzoneConsts.OM_MULTIPART_MIN_SIZE, (byte) 97));
    partsMap.put(1, partName1);
    String partName2 = uploadPart(bucket, keyName, uploadID, 2, generateData(OzoneConsts.OM_MULTIPART_MIN_SIZE, (byte) 97));
    partsMap.put(2, partName2);
    String partName3 = uploadPart(bucket, keyName, uploadID, 3, generateData(OzoneConsts.OM_MULTIPART_MIN_SIZE, (byte) 97));
    partsMap.put(3, partName3);
    OzoneMultipartUploadPartListParts ozoneMultipartUploadPartListParts = bucket.listParts(keyName, uploadID, 0, 2);
    Assert.assertEquals(RATIS, ozoneMultipartUploadPartListParts.getReplicationType());
    Assert.assertEquals(2, ozoneMultipartUploadPartListParts.getPartInfoList().size());
    Assert.assertEquals(partsMap.get(ozoneMultipartUploadPartListParts.getPartInfoList().get(0).getPartNumber()), ozoneMultipartUploadPartListParts.getPartInfoList().get(0).getPartName());
    Assert.assertEquals(partsMap.get(ozoneMultipartUploadPartListParts.getPartInfoList().get(1).getPartNumber()), ozoneMultipartUploadPartListParts.getPartInfoList().get(1).getPartName());
    // Get remaining
    Assert.assertTrue(ozoneMultipartUploadPartListParts.isTruncated());
    ozoneMultipartUploadPartListParts = bucket.listParts(keyName, uploadID, ozoneMultipartUploadPartListParts.getNextPartNumberMarker(), 2);
    Assert.assertEquals(1, ozoneMultipartUploadPartListParts.getPartInfoList().size());
    Assert.assertEquals(partsMap.get(ozoneMultipartUploadPartListParts.getPartInfoList().get(0).getPartNumber()), ozoneMultipartUploadPartListParts.getPartInfoList().get(0).getPartName());
    // As we don't have any parts for this, we should get false here
    Assert.assertFalse(ozoneMultipartUploadPartListParts.isTruncated());
}
Also used : OzoneVolume(org.apache.hadoop.ozone.client.OzoneVolume) OzoneBucket(org.apache.hadoop.ozone.client.OzoneBucket) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) OzoneMultipartUploadPartListParts(org.apache.hadoop.ozone.client.OzoneMultipartUploadPartListParts) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 5 with OzoneMultipartUploadPartListParts

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

the class TestOzoneClientMultipartUploadWithFSO method testListMultipartUploadPartsWithContinuation.

@Test
public void testListMultipartUploadPartsWithContinuation() throws Exception {
    String volumeName = UUID.randomUUID().toString();
    String bucketName = UUID.randomUUID().toString();
    String keyName = UUID.randomUUID().toString();
    store.createVolume(volumeName);
    OzoneVolume volume = store.getVolume(volumeName);
    volume.createBucket(bucketName);
    OzoneBucket bucket = volume.getBucket(bucketName);
    Map<Integer, String> partsMap = new TreeMap<>();
    String uploadID = initiateMultipartUpload(bucket, keyName, RATIS, ONE);
    String partName1 = uploadPart(bucket, keyName, uploadID, 1, generateData(OzoneConsts.OM_MULTIPART_MIN_SIZE, (byte) 97));
    partsMap.put(1, partName1);
    String partName2 = uploadPart(bucket, keyName, uploadID, 2, generateData(OzoneConsts.OM_MULTIPART_MIN_SIZE, (byte) 97));
    partsMap.put(2, partName2);
    String partName3 = uploadPart(bucket, keyName, uploadID, 3, generateData(OzoneConsts.OM_MULTIPART_MIN_SIZE, (byte) 97));
    partsMap.put(3, partName3);
    OzoneMultipartUploadPartListParts ozoneMultipartUploadPartListParts = bucket.listParts(keyName, uploadID, 0, 2);
    Assert.assertEquals(RATIS, ozoneMultipartUploadPartListParts.getReplicationType());
    Assert.assertEquals(2, ozoneMultipartUploadPartListParts.getPartInfoList().size());
    Assert.assertEquals(partsMap.get(ozoneMultipartUploadPartListParts.getPartInfoList().get(0).getPartNumber()), ozoneMultipartUploadPartListParts.getPartInfoList().get(0).getPartName());
    Assert.assertEquals(partsMap.get(ozoneMultipartUploadPartListParts.getPartInfoList().get(1).getPartNumber()), ozoneMultipartUploadPartListParts.getPartInfoList().get(1).getPartName());
    // Get remaining
    Assert.assertTrue(ozoneMultipartUploadPartListParts.isTruncated());
    ozoneMultipartUploadPartListParts = bucket.listParts(keyName, uploadID, ozoneMultipartUploadPartListParts.getNextPartNumberMarker(), 2);
    Assert.assertEquals(1, ozoneMultipartUploadPartListParts.getPartInfoList().size());
    Assert.assertEquals(partsMap.get(ozoneMultipartUploadPartListParts.getPartInfoList().get(0).getPartNumber()), ozoneMultipartUploadPartListParts.getPartInfoList().get(0).getPartName());
    // As we don't have any parts for this, we should get false here
    Assert.assertFalse(ozoneMultipartUploadPartListParts.isTruncated());
}
Also used : OzoneVolume(org.apache.hadoop.ozone.client.OzoneVolume) OzoneBucket(org.apache.hadoop.ozone.client.OzoneBucket) OzoneMultipartUploadPartListParts(org.apache.hadoop.ozone.client.OzoneMultipartUploadPartListParts) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Aggregations

OzoneMultipartUploadPartListParts (org.apache.hadoop.ozone.client.OzoneMultipartUploadPartListParts)13 OzoneBucket (org.apache.hadoop.ozone.client.OzoneBucket)11 OzoneVolume (org.apache.hadoop.ozone.client.OzoneVolume)10 Test (org.junit.Test)10 TreeMap (java.util.TreeMap)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 OMException (org.apache.hadoop.ozone.om.exceptions.OMException)1 OmMultipartUploadListParts (org.apache.hadoop.ozone.om.helpers.OmMultipartUploadListParts)1 OmPartInfo (org.apache.hadoop.ozone.om.helpers.OmPartInfo)1