Search in sources :

Example 1 with OmVolumeArgs

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);
}
Also used : OmVolumeArgs(org.apache.hadoop.ozone.om.helpers.OmVolumeArgs) MetricsRecordBuilder(org.apache.hadoop.metrics2.MetricsRecordBuilder) Test(org.junit.Test)

Example 2 with OmVolumeArgs

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);
}
Also used : OmVolumeArgs(org.apache.hadoop.ozone.om.helpers.OmVolumeArgs)

Example 3 with OmVolumeArgs

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());
}
Also used : OmBucketInfo(org.apache.hadoop.ozone.om.helpers.OmBucketInfo) OzoneManagerProtocolClientSideTranslatorPB(org.apache.hadoop.ozone.om.protocolPB.OzoneManagerProtocolClientSideTranslatorPB) ObjectStore(org.apache.hadoop.ozone.client.ObjectStore) OmVolumeArgs(org.apache.hadoop.ozone.om.helpers.OmVolumeArgs) OzoneOutputStream(org.apache.hadoop.ozone.client.io.OzoneOutputStream) OzoneClient(org.apache.hadoop.ozone.client.OzoneClient) OzoneVolume(org.apache.hadoop.ozone.client.OzoneVolume) OmKeyInfo(org.apache.hadoop.ozone.om.helpers.OmKeyInfo) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) Test(org.junit.Test)

Example 4 with OmVolumeArgs

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;
}
Also used : OmVolumeArgs(org.apache.hadoop.ozone.om.helpers.OmVolumeArgs)

Example 5 with OmVolumeArgs

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

Aggregations

OmVolumeArgs (org.apache.hadoop.ozone.om.helpers.OmVolumeArgs)70 OMException (org.apache.hadoop.ozone.om.exceptions.OMException)19 IOException (java.io.IOException)18 Test (org.junit.Test)18 OmBucketInfo (org.apache.hadoop.ozone.om.helpers.OmBucketInfo)16 OMResponse (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse)15 OMClientResponse (org.apache.hadoop.ozone.om.response.OMClientResponse)13 OMMetadataManager (org.apache.hadoop.ozone.om.OMMetadataManager)12 ArrayList (java.util.ArrayList)9 OMMetrics (org.apache.hadoop.ozone.om.OMMetrics)8 OzoneManagerProtocolProtos (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos)7 OMRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest)7 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)6 OzoneAcl (org.apache.hadoop.ozone.OzoneAcl)6 PersistedUserVolumeInfo (org.apache.hadoop.ozone.storage.proto.OzoneManagerStorageProtos.PersistedUserVolumeInfo)6 AuditLogger (org.apache.hadoop.ozone.audit.AuditLogger)5 OmMetadataManagerImpl (org.apache.hadoop.ozone.om.OmMetadataManagerImpl)5 OmKeyInfo (org.apache.hadoop.ozone.om.helpers.OmKeyInfo)5 CertificateSignRequest.getEncodedString (org.apache.hadoop.hdds.security.x509.certificates.utils.CertificateSignRequest.getEncodedString)4 GET (javax.ws.rs.GET)3