use of org.apache.hadoop.ozone.om.codec.OMDBDefinition in project ozone by apache.
the class TestDBDefinitionFactory method testGetDefinition.
@Test
public void testGetDefinition() {
DBDefinition definition = DBDefinitionFactory.getDefinition(new OMDBDefinition().getName());
assertTrue(definition instanceof OMDBDefinition);
definition = DBDefinitionFactory.getDefinition(new SCMDBDefinition().getName());
assertTrue(definition instanceof SCMDBDefinition);
definition = DBDefinitionFactory.getDefinition(new ReconSCMDBDefinition().getName());
assertTrue(definition instanceof ReconSCMDBDefinition);
definition = DBDefinitionFactory.getDefinition(RECON_OM_SNAPSHOT_DB + "_1");
assertTrue(definition instanceof OMDBDefinition);
definition = DBDefinitionFactory.getDefinition(RECON_CONTAINER_KEY_DB + "_1");
assertTrue(definition instanceof ReconDBDefinition);
DBDefinitionFactory.setDnDBSchemaVersion("V2");
definition = DBDefinitionFactory.getDefinition(Paths.get("/tmp/test-container.db"));
assertTrue(definition instanceof DatanodeSchemaTwoDBDefinition);
DBDefinitionFactory.setDnDBSchemaVersion("V1");
definition = DBDefinitionFactory.getDefinition(Paths.get("/tmp/test-container.db"));
assertTrue(definition instanceof DatanodeSchemaOneDBDefinition);
}
use of org.apache.hadoop.ozone.om.codec.OMDBDefinition in project ozone by apache.
the class OzoneManagerDoubleBuffer method addCleanupEntry.
private void addCleanupEntry(DoubleBufferEntry entry, Map<String, List<Long>> cleanupEpochs) {
Class<? extends OMClientResponse> responseClass = entry.getResponse().getClass();
CleanupTableInfo cleanupTableInfo = responseClass.getAnnotation(CleanupTableInfo.class);
if (cleanupTableInfo != null) {
String[] cleanupTables;
if (cleanupTableInfo.cleanupAll()) {
cleanupTables = Arrays.stream(new OMDBDefinition().getColumnFamilies()).map(DBColumnFamilyDefinition::getTableName).toArray(String[]::new);
} else {
cleanupTables = cleanupTableInfo.cleanupTables();
}
for (String table : cleanupTables) {
cleanupEpochs.computeIfAbsent(table, list -> new ArrayList<>()).add(entry.getTrxLogIndex());
}
} else {
// add CleanupTableInfo annotation.
throw new RuntimeException("CleanupTableInfo Annotation is missing " + "for" + responseClass);
}
}
use of org.apache.hadoop.ozone.om.codec.OMDBDefinition in project ozone by apache.
the class TestOMDBDefinition method testDBDefinition.
@Test
public void testDBDefinition() throws Exception {
OzoneConfiguration configuration = new OzoneConfiguration();
File metaDir = folder.getRoot();
DBStore store = OmMetadataManagerImpl.loadDB(configuration, metaDir);
OMDBDefinition dbDef = new OMDBDefinition();
// Get list of tables from DB Definitions
DBColumnFamilyDefinition[] columnFamilyDefinitions = dbDef.getColumnFamilies();
int countOmDefTables = columnFamilyDefinitions.length;
ArrayList<String> missingDBDefTables = new ArrayList<>();
// Get list of tables from the RocksDB Store
Collection<String> missingOmDBTables = store.getTableNames().values();
missingOmDBTables.remove("default");
int countOmDBTables = missingOmDBTables.size();
// Remove the file if it is found in both the datastructures
for (DBColumnFamilyDefinition definition : columnFamilyDefinitions) {
if (!missingOmDBTables.remove(definition.getName())) {
missingDBDefTables.add(definition.getName());
}
}
Assert.assertEquals("Tables in OmMetadataManagerImpl are:" + missingDBDefTables, 0, missingDBDefTables.size());
Assert.assertEquals("Tables missing in OMDBDefinition are:" + missingOmDBTables, 0, missingOmDBTables.size());
Assert.assertEquals(countOmDBTables, countOmDefTables);
}
Aggregations