Search in sources :

Example 21 with OmMetadataManagerImpl

use of org.apache.hadoop.ozone.om.OmMetadataManagerImpl in project ozone by apache.

the class TestOMDelegationTokenResponse method setup.

@Before
public void setup() throws IOException {
    conf = new OzoneConfiguration();
    ((OzoneConfiguration) conf).set(OMConfigKeys.OZONE_OM_DB_DIRS, folder.newFolder().getAbsolutePath());
    omMetadataManager = new OmMetadataManagerImpl((OzoneConfiguration) conf);
    batchOperation = omMetadataManager.getStore().initBatchOperation();
}
Also used : OmMetadataManagerImpl(org.apache.hadoop.ozone.om.OmMetadataManagerImpl) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) Before(org.junit.Before)

Example 22 with OmMetadataManagerImpl

use of org.apache.hadoop.ozone.om.OmMetadataManagerImpl in project ozone by apache.

the class TestOMVolumeDeleteResponse method setup.

@Before
public void setup() throws Exception {
    OzoneConfiguration ozoneConfiguration = new OzoneConfiguration();
    ozoneConfiguration.set(OMConfigKeys.OZONE_OM_DB_DIRS, folder.newFolder().getAbsolutePath());
    omMetadataManager = new OmMetadataManagerImpl(ozoneConfiguration);
    batchOperation = omMetadataManager.getStore().initBatchOperation();
}
Also used : OmMetadataManagerImpl(org.apache.hadoop.ozone.om.OmMetadataManagerImpl) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) Before(org.junit.Before)

Example 23 with OmMetadataManagerImpl

use of org.apache.hadoop.ozone.om.OmMetadataManagerImpl in project ozone by apache.

the class TestOMVolumeSetOwnerResponse method setup.

@Before
public void setup() throws Exception {
    OzoneConfiguration ozoneConfiguration = new OzoneConfiguration();
    ozoneConfiguration.set(OMConfigKeys.OZONE_OM_DB_DIRS, folder.newFolder().getAbsolutePath());
    omMetadataManager = new OmMetadataManagerImpl(ozoneConfiguration);
    batchOperation = omMetadataManager.getStore().initBatchOperation();
}
Also used : OmMetadataManagerImpl(org.apache.hadoop.ozone.om.OmMetadataManagerImpl) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) Before(org.junit.Before)

Example 24 with OmMetadataManagerImpl

use of org.apache.hadoop.ozone.om.OmMetadataManagerImpl in project ozone by apache.

the class TestOMDirectoryCreateResponseWithFSO method setup.

@Before
public void setup() throws Exception {
    OzoneConfiguration ozoneConfiguration = new OzoneConfiguration();
    ozoneConfiguration.set(OMConfigKeys.OZONE_OM_DB_DIRS, folder.newFolder().getAbsolutePath());
    omMetadataManager = new OmMetadataManagerImpl(ozoneConfiguration);
    batchOperation = omMetadataManager.getStore().initBatchOperation();
}
Also used : OmMetadataManagerImpl(org.apache.hadoop.ozone.om.OmMetadataManagerImpl) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) Before(org.junit.Before)

Example 25 with OmMetadataManagerImpl

use of org.apache.hadoop.ozone.om.OmMetadataManagerImpl in project ozone by apache.

the class TestOMDBUpdatesHandler method testPut.

@Test
public void testPut() throws Exception {
    OzoneConfiguration configuration = createNewTestPath();
    OmMetadataManagerImpl metaMgr = new OmMetadataManagerImpl(configuration);
    // Create 1 volume, 2 keys and write to source OM DB.
    String volumeKey = metaMgr.getVolumeKey("sampleVol");
    OmVolumeArgs args = OmVolumeArgs.newBuilder().setVolume("sampleVol").setAdminName("bilbo").setOwnerName("bilbo").build();
    metaMgr.getVolumeTable().put(volumeKey, args);
    OmKeyInfo firstKey = getOmKeyInfo("sampleVol", "bucketOne", "key_one");
    metaMgr.getKeyTable(getBucketLayout()).put("/sampleVol/bucketOne/key_one", firstKey);
    OmKeyInfo secondKey = getOmKeyInfo("sampleVol", "bucketOne", "key_two");
    metaMgr.getKeyTable(getBucketLayout()).put("/sampleVol/bucketOne/key_two", secondKey);
    // Write the secondKey to the target OM DB.
    OzoneConfiguration conf2 = createNewTestPath();
    OmMetadataManagerImpl reconOmmetaMgr = new OmMetadataManagerImpl(conf2);
    reconOmmetaMgr.getKeyTable(getBucketLayout()).put("/sampleVol/bucketOne/key_two", secondKey);
    RDBStore rdbStore = (RDBStore) metaMgr.getStore();
    RocksDB rocksDB = rdbStore.getDb();
    // Get all updates from source DB. (3 PUTs)
    TransactionLogIterator transactionLogIterator = rocksDB.getUpdatesSince(0);
    List<byte[]> writeBatches = new ArrayList<>();
    while (transactionLogIterator.isValid()) {
        TransactionLogIterator.BatchResult result = transactionLogIterator.getBatch();
        result.writeBatch().markWalTerminationPoint();
        WriteBatch writeBatch = result.writeBatch();
        writeBatches.add(writeBatch.data());
        transactionLogIterator.next();
    }
    // OMDBUpdatesHandler has access to target DB. Hence it has only the
    // "secondKey".
    OMDBUpdatesHandler omdbUpdatesHandler = new OMDBUpdatesHandler(reconOmmetaMgr);
    for (byte[] data : writeBatches) {
        WriteBatch writeBatch = new WriteBatch(data);
        // Capture the 3 PUT events from source DB.
        writeBatch.iterate(omdbUpdatesHandler);
    }
    List<OMDBUpdateEvent> events = omdbUpdatesHandler.getEvents();
    assertEquals(3, events.size());
    OMDBUpdateEvent volEvent = events.get(0);
    assertEquals(PUT, volEvent.getAction());
    assertEquals(volumeKey, volEvent.getKey());
    assertEquals(args.getVolume(), ((OmVolumeArgs) volEvent.getValue()).getVolume());
    OMDBUpdateEvent keyEvent = events.get(1);
    assertEquals(PUT, keyEvent.getAction());
    assertEquals("/sampleVol/bucketOne/key_one", keyEvent.getKey());
    assertNull(keyEvent.getOldValue());
    OMDBUpdateEvent updateEvent = events.get(2);
    assertEquals(UPDATE, updateEvent.getAction());
    assertEquals("/sampleVol/bucketOne/key_two", updateEvent.getKey());
    assertNotNull(updateEvent.getOldValue());
    assertEquals(secondKey.getKeyName(), ((OmKeyInfo) updateEvent.getOldValue()).getKeyName());
}
Also used : RocksDB(org.rocksdb.RocksDB) OmVolumeArgs(org.apache.hadoop.ozone.om.helpers.OmVolumeArgs) ArrayList(java.util.ArrayList) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) TransactionLogIterator(org.rocksdb.TransactionLogIterator) OmMetadataManagerImpl(org.apache.hadoop.ozone.om.OmMetadataManagerImpl) OmKeyInfo(org.apache.hadoop.ozone.om.helpers.OmKeyInfo) WriteBatch(org.rocksdb.WriteBatch) RDBStore(org.apache.hadoop.hdds.utils.db.RDBStore) Test(org.junit.Test)

Aggregations

OmMetadataManagerImpl (org.apache.hadoop.ozone.om.OmMetadataManagerImpl)36 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)34 Before (org.junit.Before)25 OzoneManager (org.apache.hadoop.ozone.om.OzoneManager)12 AuditLogger (org.apache.hadoop.ozone.audit.AuditLogger)7 AuditMessage (org.apache.hadoop.ozone.audit.AuditMessage)7 OMMetadataManager (org.apache.hadoop.ozone.om.OMMetadataManager)6 Test (org.junit.Test)6 OmBucketInfo (org.apache.hadoop.ozone.om.helpers.OmBucketInfo)5 OmVolumeArgs (org.apache.hadoop.ozone.om.helpers.OmVolumeArgs)5 OMClientRequest (org.apache.hadoop.ozone.om.request.OMClientRequest)5 ResolvedBucket (org.apache.hadoop.ozone.om.ResolvedBucket)4 KeyArgs (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyArgs)4 ArrayList (java.util.ArrayList)3 OMLayoutVersionManager (org.apache.hadoop.ozone.om.upgrade.OMLayoutVersionManager)3 File (java.io.File)2 Path (java.nio.file.Path)2 Random (java.util.Random)2 SecurityConfig (org.apache.hadoop.hdds.security.x509.SecurityConfig)2 RDBStore (org.apache.hadoop.hdds.utils.db.RDBStore)2