use of org.apache.hadoop.hdds.utils.db.DBStoreBuilder in project ozone by apache.
the class GeneratorOm method call.
@Override
public Void call() throws Exception {
init();
setThreadNo(1);
config = createOzoneConfiguration();
File metaDir = OMStorage.getOmDbDir(config);
RocksDBConfiguration rocksDBConfiguration = config.getObject(RocksDBConfiguration.class);
DBStoreBuilder dbStoreBuilder = DBStoreBuilder.newBuilder(config, rocksDBConfiguration).setName(OM_DB_NAME).setPath(metaDir.toPath());
OmMetadataManagerImpl.addOMTablesAndCodecs(dbStoreBuilder);
omDb = dbStoreBuilder.build();
// initialization: create one bucket and volume in OM.
writeOmBucketVolume();
omKeyTable = omDb.getTable(OmMetadataManagerImpl.KEY_TABLE, String.class, OmKeyInfo.class);
timer = getMetrics().timer("om-generator");
runTests(this::writeOmKeys);
omDb.close();
return null;
}
use of org.apache.hadoop.hdds.utils.db.DBStoreBuilder in project ozone by apache.
the class OmMetadataManagerImpl method loadDB.
public static DBStore loadDB(OzoneConfiguration configuration, File metaDir, String dbName) throws IOException {
RocksDBConfiguration rocksDBConfiguration = configuration.getObject(RocksDBConfiguration.class);
DBStoreBuilder dbStoreBuilder = DBStoreBuilder.newBuilder(configuration, rocksDBConfiguration).setName(dbName).setPath(Paths.get(metaDir.getPath()));
DBStore dbStore = addOMTablesAndCodecs(dbStoreBuilder).build();
return dbStore;
}
use of org.apache.hadoop.hdds.utils.db.DBStoreBuilder 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.DBStoreBuilder in project ozone by apache.
the class HAUtils method loadDB.
public static DBStore loadDB(OzoneConfiguration configuration, File metaDir, String dbName, DBDefinition definition) throws IOException {
RocksDBConfiguration rocksDBConfiguration = configuration.getObject(RocksDBConfiguration.class);
DBStoreBuilder dbStoreBuilder = DBStoreBuilder.newBuilder(configuration, rocksDBConfiguration).setName(dbName).setPath(Paths.get(metaDir.getPath()));
// Add column family names and codecs.
for (DBColumnFamilyDefinition columnFamily : definition.getColumnFamilies()) {
dbStoreBuilder.addTable(columnFamily.getName());
dbStoreBuilder.addCodec(columnFamily.getKeyType(), columnFamily.getKeyCodec());
dbStoreBuilder.addCodec(columnFamily.getValueType(), columnFamily.getValueCodec());
}
return dbStoreBuilder.build();
}
use of org.apache.hadoop.hdds.utils.db.DBStoreBuilder in project ozone by apache.
the class ReconStorageContainerManagerFacade method createDBAndAddSCMTablesAndCodecs.
private DBStore createDBAndAddSCMTablesAndCodecs(File dbFile, ReconSCMDBDefinition definition) throws IOException {
DBStoreBuilder dbStoreBuilder = DBStoreBuilder.newBuilder(ozoneConfiguration).setName(dbFile.getName()).setPath(dbFile.toPath().getParent());
for (DBColumnFamilyDefinition columnFamily : definition.getColumnFamilies()) {
dbStoreBuilder.addTable(columnFamily.getName());
dbStoreBuilder.addCodec(columnFamily.getKeyType(), columnFamily.getKeyCodec());
dbStoreBuilder.addCodec(columnFamily.getValueType(), columnFamily.getValueCodec());
}
return dbStoreBuilder.build();
}
Aggregations