use of org.apache.hadoop.ozone.om.helpers.OmVolumeArgs in project ozone by apache.
the class TestOmMetrics method testVolumeOps.
@Test
public void testVolumeOps() throws Exception {
startCluster();
VolumeManager volumeManager = (VolumeManager) HddsWhiteboxTestUtils.getInternalState(ozoneManager, "volumeManager");
VolumeManager mockVm = Mockito.spy(volumeManager);
OmVolumeArgs volumeArgs = createVolumeArgs();
doVolumeOps(volumeArgs);
MetricsRecordBuilder omMetrics = getMetrics("OMMetrics");
assertCounter("NumVolumeOps", 5L, omMetrics);
assertCounter("NumVolumeCreates", 1L, omMetrics);
assertCounter("NumVolumeUpdates", 1L, omMetrics);
assertCounter("NumVolumeInfos", 1L, omMetrics);
assertCounter("NumVolumeDeletes", 1L, omMetrics);
assertCounter("NumVolumeLists", 1L, omMetrics);
assertCounter("NumVolumes", 1L, omMetrics);
volumeArgs = createVolumeArgs();
writeClient.createVolume(volumeArgs);
volumeArgs = createVolumeArgs();
writeClient.createVolume(volumeArgs);
volumeArgs = createVolumeArgs();
writeClient.createVolume(volumeArgs);
writeClient.deleteVolume(volumeArgs.getVolume());
omMetrics = getMetrics("OMMetrics");
// Accounting 's3v' volume which is created by default.
assertCounter("NumVolumes", 3L, omMetrics);
// inject exception to test for Failure Metrics on the read path
Mockito.doThrow(exception).when(mockVm).getVolumeInfo(any());
Mockito.doThrow(exception).when(mockVm).listVolumes(any(), any(), any(), anyInt());
HddsWhiteboxTestUtils.setInternalState(ozoneManager, "volumeManager", mockVm);
// inject exception to test for Failure Metrics on the write path
mockWritePathExceptions(OmVolumeArgs.class);
volumeArgs = createVolumeArgs();
doVolumeOps(volumeArgs);
omMetrics = getMetrics("OMMetrics");
assertCounter("NumVolumeOps", 14L, omMetrics);
assertCounter("NumVolumeCreates", 5L, omMetrics);
assertCounter("NumVolumeUpdates", 2L, omMetrics);
assertCounter("NumVolumeInfos", 2L, omMetrics);
assertCounter("NumVolumeDeletes", 3L, omMetrics);
assertCounter("NumVolumeLists", 2L, omMetrics);
assertCounter("NumVolumeCreateFails", 1L, omMetrics);
assertCounter("NumVolumeUpdateFails", 1L, omMetrics);
assertCounter("NumVolumeInfoFails", 1L, omMetrics);
assertCounter("NumVolumeDeleteFails", 1L, omMetrics);
assertCounter("NumVolumeListFails", 1L, omMetrics);
// As last call for volumesOps does not increment numVolumes as those are
// failed.
assertCounter("NumVolumes", 3L, omMetrics);
cluster.restartOzoneManager();
assertCounter("NumVolumes", 3L, omMetrics);
}
use of org.apache.hadoop.ozone.om.helpers.OmVolumeArgs in project ozone by apache.
the class TestKeyManagerImpl method createVolume.
private static void createVolume(String volumeName) throws IOException {
OmVolumeArgs volumeArgs = OmVolumeArgs.newBuilder().setVolume(volumeName).setAdminName("bilbo").setOwnerName("bilbo").build();
OMRequestTestUtils.addVolumeToOM(metadataManager, volumeArgs);
}
use of org.apache.hadoop.ozone.om.helpers.OmVolumeArgs in project ozone by apache.
the class TestOMEpochForNonRatis method testUniqueTrxnIndexOnOMRestart.
@Test
public void testUniqueTrxnIndexOnOMRestart() throws Exception {
// When OM is restarted, the transaction index for requests should not
// start from 0. It should incrementally increase from the last
// transaction index which was stored in DB before restart.
String volumeName = "volume" + RandomStringUtils.randomNumeric(5);
String bucketName = "bucket" + RandomStringUtils.randomNumeric(5);
String keyName = "key" + RandomStringUtils.randomNumeric(5);
OzoneManager om = cluster.getOzoneManager();
OzoneClient client = cluster.getClient();
ObjectStore objectStore = client.getObjectStore();
UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
OzoneManagerProtocolClientSideTranslatorPB omClient = new OzoneManagerProtocolClientSideTranslatorPB(OmTransportFactory.create(conf, ugi, null), RandomStringUtils.randomAscii(5));
objectStore.createVolume(volumeName);
// Verify that the last transactionIndex stored in DB after volume
// creation equals the transaction index corresponding to volume's
// objectID. Also, the volume transaction index should be 1 as this is
// the first transaction in this cluster.
OmVolumeArgs volumeInfo = omClient.getVolumeInfo(volumeName);
long volumeTrxnIndex = OmUtils.getTxIdFromObjectId(volumeInfo.getObjectID());
Assert.assertEquals(1, volumeTrxnIndex);
Assert.assertEquals(volumeTrxnIndex, om.getLastTrxnIndexForNonRatis());
OzoneVolume ozoneVolume = objectStore.getVolume(volumeName);
ozoneVolume.createBucket(bucketName);
// Verify last transactionIndex is updated after bucket creation
OmBucketInfo bucketInfo = omClient.getBucketInfo(volumeName, bucketName);
long bucketTrxnIndex = OmUtils.getTxIdFromObjectId(bucketInfo.getObjectID());
Assert.assertEquals(2, bucketTrxnIndex);
Assert.assertEquals(bucketTrxnIndex, om.getLastTrxnIndexForNonRatis());
// Restart the OM and create new object
cluster.restartOzoneManager();
String data = "random data";
OzoneOutputStream ozoneOutputStream = ozoneVolume.getBucket(bucketName).createKey(keyName, data.length(), ReplicationType.RATIS, ReplicationFactor.ONE, new HashMap<>());
ozoneOutputStream.write(data.getBytes(UTF_8), 0, data.length());
ozoneOutputStream.close();
// Verify last transactionIndex is updated after key creation and the
// transaction index after restart is incremented from the last
// transaction index before restart.
OmKeyInfo omKeyInfo = omClient.lookupKey(new OmKeyArgs.Builder().setVolumeName(volumeName).setBucketName(bucketName).setKeyName(keyName).setRefreshPipeline(true).build());
long keyTrxnIndex = OmUtils.getTxIdFromObjectId(omKeyInfo.getObjectID());
Assert.assertEquals(3, keyTrxnIndex);
// Key commit is a separate transaction. Hence, the last trxn index in DB
// should be 1 more than KeyTrxnIndex
Assert.assertEquals(4, om.getLastTrxnIndexForNonRatis());
}
use of org.apache.hadoop.ozone.om.helpers.OmVolumeArgs in project ozone by apache.
the class TestOMOpenKeysDeleteRequest method getVolumeFromCache.
private OmVolumeArgs getVolumeFromCache(String volume) {
String volumeKey = omMetadataManager.getVolumeKey(volume);
CacheValue<OmVolumeArgs> value = omMetadataManager.getVolumeTable().getCacheValue(new CacheKey<>(volumeKey));
OmVolumeArgs result = null;
if (value != null) {
result = value.getCacheValue();
}
return result;
}
use of org.apache.hadoop.ozone.om.helpers.OmVolumeArgs in project ozone by apache.
the class TestOMVolumeAddAclRequest method testValidateAndUpdateCacheSuccess.
@Test
public void testValidateAndUpdateCacheSuccess() throws Exception {
String volumeName = UUID.randomUUID().toString();
String ownerName = "user1";
OMRequestTestUtils.addUserToDB(volumeName, ownerName, omMetadataManager);
OMRequestTestUtils.addVolumeToDB(volumeName, ownerName, omMetadataManager);
OzoneAcl acl = OzoneAcl.parseAcl("user:bilbo:rwdlncxy[ACCESS]");
OMRequest originalRequest = OMRequestTestUtils.createVolumeAddAclRequest(volumeName, acl);
OMVolumeAddAclRequest omVolumeAddAclRequest = new OMVolumeAddAclRequest(originalRequest);
omVolumeAddAclRequest.preExecute(ozoneManager);
String volumeKey = omMetadataManager.getVolumeKey(volumeName);
// Get Acl before validateAndUpdateCache.
OmVolumeArgs omVolumeArgs = omMetadataManager.getVolumeTable().get(volumeKey);
// As request is valid volume table should have entry.
Assert.assertNotNull(omVolumeArgs);
OMClientResponse omClientResponse = omVolumeAddAclRequest.validateAndUpdateCache(ozoneManager, 1, ozoneManagerDoubleBufferHelper);
OMResponse omResponse = omClientResponse.getOMResponse();
Assert.assertNotNull(omResponse.getAddAclResponse());
Assert.assertEquals(OzoneManagerProtocolProtos.Status.OK, omResponse.getStatus());
List<OzoneAcl> aclsAfterSet = omMetadataManager.getVolumeTable().get(volumeKey).getAcls();
// acl is added to aclMapAfterSet
Assert.assertEquals(1, aclsAfterSet.size());
Assert.assertEquals(acl, aclsAfterSet.get(0));
}
Aggregations