Search in sources :

Example 11 with OMClientResponse

use of org.apache.hadoop.ozone.om.response.OMClientResponse in project ozone by apache.

the class TestOMKeyCommitRequest method testValidateAndUpdateCacheWithUnknownBlockId.

@Test
public void testValidateAndUpdateCacheWithUnknownBlockId() throws Exception {
    OMRequest modifiedOmRequest = doPreExecute(createCommitKeyRequest());
    OMKeyCommitRequest omKeyCommitRequest = getOmKeyCommitRequest(modifiedOmRequest);
    // Append 3 blocks locations.
    List<OmKeyLocationInfo> allocatedLocationList = getKeyLocation(3).stream().map(OmKeyLocationInfo::getFromProtobuf).collect(Collectors.toList());
    OMRequestTestUtils.addVolumeAndBucketToDB(volumeName, bucketName, omMetadataManager, omKeyCommitRequest.getBucketLayout());
    String ozoneKey = addKeyToOpenKeyTable(allocatedLocationList);
    // Key should not be there in key table, as validateAndUpdateCache is
    // still not called.
    OmKeyInfo omKeyInfo = omMetadataManager.getKeyTable(omKeyCommitRequest.getBucketLayout()).get(ozoneKey);
    Assert.assertNull(omKeyInfo);
    OMClientResponse omClientResponse = omKeyCommitRequest.validateAndUpdateCache(ozoneManager, 100L, ozoneManagerDoubleBufferHelper);
    Assert.assertEquals(OzoneManagerProtocolProtos.Status.OK, omClientResponse.getOMResponse().getStatus());
    // Entry should be deleted from openKey Table.
    omKeyInfo = omMetadataManager.getOpenKeyTable(omKeyCommitRequest.getBucketLayout()).get(ozoneKey);
    Assert.assertNull(omKeyInfo);
    // Now entry should be created in key Table.
    omKeyInfo = omMetadataManager.getKeyTable(omKeyCommitRequest.getBucketLayout()).get(ozoneKey);
    Assert.assertNotNull(omKeyInfo);
    // Check modification time
    CommitKeyRequest commitKeyRequest = modifiedOmRequest.getCommitKeyRequest();
    Assert.assertEquals(commitKeyRequest.getKeyArgs().getModificationTime(), omKeyInfo.getModificationTime());
    // Check block location.
    Assert.assertEquals(allocatedLocationList, omKeyInfo.getLatestVersionLocations().getLocationList());
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) OMClientResponse(org.apache.hadoop.ozone.om.response.OMClientResponse) CommitKeyRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CommitKeyRequest) OmKeyInfo(org.apache.hadoop.ozone.om.helpers.OmKeyInfo) OmKeyLocationInfo(org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo) Test(org.junit.Test)

Example 12 with OMClientResponse

use of org.apache.hadoop.ozone.om.response.OMClientResponse in project ozone by apache.

the class TestOMKeyCreateRequest method testValidateAndUpdateCacheWithBucketNotFound.

@Test
public void testValidateAndUpdateCacheWithBucketNotFound() throws Exception {
    OMRequest modifiedOmRequest = doPreExecute(createKeyRequest(false, 0));
    OMKeyCreateRequest omKeyCreateRequest = getOMKeyCreateRequest(modifiedOmRequest);
    long id = modifiedOmRequest.getCreateKeyRequest().getClientID();
    String openKey = getOpenKey(id);
    OMRequestTestUtils.addVolumeToDB(volumeName, OzoneConsts.OZONE, omMetadataManager);
    // Before calling
    OmKeyInfo omKeyInfo = omMetadataManager.getOpenKeyTable(getBucketLayout()).get(openKey);
    Assert.assertNull(omKeyInfo);
    OMClientResponse omKeyCreateResponse = omKeyCreateRequest.validateAndUpdateCache(ozoneManager, 100L, ozoneManagerDoubleBufferHelper);
    Assert.assertEquals(OzoneManagerProtocolProtos.Status.BUCKET_NOT_FOUND, omKeyCreateResponse.getOMResponse().getStatus());
    // As We got an error, openKey Table should not have entry.
    omKeyInfo = omMetadataManager.getOpenKeyTable(getBucketLayout()).get(openKey);
    Assert.assertNull(omKeyInfo);
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) OMClientResponse(org.apache.hadoop.ozone.om.response.OMClientResponse) OmKeyInfo(org.apache.hadoop.ozone.om.helpers.OmKeyInfo) Test(org.junit.Test)

Example 13 with OMClientResponse

use of org.apache.hadoop.ozone.om.response.OMClientResponse in project ozone by apache.

the class TestOMKeyCreateRequest method testValidateAndUpdateCacheWithNoSuchMultipartUploadError.

@Test
public void testValidateAndUpdateCacheWithNoSuchMultipartUploadError() throws Exception {
    int partNumber = 1;
    OMRequest modifiedOmRequest = doPreExecute(createKeyRequest(true, partNumber));
    OMKeyCreateRequest omKeyCreateRequest = getOMKeyCreateRequest(modifiedOmRequest);
    // Add volume and bucket entries to DB.
    addVolumeAndBucketToDB(volumeName, bucketName, omMetadataManager);
    long id = modifiedOmRequest.getCreateKeyRequest().getClientID();
    String openKey = omMetadataManager.getOpenKey(volumeName, bucketName, keyName, id);
    // Before calling
    OmKeyInfo omKeyInfo = omMetadataManager.getOpenKeyTable(getBucketLayout()).get(openKey);
    Assert.assertNull(omKeyInfo);
    OMClientResponse omKeyCreateResponse = omKeyCreateRequest.validateAndUpdateCache(ozoneManager, 100L, ozoneManagerDoubleBufferHelper);
    Assert.assertEquals(OzoneManagerProtocolProtos.Status.NO_SUCH_MULTIPART_UPLOAD_ERROR, omKeyCreateResponse.getOMResponse().getStatus());
    // As we got error, no entry should be created in openKeyTable.
    omKeyInfo = omMetadataManager.getOpenKeyTable(getBucketLayout()).get(openKey);
    Assert.assertNull(omKeyInfo);
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) OMClientResponse(org.apache.hadoop.ozone.om.response.OMClientResponse) OmKeyInfo(org.apache.hadoop.ozone.om.helpers.OmKeyInfo) Test(org.junit.Test)

Example 14 with OMClientResponse

use of org.apache.hadoop.ozone.om.response.OMClientResponse in project ozone by apache.

the class TestS3MultipartUploadCommitPartRequest method testValidateAndUpdateCacheSuccess.

@Test
public void testValidateAndUpdateCacheSuccess() throws Exception {
    String volumeName = UUID.randomUUID().toString();
    String bucketName = UUID.randomUUID().toString();
    String keyName = getKeyName();
    OMRequestTestUtils.addVolumeAndBucketToDB(volumeName, bucketName, omMetadataManager);
    createParentPath(volumeName, bucketName);
    OMRequest initiateMPURequest = doPreExecuteInitiateMPU(volumeName, bucketName, keyName);
    S3InitiateMultipartUploadRequest s3InitiateMultipartUploadRequest = getS3InitiateMultipartUploadReq(initiateMPURequest);
    OMClientResponse omClientResponse = s3InitiateMultipartUploadRequest.validateAndUpdateCache(ozoneManager, 1L, ozoneManagerDoubleBufferHelper);
    long clientID = Time.now();
    String multipartUploadID = omClientResponse.getOMResponse().getInitiateMultiPartUploadResponse().getMultipartUploadID();
    OMRequest commitMultipartRequest = doPreExecuteCommitMPU(volumeName, bucketName, keyName, clientID, multipartUploadID, 1);
    S3MultipartUploadCommitPartRequest s3MultipartUploadCommitPartRequest = getS3MultipartUploadCommitReq(commitMultipartRequest);
    // Add key to open key table.
    addKeyToOpenKeyTable(volumeName, bucketName, keyName, clientID);
    omClientResponse = s3MultipartUploadCommitPartRequest.validateAndUpdateCache(ozoneManager, 2L, ozoneManagerDoubleBufferHelper);
    Assert.assertTrue(omClientResponse.getOMResponse().getStatus() == OzoneManagerProtocolProtos.Status.OK);
    String multipartOpenKey = getMultipartOpenKey(volumeName, bucketName, keyName, multipartUploadID);
    String multipartKey = omMetadataManager.getMultipartKey(volumeName, bucketName, keyName, multipartUploadID);
    Assert.assertNotNull(omMetadataManager.getMultipartInfoTable().get(multipartKey));
    Assert.assertTrue(omMetadataManager.getMultipartInfoTable().get(multipartKey).getPartKeyInfoMap().size() == 1);
    Assert.assertNotNull(omMetadataManager.getOpenKeyTable(s3MultipartUploadCommitPartRequest.getBucketLayout()).get(multipartOpenKey));
    String partKey = getOpenKey(volumeName, bucketName, keyName, clientID);
    Assert.assertNull(omMetadataManager.getOpenKeyTable(s3MultipartUploadCommitPartRequest.getBucketLayout()).get(partKey));
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) OMClientResponse(org.apache.hadoop.ozone.om.response.OMClientResponse) Test(org.junit.Test)

Example 15 with OMClientResponse

use of org.apache.hadoop.ozone.om.response.OMClientResponse in project ozone by apache.

the class TestS3MultipartUploadCommitPartRequest method testValidateAndUpdateCacheMultipartNotFound.

@Test
public void testValidateAndUpdateCacheMultipartNotFound() throws Exception {
    String volumeName = UUID.randomUUID().toString();
    String bucketName = UUID.randomUUID().toString();
    String keyName = getKeyName();
    OMRequestTestUtils.addVolumeAndBucketToDB(volumeName, bucketName, omMetadataManager);
    createParentPath(volumeName, bucketName);
    long clientID = Time.now();
    String multipartUploadID = UUID.randomUUID().toString();
    OMRequest commitMultipartRequest = doPreExecuteCommitMPU(volumeName, bucketName, keyName, clientID, multipartUploadID, 1);
    S3MultipartUploadCommitPartRequest s3MultipartUploadCommitPartRequest = getS3MultipartUploadCommitReq(commitMultipartRequest);
    // Add key to open key table.
    addKeyToOpenKeyTable(volumeName, bucketName, keyName, clientID);
    OMClientResponse omClientResponse = s3MultipartUploadCommitPartRequest.validateAndUpdateCache(ozoneManager, 2L, ozoneManagerDoubleBufferHelper);
    Assert.assertTrue(omClientResponse.getOMResponse().getStatus() == OzoneManagerProtocolProtos.Status.NO_SUCH_MULTIPART_UPLOAD_ERROR);
    String multipartKey = omMetadataManager.getMultipartKey(volumeName, bucketName, keyName, multipartUploadID);
    Assert.assertNull(omMetadataManager.getMultipartInfoTable().get(multipartKey));
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) OMClientResponse(org.apache.hadoop.ozone.om.response.OMClientResponse) Test(org.junit.Test)

Aggregations

OMClientResponse (org.apache.hadoop.ozone.om.response.OMClientResponse)163 OMRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest)106 Test (org.junit.Test)105 OMResponse (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse)62 OmKeyInfo (org.apache.hadoop.ozone.om.helpers.OmKeyInfo)47 IOException (java.io.IOException)46 OMMetadataManager (org.apache.hadoop.ozone.om.OMMetadataManager)43 OzoneManagerProtocolProtos (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos)34 OmBucketInfo (org.apache.hadoop.ozone.om.helpers.OmBucketInfo)33 OMException (org.apache.hadoop.ozone.om.exceptions.OMException)30 ArrayList (java.util.ArrayList)29 OMMetrics (org.apache.hadoop.ozone.om.OMMetrics)27 OzoneAcl (org.apache.hadoop.ozone.OzoneAcl)20 KeyArgs (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyArgs)19 AuditLogger (org.apache.hadoop.ozone.audit.AuditLogger)18 OmKeyLocationInfo (org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo)16 OmVolumeArgs (org.apache.hadoop.ozone.om.helpers.OmVolumeArgs)13 OmDirectoryInfo (org.apache.hadoop.ozone.om.helpers.OmDirectoryInfo)10 OmMultipartKeyInfo (org.apache.hadoop.ozone.om.helpers.OmMultipartKeyInfo)6 RepeatedOmKeyInfo (org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo)5