use of org.apache.hadoop.ozone.om.response.OMClientResponse in project ozone by apache.
the class TestOMKeysRenameRequest method testKeysRenameRequestFail.
@Test
public void testKeysRenameRequestFail() throws Exception {
OMRequest modifiedOmRequest = createRenameKeyRequest(true);
OMKeysRenameRequest omKeysRenameRequest = new OMKeysRenameRequest(modifiedOmRequest);
OMClientResponse omKeysRenameResponse = omKeysRenameRequest.validateAndUpdateCache(ozoneManager, 100L, ozoneManagerDoubleBufferHelper);
Assert.assertFalse(omKeysRenameResponse.getOMResponse().getSuccess());
Assert.assertEquals(OzoneManagerProtocolProtos.Status.PARTIAL_RENAME, omKeysRenameResponse.getOMResponse().getStatus());
// The keys(key0 to key9)can be renamed success.
for (int i = 0; i < count; i++) {
// Original key should be deleted, toKey should exist.
OmKeyInfo omKeyInfo = omMetadataManager.getKeyTable(getBucketLayout()).get(omMetadataManager.getOzoneKey(volumeName, bucketName, parentDir.concat("/key" + i)));
Assert.assertNull(omKeyInfo);
omKeyInfo = omMetadataManager.getKeyTable(getBucketLayout()).get(omMetadataManager.getOzoneKey(volumeName, bucketName, parentDir.concat("/newKey" + i)));
Assert.assertNotNull(omKeyInfo);
}
// The key not rename should be in unRenamedKeys.
RenameKeysMap unRenamedKeys = omKeysRenameResponse.getOMResponse().getRenameKeysResponse().getUnRenamedKeys(0);
Assert.assertEquals("testKey", unRenamedKeys.getFromKeyName());
}
use of org.apache.hadoop.ozone.om.response.OMClientResponse in project ozone by apache.
the class TestS3InitiateMultipartUploadRequestWithFSO method testValidateAndUpdateCache.
@Test
public void testValidateAndUpdateCache() throws Exception {
String volumeName = UUID.randomUUID().toString();
String bucketName = UUID.randomUUID().toString();
String prefix = "a/b/c/";
List<String> dirs = new ArrayList<String>();
dirs.add("a");
dirs.add("b");
dirs.add("c");
String fileName = UUID.randomUUID().toString();
String keyName = prefix + fileName;
// Add volume and bucket to DB.
OMRequestTestUtils.addVolumeAndBucketToDB(volumeName, bucketName, omMetadataManager);
String bucketKey = omMetadataManager.getBucketKey(volumeName, bucketName);
OmBucketInfo omBucketInfo = omMetadataManager.getBucketTable().get(bucketKey);
long bucketID = omBucketInfo.getObjectID();
OMRequest modifiedRequest = doPreExecuteInitiateMPUWithFSO(volumeName, bucketName, keyName);
S3InitiateMultipartUploadRequest s3InitiateMultipartUploadReqFSO = getS3InitiateMultipartUploadReq(modifiedRequest);
OMClientResponse omClientResponse = s3InitiateMultipartUploadReqFSO.validateAndUpdateCache(ozoneManager, 100L, ozoneManagerDoubleBufferHelper);
Assert.assertEquals(OzoneManagerProtocolProtos.Status.OK, omClientResponse.getOMResponse().getStatus());
long parentID = verifyDirectoriesInDB(dirs, bucketID);
String multipartFileKey = omMetadataManager.getMultipartKey(volumeName, bucketName, keyName, modifiedRequest.getInitiateMultiPartUploadRequest().getKeyArgs().getMultipartUploadID());
String multipartOpenFileKey = omMetadataManager.getMultipartKey(parentID, fileName, modifiedRequest.getInitiateMultiPartUploadRequest().getKeyArgs().getMultipartUploadID());
OmKeyInfo omKeyInfo = omMetadataManager.getOpenKeyTable(s3InitiateMultipartUploadReqFSO.getBucketLayout()).get(multipartOpenFileKey);
Assert.assertNotNull("Failed to find the fileInfo", omKeyInfo);
Assert.assertEquals("FileName mismatches!", fileName, omKeyInfo.getKeyName());
Assert.assertEquals("ParentId mismatches!", parentID, omKeyInfo.getParentObjectID());
OmMultipartKeyInfo omMultipartKeyInfo = omMetadataManager.getMultipartInfoTable().get(multipartFileKey);
Assert.assertNotNull("Failed to find the multipartFileInfo", omMultipartKeyInfo);
Assert.assertEquals("ParentId mismatches!", parentID, omMultipartKeyInfo.getParentID());
Assert.assertEquals(modifiedRequest.getInitiateMultiPartUploadRequest().getKeyArgs().getMultipartUploadID(), omMultipartKeyInfo.getUploadID());
Assert.assertEquals(modifiedRequest.getInitiateMultiPartUploadRequest().getKeyArgs().getModificationTime(), omKeyInfo.getModificationTime());
Assert.assertEquals(modifiedRequest.getInitiateMultiPartUploadRequest().getKeyArgs().getModificationTime(), omKeyInfo.getCreationTime());
}
use of org.apache.hadoop.ozone.om.response.OMClientResponse in project ozone by apache.
the class TestS3MultipartUploadAbortRequest method testValidateAndUpdateCacheVolumeNotFound.
@Test
public void testValidateAndUpdateCacheVolumeNotFound() throws Exception {
String volumeName = UUID.randomUUID().toString();
String bucketName = UUID.randomUUID().toString();
String keyName = UUID.randomUUID().toString();
String multipartUploadID = "randomMPU";
OMRequest abortMPURequest = doPreExecuteAbortMPU(volumeName, bucketName, keyName, multipartUploadID);
S3MultipartUploadAbortRequest s3MultipartUploadAbortRequest = new S3MultipartUploadAbortRequest(abortMPURequest);
OMClientResponse omClientResponse = s3MultipartUploadAbortRequest.validateAndUpdateCache(ozoneManager, 2L, ozoneManagerDoubleBufferHelper);
// Check table and response.
Assert.assertEquals(OzoneManagerProtocolProtos.Status.VOLUME_NOT_FOUND, omClientResponse.getOMResponse().getStatus());
}
use of org.apache.hadoop.ozone.om.response.OMClientResponse in project ozone by apache.
the class TestS3MultipartUploadAbortRequest method testValidateAndUpdateCache.
@Test
public void testValidateAndUpdateCache() 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);
String multipartUploadID = omClientResponse.getOMResponse().getInitiateMultiPartUploadResponse().getMultipartUploadID();
OMRequest abortMPURequest = doPreExecuteAbortMPU(volumeName, bucketName, keyName, multipartUploadID);
S3MultipartUploadAbortRequest s3MultipartUploadAbortRequest = getS3MultipartUploadAbortReq(abortMPURequest);
omClientResponse = s3MultipartUploadAbortRequest.validateAndUpdateCache(ozoneManager, 2L, ozoneManagerDoubleBufferHelper);
String multipartKey = omMetadataManager.getMultipartKey(volumeName, bucketName, keyName, multipartUploadID);
String multipartOpenKey = getMultipartOpenKey(volumeName, bucketName, keyName, multipartUploadID);
// Check table and response.
Assert.assertEquals(OzoneManagerProtocolProtos.Status.OK, omClientResponse.getOMResponse().getStatus());
Assert.assertNull(omMetadataManager.getMultipartInfoTable().get(multipartKey));
Assert.assertNull(omMetadataManager.getOpenKeyTable(s3MultipartUploadAbortRequest.getBucketLayout()).get(multipartOpenKey));
}
use of org.apache.hadoop.ozone.om.response.OMClientResponse in project ozone by apache.
the class TestS3MultipartUploadAbortRequest method testValidateAndUpdateCacheBucketNotFound.
@Test
public void testValidateAndUpdateCacheBucketNotFound() throws Exception {
String volumeName = UUID.randomUUID().toString();
String bucketName = UUID.randomUUID().toString();
String keyName = UUID.randomUUID().toString();
OMRequestTestUtils.addVolumeToDB(volumeName, omMetadataManager);
String multipartUploadID = "randomMPU";
OMRequest abortMPURequest = doPreExecuteAbortMPU(volumeName, bucketName, keyName, multipartUploadID);
S3MultipartUploadAbortRequest s3MultipartUploadAbortRequest = new S3MultipartUploadAbortRequest(abortMPURequest);
OMClientResponse omClientResponse = s3MultipartUploadAbortRequest.validateAndUpdateCache(ozoneManager, 2L, ozoneManagerDoubleBufferHelper);
// Check table and response.
Assert.assertEquals(OzoneManagerProtocolProtos.Status.BUCKET_NOT_FOUND, omClientResponse.getOMResponse().getStatus());
}
Aggregations