use of org.apache.hadoop.ozone.container.metadata.DatanodeSchemaTwoDBDefinition in project ozone by apache.
the class DBDefinitionFactory method getDefinition.
public static DBDefinition getDefinition(Path dbPath) {
Preconditions.checkNotNull(dbPath, "Path is required to identify the used db scheme");
final Path fileName = dbPath.getFileName();
if (fileName == null) {
throw new InvalidArnException("Path is required to identify the used db scheme");
}
String dbName = fileName.toString();
if (dbName.endsWith("-container.db")) {
switch(dnDBSchemaVersion) {
case "V1":
return new DatanodeSchemaOneDBDefinition(dbPath.toAbsolutePath().toString());
default:
return new DatanodeSchemaTwoDBDefinition(dbPath.toAbsolutePath().toString());
}
}
return getDefinition(dbName);
}
use of org.apache.hadoop.ozone.container.metadata.DatanodeSchemaTwoDBDefinition 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);
}
Aggregations