Search in sources :

Example 6 with OMClientResponse

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

the class TestOMVolumeCreateRequest method testValidateAndUpdateCacheWithVolumeAlreadyExists.

@Test
public void testValidateAndUpdateCacheWithVolumeAlreadyExists() throws Exception {
    String volumeName = UUID.randomUUID().toString();
    String adminName = "user1";
    String ownerName = "user1";
    OMRequestTestUtils.addVolumeToDB(volumeName, omMetadataManager);
    OMRequest originalRequest = createVolumeRequest(volumeName, adminName, ownerName);
    OMVolumeCreateRequest omVolumeCreateRequest = new OMVolumeCreateRequest(originalRequest);
    OMRequest modifiedRequest = omVolumeCreateRequest.preExecute(ozoneManager);
    omVolumeCreateRequest = new OMVolumeCreateRequest(modifiedRequest);
    OMClientResponse omClientResponse = omVolumeCreateRequest.validateAndUpdateCache(ozoneManager, 1, ozoneManagerDoubleBufferHelper);
    OzoneManagerProtocolProtos.OMResponse omResponse = omClientResponse.getOMResponse();
    Assert.assertNotNull(omResponse.getCreateVolumeResponse());
    Assert.assertEquals(OzoneManagerProtocolProtos.Status.VOLUME_ALREADY_EXISTS, omResponse.getStatus());
    // Check really if we have a volume with the specified volume name.
    Assert.assertNotNull(omMetadataManager.getVolumeTable().get(omMetadataManager.getVolumeKey(volumeName)));
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) OMClientResponse(org.apache.hadoop.ozone.om.response.OMClientResponse) OzoneManagerProtocolProtos(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos) Test(org.junit.Test)

Example 7 with OMClientResponse

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

the class TestOMKeyAclRequest method testKeyAddAclRequest.

@Test
public void testKeyAddAclRequest() throws Exception {
    // Manually add volume, bucket and key to DB
    OMRequestTestUtils.addVolumeAndBucketToDB(volumeName, bucketName, omMetadataManager, getBucketLayout());
    String ozoneKey = addKeyToTable();
    OmKeyInfo omKeyInfo = omMetadataManager.getKeyTable(getBucketLayout()).get(ozoneKey);
    // As we added manually to key table.
    Assert.assertNotNull(omKeyInfo);
    OzoneAcl acl = OzoneAcl.parseAcl("user:bilbo:rwdlncxy[ACCESS]");
    // Create KeyAddAcl request
    OMRequest originalRequest = createAddAclkeyRequest(acl);
    OMKeyAclRequest omKeyAddAclRequest = getOmKeyAddAclRequest(originalRequest);
    OMRequest preExecuteRequest = omKeyAddAclRequest.preExecute(ozoneManager);
    // When preExecute() of adding acl,
    // the new modification time is greater than origin one.
    long originModTime = originalRequest.getAddAclRequest().getModificationTime();
    long newModTime = preExecuteRequest.getAddAclRequest().getModificationTime();
    Assert.assertTrue(newModTime > originModTime);
    // Execute original request
    OMClientResponse omClientResponse = omKeyAddAclRequest.validateAndUpdateCache(ozoneManager, 100L, ozoneManagerDoubleBufferHelper);
    Assert.assertEquals(OzoneManagerProtocolProtos.Status.OK, omClientResponse.getOMResponse().getStatus());
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) OzoneAcl(org.apache.hadoop.ozone.OzoneAcl) OMClientResponse(org.apache.hadoop.ozone.om.response.OMClientResponse) OMKeyAclRequest(org.apache.hadoop.ozone.om.request.key.acl.OMKeyAclRequest) OmKeyInfo(org.apache.hadoop.ozone.om.helpers.OmKeyInfo) Test(org.junit.Test)

Example 8 with OMClientResponse

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

the class TestOMKeyAclRequest method testKeyRemoveAclRequest.

@Test
public void testKeyRemoveAclRequest() throws Exception {
    OMRequestTestUtils.addVolumeAndBucketToDB(volumeName, bucketName, omMetadataManager, getBucketLayout());
    String ozoneKey = addKeyToTable();
    OmKeyInfo omKeyInfo = omMetadataManager.getKeyTable(getBucketLayout()).get(ozoneKey);
    // As we added manually to key table.
    Assert.assertNotNull(omKeyInfo);
    OzoneAcl acl = OzoneAcl.parseAcl("user:bilbo:rwdlncxy[ACCESS]");
    // Add acl.
    OMRequest addAclRequest = createAddAclkeyRequest(acl);
    OMKeyAclRequest omKeyAddAclRequest = getOmKeyAddAclRequest(addAclRequest);
    omKeyAddAclRequest.preExecute(ozoneManager);
    OMClientResponse omClientAddAclResponse = omKeyAddAclRequest.validateAndUpdateCache(ozoneManager, 100L, ozoneManagerDoubleBufferHelper);
    OMResponse omAddAclResponse = omClientAddAclResponse.getOMResponse();
    Assert.assertNotNull(omAddAclResponse.getAddAclResponse());
    Assert.assertEquals(OzoneManagerProtocolProtos.Status.OK, omAddAclResponse.getStatus());
    // Verify result of adding acl.
    List<OzoneAcl> keyAcls = omMetadataManager.getKeyTable(getBucketLayout()).get(ozoneKey).getAcls();
    Assert.assertEquals(1, keyAcls.size());
    Assert.assertEquals(acl, keyAcls.get(0));
    // Remove acl.
    OMRequest removeAclRequest = createRemoveAclKeyRequest(acl);
    OMKeyAclRequest omKeyRemoveAclRequest = getOmKeyRemoveAclRequest(removeAclRequest);
    OMRequest preExecuteRequest = omKeyRemoveAclRequest.preExecute(ozoneManager);
    // When preExecute() of removing acl,
    // the new modification time is greater than origin one.
    long originModTime = removeAclRequest.getRemoveAclRequest().getModificationTime();
    long newModTime = preExecuteRequest.getRemoveAclRequest().getModificationTime();
    Assert.assertTrue(newModTime > originModTime);
    OMClientResponse omClientRemoveAclResponse = omKeyRemoveAclRequest.validateAndUpdateCache(ozoneManager, 100L, ozoneManagerDoubleBufferHelper);
    OMResponse omRemoveAclResponse = omClientRemoveAclResponse.getOMResponse();
    Assert.assertNotNull(omRemoveAclResponse.getRemoveAclResponse());
    Assert.assertEquals(OzoneManagerProtocolProtos.Status.OK, omRemoveAclResponse.getStatus());
    // Verify result of removing acl.
    List<OzoneAcl> newAcls = omMetadataManager.getKeyTable(getBucketLayout()).get(ozoneKey).getAcls();
    Assert.assertEquals(0, newAcls.size());
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) OzoneAcl(org.apache.hadoop.ozone.OzoneAcl) OMClientResponse(org.apache.hadoop.ozone.om.response.OMClientResponse) OMKeyAclRequest(org.apache.hadoop.ozone.om.request.key.acl.OMKeyAclRequest) OmKeyInfo(org.apache.hadoop.ozone.om.helpers.OmKeyInfo) OMResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse) Test(org.junit.Test)

Example 9 with OMClientResponse

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

the class TestOMKeyAclRequest method testKeySetAclRequest.

@Test
public void testKeySetAclRequest() throws Exception {
    OMRequestTestUtils.addVolumeAndBucketToDB(volumeName, bucketName, omMetadataManager, getBucketLayout());
    String ozoneKey = addKeyToTable();
    OmKeyInfo omKeyInfo = omMetadataManager.getKeyTable(getBucketLayout()).get(ozoneKey);
    // As we added manually to key table.
    Assert.assertNotNull(omKeyInfo);
    OzoneAcl acl = OzoneAcl.parseAcl("user:bilbo:rwdlncxy[ACCESS]");
    OMRequest setAclRequest = createSetAclKeyRequest(acl);
    OMKeyAclRequest omKeySetAclRequest = getOmKeySetAclRequest(setAclRequest);
    OMRequest preExecuteRequest = omKeySetAclRequest.preExecute(ozoneManager);
    // When preExecute() of setting acl,
    // the new modification time is greater than origin one.
    long originModTime = setAclRequest.getSetAclRequest().getModificationTime();
    long newModTime = preExecuteRequest.getSetAclRequest().getModificationTime();
    Assert.assertTrue(newModTime > originModTime);
    OMClientResponse omClientResponse = omKeySetAclRequest.validateAndUpdateCache(ozoneManager, 100L, ozoneManagerDoubleBufferHelper);
    OMResponse omSetAclResponse = omClientResponse.getOMResponse();
    Assert.assertNotNull(omSetAclResponse.getSetAclResponse());
    Assert.assertEquals(OzoneManagerProtocolProtos.Status.OK, omSetAclResponse.getStatus());
    // Verify result of setting acl.
    List<OzoneAcl> newAcls = omMetadataManager.getKeyTable(getBucketLayout()).get(ozoneKey).getAcls();
    Assert.assertEquals(newAcls.get(0), acl);
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) OzoneAcl(org.apache.hadoop.ozone.OzoneAcl) OMClientResponse(org.apache.hadoop.ozone.om.response.OMClientResponse) OMKeyAclRequest(org.apache.hadoop.ozone.om.request.key.acl.OMKeyAclRequest) OmKeyInfo(org.apache.hadoop.ozone.om.helpers.OmKeyInfo) OMResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse) Test(org.junit.Test)

Example 10 with OMClientResponse

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

the class TestOMKeyCommitRequest method testValidateAndUpdateCacheWithKeyNotFound.

@Test
public void testValidateAndUpdateCacheWithKeyNotFound() throws Exception {
    OMRequest modifiedOmRequest = doPreExecute(createCommitKeyRequest());
    OMKeyCommitRequest omKeyCommitRequest = getOmKeyCommitRequest(modifiedOmRequest);
    OMRequestTestUtils.addVolumeAndBucketToDB(volumeName, bucketName, omMetadataManager, omKeyCommitRequest.getBucketLayout());
    String ozoneKey = getOzonePathKey();
    // 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.KEY_NOT_FOUND, omClientResponse.getOMResponse().getStatus());
    omKeyInfo = omMetadataManager.getKeyTable(omKeyCommitRequest.getBucketLayout()).get(ozoneKey);
    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)

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