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