Search in sources :

Example 11 with OmMultipartCommitUploadPartInfo

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

the class TestOzoneRpcClientAbstract method uploadPart.

private String uploadPart(OzoneBucket bucket, String keyName, String uploadID, int partNumber, byte[] data) throws Exception {
    OzoneOutputStream ozoneOutputStream = bucket.createMultipartKey(keyName, data.length, partNumber, uploadID);
    ozoneOutputStream.write(data, 0, data.length);
    ozoneOutputStream.close();
    OmMultipartCommitUploadPartInfo omMultipartCommitUploadPartInfo = ozoneOutputStream.getCommitUploadPartInfo();
    Assert.assertNotNull(omMultipartCommitUploadPartInfo);
    Assert.assertNotNull(omMultipartCommitUploadPartInfo.getPartName());
    return omMultipartCommitUploadPartInfo.getPartName();
}
Also used : OmMultipartCommitUploadPartInfo(org.apache.hadoop.ozone.om.helpers.OmMultipartCommitUploadPartInfo) OzoneOutputStream(org.apache.hadoop.ozone.client.io.OzoneOutputStream)

Example 12 with OmMultipartCommitUploadPartInfo

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

the class TestOzoneRpcClientAbstract method testUploadPartOverrideWithRatis.

@Test
public void testUploadPartOverrideWithRatis() throws IOException {
    String volumeName = UUID.randomUUID().toString();
    String bucketName = UUID.randomUUID().toString();
    String keyName = UUID.randomUUID().toString();
    String sampleData = "sample Value";
    store.createVolume(volumeName);
    OzoneVolume volume = store.getVolume(volumeName);
    volume.createBucket(bucketName);
    OzoneBucket bucket = volume.getBucket(bucketName);
    OmMultipartInfo multipartInfo = bucket.initiateMultipartUpload(keyName, ReplicationType.RATIS, THREE);
    assertNotNull(multipartInfo);
    String uploadID = multipartInfo.getUploadID();
    Assert.assertEquals(volumeName, multipartInfo.getVolumeName());
    Assert.assertEquals(bucketName, multipartInfo.getBucketName());
    Assert.assertEquals(keyName, multipartInfo.getKeyName());
    assertNotNull(multipartInfo.getUploadID());
    int partNumber = 1;
    OzoneOutputStream ozoneOutputStream = bucket.createMultipartKey(keyName, sampleData.length(), partNumber, uploadID);
    ozoneOutputStream.write(string2Bytes(sampleData), 0, sampleData.length());
    ozoneOutputStream.close();
    OmMultipartCommitUploadPartInfo commitUploadPartInfo = ozoneOutputStream.getCommitUploadPartInfo();
    assertNotNull(commitUploadPartInfo);
    String partName = commitUploadPartInfo.getPartName();
    assertNotNull(commitUploadPartInfo.getPartName());
    // Overwrite the part by creating part key with same part number
    // and same content.
    ozoneOutputStream = bucket.createMultipartKey(keyName, sampleData.length(), partNumber, uploadID);
    ozoneOutputStream.write(string2Bytes(sampleData), 0, "name".length());
    ozoneOutputStream.close();
    commitUploadPartInfo = ozoneOutputStream.getCommitUploadPartInfo();
    assertNotNull(commitUploadPartInfo);
    assertNotNull(commitUploadPartInfo.getPartName());
    // AWS S3 for same content generates same partName during upload part.
    // In AWS S3 ETag is generated from md5sum. In Ozone right now we
    // don't do this. For now to make things work for large file upload
    // through aws s3 cp, the partName are generated in a predictable fashion.
    // So, when a part is override partNames will still be same irrespective
    // of content in ozone s3. This will make S3 Mpu completeMPU pass when
    // comparing part names and large file uploads work using aws cp.
    assertEquals("Part names should be same", partName, commitUploadPartInfo.getPartName());
}
Also used : OzoneVolume(org.apache.hadoop.ozone.client.OzoneVolume) OzoneBucket(org.apache.hadoop.ozone.client.OzoneBucket) OmMultipartCommitUploadPartInfo(org.apache.hadoop.ozone.om.helpers.OmMultipartCommitUploadPartInfo) OzoneOutputStream(org.apache.hadoop.ozone.client.io.OzoneOutputStream) OmMultipartInfo(org.apache.hadoop.ozone.om.helpers.OmMultipartInfo) Test(org.junit.Test)

Aggregations

OmMultipartCommitUploadPartInfo (org.apache.hadoop.ozone.om.helpers.OmMultipartCommitUploadPartInfo)12 OzoneOutputStream (org.apache.hadoop.ozone.client.io.OzoneOutputStream)11 OzoneBucket (org.apache.hadoop.ozone.client.OzoneBucket)8 OzoneVolume (org.apache.hadoop.ozone.client.OzoneVolume)7 OmMultipartInfo (org.apache.hadoop.ozone.om.helpers.OmMultipartInfo)7 Test (org.junit.Test)7 OzoneInputStream (org.apache.hadoop.ozone.client.io.OzoneInputStream)3 OMException (org.apache.hadoop.ozone.om.exceptions.OMException)3 IOException (java.io.IOException)2 LinkedHashMap (java.util.LinkedHashMap)2 OmMultipartUploadCompleteInfo (org.apache.hadoop.ozone.om.helpers.OmMultipartUploadCompleteInfo)2 EOFException (java.io.EOFException)1 OptionalLong (java.util.OptionalLong)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 OmKeyArgs (org.apache.hadoop.ozone.om.helpers.OmKeyArgs)1 OmKeyLocationInfo (org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo)1 DeleteKeyArgs (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteKeyArgs)1 KeyArgs (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyArgs)1 MultipartCommitUploadPartRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.MultipartCommitUploadPartRequest)1 MultipartCommitUploadPartResponse (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.MultipartCommitUploadPartResponse)1