Search in sources :

Example 1 with DBStoreBuilder

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;
}
Also used : DBStoreBuilder(org.apache.hadoop.hdds.utils.db.DBStoreBuilder) OmKeyInfo(org.apache.hadoop.ozone.om.helpers.OmKeyInfo) RocksDBConfiguration(org.apache.hadoop.hdds.utils.db.RocksDBConfiguration) File(java.io.File)

Example 2 with DBStoreBuilder

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;
}
Also used : DBStoreBuilder(org.apache.hadoop.hdds.utils.db.DBStoreBuilder) RocksDBConfiguration(org.apache.hadoop.hdds.utils.db.RocksDBConfiguration) DBStore(org.apache.hadoop.hdds.utils.db.DBStore)

Example 3 with DBStoreBuilder

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;
    }
}
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 4 with DBStoreBuilder

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();
}
Also used : DBColumnFamilyDefinition(org.apache.hadoop.hdds.utils.db.DBColumnFamilyDefinition) DBStoreBuilder(org.apache.hadoop.hdds.utils.db.DBStoreBuilder) RocksDBConfiguration(org.apache.hadoop.hdds.utils.db.RocksDBConfiguration)

Example 5 with DBStoreBuilder

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();
}
Also used : DBColumnFamilyDefinition(org.apache.hadoop.hdds.utils.db.DBColumnFamilyDefinition) DBStoreBuilder(org.apache.hadoop.hdds.utils.db.DBStoreBuilder)

Aggregations

DBStoreBuilder (org.apache.hadoop.hdds.utils.db.DBStoreBuilder)5 RocksDBConfiguration (org.apache.hadoop.hdds.utils.db.RocksDBConfiguration)3 DBColumnFamilyDefinition (org.apache.hadoop.hdds.utils.db.DBColumnFamilyDefinition)2 DBStore (org.apache.hadoop.hdds.utils.db.DBStore)2 File (java.io.File)1 IOException (java.io.IOException)1 RDBStore (org.apache.hadoop.hdds.utils.db.RDBStore)1 OmKeyInfo (org.apache.hadoop.ozone.om.helpers.OmKeyInfo)1