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