Search in sources :

Example 26 with OMClientResponse

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

the class TestOMOpenKeysDeleteRequest method deleteOpenKeysFromCache.

/**
 * Runs the validate and update cache step of
 * {@link OMOpenKeysDeleteRequest} to mark the keys in {@code openKeys}
 * as deleted in the open key table cache.
 * Asserts that the call's response status is {@link Status#OK}.
 * @throws Exception
 */
private void deleteOpenKeysFromCache(OpenKeyBucket... openKeys) throws Exception {
    OMRequest omRequest = doPreExecute(createDeleteOpenKeyRequest(openKeys));
    OMOpenKeysDeleteRequest openKeyDeleteRequest = new OMOpenKeysDeleteRequest(omRequest);
    OMClientResponse omClientResponse = openKeyDeleteRequest.validateAndUpdateCache(ozoneManager, 100L, ozoneManagerDoubleBufferHelper);
    Assert.assertEquals(Status.OK, omClientResponse.getOMResponse().getStatus());
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) OMClientResponse(org.apache.hadoop.ozone.om.response.OMClientResponse)

Example 27 with OMClientResponse

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

the class TestOMVolumeDeleteRequest method testValidateAndUpdateCacheSuccess.

@Test
public void testValidateAndUpdateCacheSuccess() throws Exception {
    String volumeName = UUID.randomUUID().toString();
    String ownerName = "user1";
    OMRequest originalRequest = deleteVolumeRequest(volumeName);
    OMVolumeDeleteRequest omVolumeDeleteRequest = new OMVolumeDeleteRequest(originalRequest);
    omVolumeDeleteRequest.preExecute(ozoneManager);
    // Add volume and user to DB
    OMRequestTestUtils.addVolumeToDB(volumeName, ownerName, omMetadataManager);
    OMRequestTestUtils.addUserToDB(volumeName, ownerName, omMetadataManager);
    String volumeKey = omMetadataManager.getVolumeKey(volumeName);
    String ownerKey = omMetadataManager.getUserKey(ownerName);
    Assert.assertNotNull(omMetadataManager.getVolumeTable().get(volumeKey));
    Assert.assertNotNull(omMetadataManager.getUserTable().get(ownerKey));
    OMClientResponse omClientResponse = omVolumeDeleteRequest.validateAndUpdateCache(ozoneManager, 1, ozoneManagerDoubleBufferHelper);
    OzoneManagerProtocolProtos.OMResponse omResponse = omClientResponse.getOMResponse();
    Assert.assertNotNull(omResponse.getCreateVolumeResponse());
    Assert.assertEquals(OzoneManagerProtocolProtos.Status.OK, omResponse.getStatus());
    Assert.assertTrue(omMetadataManager.getUserTable().get(ownerKey).getVolumeNamesList().size() == 0);
    // As now volume is deleted, table should not have those entries.
    Assert.assertNull(omMetadataManager.getVolumeTable().get(volumeKey));
}
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 28 with OMClientResponse

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

the class TestOMVolumeDeleteRequest method testValidateAndUpdateCacheWithVolumeNotFound.

@Test
public void testValidateAndUpdateCacheWithVolumeNotFound() throws Exception {
    String volumeName = UUID.randomUUID().toString();
    OMRequest originalRequest = deleteVolumeRequest(volumeName);
    OMVolumeDeleteRequest omVolumeDeleteRequest = new OMVolumeDeleteRequest(originalRequest);
    omVolumeDeleteRequest.preExecute(ozoneManager);
    OMClientResponse omClientResponse = omVolumeDeleteRequest.validateAndUpdateCache(ozoneManager, 1, ozoneManagerDoubleBufferHelper);
    OzoneManagerProtocolProtos.OMResponse omResponse = omClientResponse.getOMResponse();
    Assert.assertNotNull(omResponse.getCreateVolumeResponse());
    Assert.assertEquals(OzoneManagerProtocolProtos.Status.VOLUME_NOT_FOUND, omResponse.getStatus());
}
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 29 with OMClientResponse

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

the class TestOMVolumeSetOwnerRequest method testOwnSameVolumeTwice.

@Test
public void testOwnSameVolumeTwice() throws Exception {
    String volumeName = UUID.randomUUID().toString();
    String owner = "user1";
    OMRequestTestUtils.addVolumeToDB(volumeName, owner, omMetadataManager);
    OMRequestTestUtils.addUserToDB(volumeName, owner, omMetadataManager);
    String newOwner = "user2";
    // Create request to set new owner
    OMRequest omRequest = OMRequestTestUtils.createSetVolumePropertyRequest(volumeName, newOwner);
    OMVolumeSetOwnerRequest setOwnerRequest = new OMVolumeSetOwnerRequest(omRequest);
    // Execute the request
    setOwnerRequest.preExecute(ozoneManager);
    OMClientResponse omClientResponse = setOwnerRequest.validateAndUpdateCache(ozoneManager, 1, ozoneManagerDoubleBufferHelper);
    // Response status should be OK and success flag should be true.
    Assert.assertEquals(OzoneManagerProtocolProtos.Status.OK, omClientResponse.getOMResponse().getStatus());
    Assert.assertTrue(omClientResponse.getOMResponse().getSuccess());
    // Execute the same request again but with higher index
    setOwnerRequest.preExecute(ozoneManager);
    omClientResponse = setOwnerRequest.validateAndUpdateCache(ozoneManager, 2, ozoneManagerDoubleBufferHelper);
    // Response status should be OK, but success flag should be false.
    Assert.assertEquals(OzoneManagerProtocolProtos.Status.OK, omClientResponse.getOMResponse().getStatus());
    Assert.assertFalse(omClientResponse.getOMResponse().getSuccess());
    // Check volume names list
    OzoneManagerStorageProtos.PersistedUserVolumeInfo userVolumeInfo = omMetadataManager.getUserTable().get(newOwner);
    Assert.assertNotNull(userVolumeInfo);
    List<String> volumeNamesList = userVolumeInfo.getVolumeNamesList();
    Assert.assertEquals(1, volumeNamesList.size());
    Set<String> volumeNamesSet = new HashSet<>(volumeNamesList);
    // If the set size isn't equal to list size, there are duplicates
    // in the list (which was the bug before the fix).
    Assert.assertEquals(volumeNamesList.size(), volumeNamesSet.size());
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) OzoneManagerStorageProtos(org.apache.hadoop.ozone.storage.proto.OzoneManagerStorageProtos) OMClientResponse(org.apache.hadoop.ozone.om.response.OMClientResponse) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 30 with OMClientResponse

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

the class TestOMVolumeSetOwnerRequest method testValidateAndUpdateCacheWithVolumeNotFound.

@Test
public void testValidateAndUpdateCacheWithVolumeNotFound() throws Exception {
    String volumeName = UUID.randomUUID().toString();
    String ownerName = "user1";
    OMRequest originalRequest = OMRequestTestUtils.createSetVolumePropertyRequest(volumeName, ownerName);
    OMVolumeSetOwnerRequest omVolumeSetOwnerRequest = new OMVolumeSetOwnerRequest(originalRequest);
    omVolumeSetOwnerRequest.preExecute(ozoneManager);
    OMClientResponse omClientResponse = omVolumeSetOwnerRequest.validateAndUpdateCache(ozoneManager, 1, ozoneManagerDoubleBufferHelper);
    OzoneManagerProtocolProtos.OMResponse omResponse = omClientResponse.getOMResponse();
    Assert.assertNotNull(omResponse.getCreateVolumeResponse());
    Assert.assertEquals(OzoneManagerProtocolProtos.Status.VOLUME_NOT_FOUND, omResponse.getStatus());
}
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)

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