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