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());
}
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;
}
Aggregations