Search in sources :

Example 1 with DatanodeSchemaTwoDBDefinition

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);
}
Also used : Path(java.nio.file.Path) DatanodeSchemaTwoDBDefinition(org.apache.hadoop.ozone.container.metadata.DatanodeSchemaTwoDBDefinition) DatanodeSchemaOneDBDefinition(org.apache.hadoop.ozone.container.metadata.DatanodeSchemaOneDBDefinition) InvalidArnException(com.amazonaws.services.kms.model.InvalidArnException)

Example 2 with DatanodeSchemaTwoDBDefinition

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);
}
Also used : ReconSCMDBDefinition(org.apache.hadoop.ozone.recon.scm.ReconSCMDBDefinition) DatanodeSchemaOneDBDefinition(org.apache.hadoop.ozone.container.metadata.DatanodeSchemaOneDBDefinition) SCMDBDefinition(org.apache.hadoop.hdds.scm.metadata.SCMDBDefinition) DatanodeSchemaTwoDBDefinition(org.apache.hadoop.ozone.container.metadata.DatanodeSchemaTwoDBDefinition) ReconDBDefinition(org.apache.hadoop.ozone.recon.spi.impl.ReconDBDefinition) DBDefinition(org.apache.hadoop.hdds.utils.db.DBDefinition) OMDBDefinition(org.apache.hadoop.ozone.om.codec.OMDBDefinition) OMDBDefinition(org.apache.hadoop.ozone.om.codec.OMDBDefinition) DatanodeSchemaTwoDBDefinition(org.apache.hadoop.ozone.container.metadata.DatanodeSchemaTwoDBDefinition) ReconSCMDBDefinition(org.apache.hadoop.ozone.recon.scm.ReconSCMDBDefinition) SCMDBDefinition(org.apache.hadoop.hdds.scm.metadata.SCMDBDefinition) ReconSCMDBDefinition(org.apache.hadoop.ozone.recon.scm.ReconSCMDBDefinition) ReconDBDefinition(org.apache.hadoop.ozone.recon.spi.impl.ReconDBDefinition) DatanodeSchemaOneDBDefinition(org.apache.hadoop.ozone.container.metadata.DatanodeSchemaOneDBDefinition) Test(org.junit.Test)

Aggregations

DatanodeSchemaOneDBDefinition (org.apache.hadoop.ozone.container.metadata.DatanodeSchemaOneDBDefinition)2 DatanodeSchemaTwoDBDefinition (org.apache.hadoop.ozone.container.metadata.DatanodeSchemaTwoDBDefinition)2 InvalidArnException (com.amazonaws.services.kms.model.InvalidArnException)1 Path (java.nio.file.Path)1 SCMDBDefinition (org.apache.hadoop.hdds.scm.metadata.SCMDBDefinition)1 DBDefinition (org.apache.hadoop.hdds.utils.db.DBDefinition)1 OMDBDefinition (org.apache.hadoop.ozone.om.codec.OMDBDefinition)1 ReconSCMDBDefinition (org.apache.hadoop.ozone.recon.scm.ReconSCMDBDefinition)1 ReconDBDefinition (org.apache.hadoop.ozone.recon.spi.impl.ReconDBDefinition)1 Test (org.junit.Test)1