use of org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest in project ozone by apache.
the class TestOzoneManagerHAMetadataOnly method testOMRetryCache.
@Test
public void testOMRetryCache() throws Exception {
ObjectStore objectStore = getObjectStore();
objectStore.createVolume(UUID.randomUUID().toString());
OMFailoverProxyProvider omFailoverProxyProvider = OmFailoverProxyUtil.getFailoverProxyProvider(objectStore.getClientProxy());
String currentLeaderNodeId = omFailoverProxyProvider.getCurrentProxyOMNodeId();
OzoneManagerRatisServer ozoneManagerRatisServer = getCluster().getOzoneManager(currentLeaderNodeId).getOmRatisServer();
RaftServer raftServer = ozoneManagerRatisServer.getServer();
ClientId clientId = ClientId.randomId();
long callId = 2000L;
String userName = UserGroupInformation.getCurrentUser().getUserName();
String volumeName = UUID.randomUUID().toString();
GenericTestUtils.LogCapturer logCapturer = GenericTestUtils.LogCapturer.captureLogs(OMVolumeCreateRequest.getLogger());
OMRequest omRequest = OMRequest.newBuilder().setCreateVolumeRequest(CreateVolumeRequest.newBuilder().setVolumeInfo(VolumeInfo.newBuilder().setOwnerName(userName).setAdminName(userName).setVolume(volumeName).build()).build()).setClientId(UUID.randomUUID().toString()).setCmdType(OzoneManagerProtocolProtos.Type.CreateVolume).build();
RaftClientReply raftClientReply = raftServer.submitClientRequest(RaftClientRequest.newBuilder().setClientId(clientId).setServerId(raftServer.getId()).setGroupId(ozoneManagerRatisServer.getRaftGroup().getGroupId()).setCallId(callId).setMessage(Message.valueOf(OMRatisHelper.convertRequestToByteString(omRequest))).setType(RaftClientRequest.writeRequestType()).build());
Assert.assertTrue(raftClientReply.isSuccess());
Assert.assertTrue(logCapturer.getOutput().contains("created volume:" + volumeName));
logCapturer.clearOutput();
raftClientReply = raftServer.submitClientRequest(RaftClientRequest.newBuilder().setClientId(clientId).setServerId(raftServer.getId()).setGroupId(ozoneManagerRatisServer.getRaftGroup().getGroupId()).setCallId(callId).setMessage(Message.valueOf(OMRatisHelper.convertRequestToByteString(omRequest))).setType(RaftClientRequest.writeRequestType()).build());
Assert.assertTrue(raftClientReply.isSuccess());
// As second time with same client id and call id, this request should
// not be executed ratis server should return from cache.
// If 2nd time executed, it will fail with Volume creation failed. check
// for that.
Assert.assertFalse(logCapturer.getOutput().contains("Volume creation failed"));
// Sleep for little above retry cache duration to get cache clear.
Thread.sleep(getRetryCacheDuration().toMillis() + 5000);
raftClientReply = raftServer.submitClientRequest(RaftClientRequest.newBuilder().setClientId(clientId).setServerId(raftServer.getId()).setGroupId(ozoneManagerRatisServer.getRaftGroup().getGroupId()).setCallId(callId).setMessage(Message.valueOf(OMRatisHelper.convertRequestToByteString(omRequest))).setType(RaftClientRequest.writeRequestType()).build());
Assert.assertTrue(raftClientReply.isSuccess());
// As second time with same client id and call id, this request should
// be executed by ratis server as we are sending this request after cache
// expiry duration.
Assert.assertTrue(logCapturer.getOutput().contains("Volume creation failed"));
}
use of org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest 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.protocol.proto.OzoneManagerProtocolProtos.OMRequest 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.protocol.proto.OzoneManagerProtocolProtos.OMRequest 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.protocol.proto.OzoneManagerProtocolProtos.OMRequest 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));
}
Aggregations