Search in sources :

Example 1 with DatanodeDBProfile

use of org.apache.hadoop.ozone.container.common.utils.db.DatanodeDBProfile in project ozone by apache.

the class TestKeyValueContainer method testContainersShareColumnFamilyOptions.

@Test
public void testContainersShareColumnFamilyOptions() {
    ConfigurationSource conf = new OzoneConfiguration();
    // Make sure ColumnFamilyOptions are same for a particular db profile
    for (Supplier<DatanodeDBProfile> dbProfileSupplier : new Supplier[] { DatanodeDBProfile.Disk::new, DatanodeDBProfile.SSD::new }) {
        // ColumnFamilyOptions should be same across configurations
        ColumnFamilyOptions columnFamilyOptions1 = dbProfileSupplier.get().getColumnFamilyOptions(new OzoneConfiguration());
        ColumnFamilyOptions columnFamilyOptions2 = dbProfileSupplier.get().getColumnFamilyOptions(new OzoneConfiguration());
        Assert.assertEquals(columnFamilyOptions1, columnFamilyOptions2);
        // ColumnFamilyOptions should be same when queried multiple times
        // for a particulat configuration
        columnFamilyOptions1 = dbProfileSupplier.get().getColumnFamilyOptions(conf);
        columnFamilyOptions2 = dbProfileSupplier.get().getColumnFamilyOptions(conf);
        Assert.assertEquals(columnFamilyOptions1, columnFamilyOptions2);
    }
    // Make sure ColumnFamilyOptions are different for different db profile
    DatanodeDBProfile diskProfile = new DatanodeDBProfile.Disk();
    DatanodeDBProfile ssdProfile = new DatanodeDBProfile.SSD();
    Assert.assertNotEquals(diskProfile.getColumnFamilyOptions(new OzoneConfiguration()), ssdProfile.getColumnFamilyOptions(new OzoneConfiguration()));
    Assert.assertNotEquals(diskProfile.getColumnFamilyOptions(conf), ssdProfile.getColumnFamilyOptions(conf));
}
Also used : ColumnFamilyOptions(org.rocksdb.ColumnFamilyOptions) DatanodeDBProfile(org.apache.hadoop.ozone.container.common.utils.db.DatanodeDBProfile) ConfigurationSource(org.apache.hadoop.hdds.conf.ConfigurationSource) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) Supplier(java.util.function.Supplier) Test(org.junit.Test)

Example 2 with DatanodeDBProfile

use of org.apache.hadoop.ozone.container.common.utils.db.DatanodeDBProfile in project ozone by apache.

the class TestKeyValueContainer method testDBProfileAffectsDBOptions.

@Test
public void testDBProfileAffectsDBOptions() throws Exception {
    // Create Container 1
    keyValueContainer.create(volumeSet, volumeChoosingPolicy, scmId);
    DatanodeDBProfile outProfile1;
    try (ReferenceCountedDB db1 = BlockUtils.getDB(keyValueContainer.getContainerData(), CONF)) {
        DatanodeStore store1 = db1.getStore();
        Assert.assertTrue(store1 instanceof AbstractDatanodeStore);
        outProfile1 = ((AbstractDatanodeStore) store1).getDbProfile();
    }
    // Create Container 2 with different DBProfile in otherConf
    OzoneConfiguration otherConf = new OzoneConfiguration();
    // Use a dedicated profile for test
    otherConf.setEnum(HDDS_DB_PROFILE, DBProfile.SSD);
    keyValueContainerData = new KeyValueContainerData(2L, layout, (long) StorageUnit.GB.toBytes(5), UUID.randomUUID().toString(), datanodeId.toString());
    keyValueContainer = new KeyValueContainer(keyValueContainerData, otherConf);
    keyValueContainer.create(volumeSet, volumeChoosingPolicy, scmId);
    DatanodeDBProfile outProfile2;
    try (ReferenceCountedDB db2 = BlockUtils.getDB(keyValueContainer.getContainerData(), otherConf)) {
        DatanodeStore store2 = db2.getStore();
        Assert.assertTrue(store2 instanceof AbstractDatanodeStore);
        outProfile2 = ((AbstractDatanodeStore) store2).getDbProfile();
    }
    // DBOtions should be different
    Assert.assertNotEquals(outProfile1.getDBOptions().compactionReadaheadSize(), outProfile2.getDBOptions().compactionReadaheadSize());
}
Also used : DatanodeDBProfile(org.apache.hadoop.ozone.container.common.utils.db.DatanodeDBProfile) DatanodeStore(org.apache.hadoop.ozone.container.metadata.DatanodeStore) AbstractDatanodeStore(org.apache.hadoop.ozone.container.metadata.AbstractDatanodeStore) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) AbstractDatanodeStore(org.apache.hadoop.ozone.container.metadata.AbstractDatanodeStore) ReferenceCountedDB(org.apache.hadoop.ozone.container.common.utils.ReferenceCountedDB) Test(org.junit.Test)

Aggregations

OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)2 DatanodeDBProfile (org.apache.hadoop.ozone.container.common.utils.db.DatanodeDBProfile)2 Test (org.junit.Test)2 Supplier (java.util.function.Supplier)1 ConfigurationSource (org.apache.hadoop.hdds.conf.ConfigurationSource)1 ReferenceCountedDB (org.apache.hadoop.ozone.container.common.utils.ReferenceCountedDB)1 AbstractDatanodeStore (org.apache.hadoop.ozone.container.metadata.AbstractDatanodeStore)1 DatanodeStore (org.apache.hadoop.ozone.container.metadata.DatanodeStore)1 ColumnFamilyOptions (org.rocksdb.ColumnFamilyOptions)1