Search in sources :

Example 6 with DBStore

use of org.apache.hadoop.hdds.utils.db.DBStore in project ozone by apache.

the class ReconDBProvider method provideReconDB.

public DBStore provideReconDB() {
    DBStore db;
    File reconDbDir = reconUtils.getReconDbDir(configuration, OZONE_RECON_DB_DIR);
    File lastKnownContainerKeyDb = reconUtils.getLastKnownDB(reconDbDir, RECON_CONTAINER_KEY_DB);
    if (lastKnownContainerKeyDb != null) {
        LOG.info("Last known Recon DB : {}", lastKnownContainerKeyDb.getAbsolutePath());
        db = initializeDBStore(configuration, lastKnownContainerKeyDb.getName());
    } else {
        db = getNewDBStore(configuration);
    }
    if (db == null) {
        throw new ProvisionException("Unable to provide instance of DBStore " + "store.");
    }
    return db;
}
Also used : ProvisionException(com.google.inject.ProvisionException) DBStore(org.apache.hadoop.hdds.utils.db.DBStore) File(java.io.File)

Example 7 with DBStore

use of org.apache.hadoop.hdds.utils.db.DBStore in project ozone by apache.

the class ReconOmMetadataManagerImpl method initializeNewRdbStore.

/**
 * Replace existing DB instance with new one.
 *
 * @param dbFile new DB file location.
 */
private void initializeNewRdbStore(File dbFile) throws IOException {
    try {
        DBStoreBuilder dbStoreBuilder = DBStoreBuilder.newBuilder(ozoneConfiguration).setName(dbFile.getName()).setPath(dbFile.toPath().getParent());
        addOMTablesAndCodecs(dbStoreBuilder);
        DBStore newStore = dbStoreBuilder.build();
        setStore(newStore);
        LOG.info("Created OM DB handle from snapshot at {}.", dbFile.getAbsolutePath());
    } catch (IOException ioEx) {
        LOG.error("Unable to initialize Recon OM DB snapshot store.", ioEx);
    }
    if (getStore() != null) {
        initializeOmTables();
        omTablesInitialized = true;
    }
}
Also used : DBStoreBuilder(org.apache.hadoop.hdds.utils.db.DBStoreBuilder) IOException(java.io.IOException) DBStore(org.apache.hadoop.hdds.utils.db.DBStore) RDBStore(org.apache.hadoop.hdds.utils.db.RDBStore)

Example 8 with DBStore

use of org.apache.hadoop.hdds.utils.db.DBStore in project ozone by apache.

the class ReconStorageContainerManagerFacade method initializeNewRdbStore.

private void initializeNewRdbStore(File dbFile) throws IOException {
    try {
        DBStore newStore = createDBAndAddSCMTablesAndCodecs(dbFile, new ReconSCMDBDefinition());
        Table<UUID, DatanodeDetails> nodeTable = ReconSCMDBDefinition.NODES.getTable(dbStore);
        Table<UUID, DatanodeDetails> newNodeTable = ReconSCMDBDefinition.NODES.getTable(newStore);
        TableIterator<UUID, ? extends KeyValue<UUID, DatanodeDetails>> iterator = nodeTable.iterator();
        while (iterator.hasNext()) {
            KeyValue<UUID, DatanodeDetails> keyValue = iterator.next();
            newNodeTable.put(keyValue.getKey(), keyValue.getValue());
        }
        sequenceIdGen.reinitialize(ReconSCMDBDefinition.SEQUENCE_ID.getTable(newStore));
        pipelineManager.reinitialize(ReconSCMDBDefinition.PIPELINES.getTable(newStore));
        containerManager.reinitialize(ReconSCMDBDefinition.CONTAINERS.getTable(newStore));
        nodeManager.reinitialize(ReconSCMDBDefinition.NODES.getTable(newStore));
        deleteOldSCMDB();
        setDbStore(newStore);
        File newDb = new File(dbFile.getParent() + OZONE_URI_DELIMITER + ReconSCMDBDefinition.RECON_SCM_DB_NAME);
        boolean success = dbFile.renameTo(newDb);
        if (success) {
            LOG.info("SCM snapshot linked to Recon DB.");
        }
        LOG.info("Created SCM DB handle from snapshot at {}.", dbFile.getAbsolutePath());
    } catch (IOException ioEx) {
        LOG.error("Unable to initialize Recon SCM DB snapshot store.", ioEx);
    }
}
Also used : DatanodeDetails(org.apache.hadoop.hdds.protocol.DatanodeDetails) IOException(java.io.IOException) DBStore(org.apache.hadoop.hdds.utils.db.DBStore) UUID(java.util.UUID) File(java.io.File)

Aggregations

DBStore (org.apache.hadoop.hdds.utils.db.DBStore)8 File (java.io.File)4 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)2 UUID (java.util.UUID)2 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)2 DatanodeDetails (org.apache.hadoop.hdds.protocol.DatanodeDetails)2 SCMDBDefinition (org.apache.hadoop.hdds.scm.metadata.SCMDBDefinition)2 PipelineID (org.apache.hadoop.hdds.scm.pipeline.PipelineID)2 DBStoreBuilder (org.apache.hadoop.hdds.utils.db.DBStoreBuilder)2 Test (org.junit.jupiter.api.Test)2 Longs (com.google.common.primitives.Longs)1 ProvisionException (com.google.inject.ProvisionException)1 Instant (java.time.Instant)1 ZoneId (java.time.ZoneId)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1