Search in sources :

Example 1 with OMRequest

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"));
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) ObjectStore(org.apache.hadoop.ozone.client.ObjectStore) OMFailoverProxyProvider(org.apache.hadoop.ozone.om.ha.OMFailoverProxyProvider) RaftClientReply(org.apache.ratis.protocol.RaftClientReply) RaftServer(org.apache.ratis.server.RaftServer) ClientId(org.apache.ratis.protocol.ClientId) GenericTestUtils(org.apache.ozone.test.GenericTestUtils) OzoneManagerRatisServer(org.apache.hadoop.ozone.om.ratis.OzoneManagerRatisServer) Test(org.junit.Test)

Example 2 with OMRequest

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());
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) OMClientResponse(org.apache.hadoop.ozone.om.response.OMClientResponse) RenameKeysMap(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RenameKeysMap) OmKeyInfo(org.apache.hadoop.ozone.om.helpers.OmKeyInfo) Test(org.junit.Test)

Example 3 with OMRequest

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());
}
Also used : OmBucketInfo(org.apache.hadoop.ozone.om.helpers.OmBucketInfo) OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) OMClientResponse(org.apache.hadoop.ozone.om.response.OMClientResponse) OmMultipartKeyInfo(org.apache.hadoop.ozone.om.helpers.OmMultipartKeyInfo) ArrayList(java.util.ArrayList) OmKeyInfo(org.apache.hadoop.ozone.om.helpers.OmKeyInfo) Test(org.junit.Test)

Example 4 with OMRequest

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());
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) OMClientResponse(org.apache.hadoop.ozone.om.response.OMClientResponse) Test(org.junit.Test)

Example 5 with OMRequest

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));
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) OMClientResponse(org.apache.hadoop.ozone.om.response.OMClientResponse) Test(org.junit.Test)

Aggregations

OMRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest)209 Test (org.junit.Test)119 OMClientResponse (org.apache.hadoop.ozone.om.response.OMClientResponse)106 OMResponse (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse)30 OmKeyInfo (org.apache.hadoop.ozone.om.helpers.OmKeyInfo)27 ArrayList (java.util.ArrayList)26 OzoneAcl (org.apache.hadoop.ozone.OzoneAcl)26 KeyArgs (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyArgs)24 OzoneManagerProtocolProtos (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos)19 DeleteKeyArgs (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteKeyArgs)17 OmKeyArgs (org.apache.hadoop.ozone.om.helpers.OmKeyArgs)16 OMException (org.apache.hadoop.ozone.om.exceptions.OMException)15 OmBucketInfo (org.apache.hadoop.ozone.om.helpers.OmBucketInfo)15 IOException (java.io.IOException)13 OmKeyLocationInfo (org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo)11 OmVolumeArgs (org.apache.hadoop.ozone.om.helpers.OmVolumeArgs)10 CommitKeyRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CommitKeyRequest)7 VolumeInfo (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.VolumeInfo)7 UpgradeFinalizationStatus (org.apache.hadoop.hdds.protocol.proto.HddsProtos.UpgradeFinalizationStatus)5 Text (org.apache.hadoop.io.Text)5