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());
}
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));
}
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());
}
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());
}
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());
}
Aggregations