Search in sources :

Example 1 with DBColumnFamilyDefinition

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

the class DBScanner method printAppropriateTable.

private void printAppropriateTable(List<ColumnFamilyHandle> columnFamilyHandleList, RocksDB rocksDB, String dbPath) throws IOException {
    if (limit < 1 && limit != -1) {
        throw new IllegalArgumentException("List length should be a positive number. Only allowed negative" + " number is -1 which is to dump entire table");
    }
    dbPath = removeTrailingSlashIfNeeded(dbPath);
    DBDefinitionFactory.setDnDBSchemaVersion(dnDBSchemaVersion);
    this.constructColumnFamilyMap(DBDefinitionFactory.getDefinition(Paths.get(dbPath)));
    if (this.columnFamilyMap != null) {
        if (!this.columnFamilyMap.containsKey(tableName)) {
            System.out.print("Table with name:" + tableName + " does not exist");
        } else {
            DBColumnFamilyDefinition columnFamilyDefinition = this.columnFamilyMap.get(tableName);
            ColumnFamilyHandle columnFamilyHandle = getColumnFamilyHandle(columnFamilyDefinition.getTableName().getBytes(StandardCharsets.UTF_8), columnFamilyHandleList);
            if (columnFamilyHandle == null) {
                throw new IllegalArgumentException("columnFamilyHandle is null");
            }
            RocksIterator iterator = rocksDB.newIterator(columnFamilyHandle);
            scannedObjects = displayTable(iterator, columnFamilyDefinition);
        }
    } else {
        System.out.println("Incorrect db Path");
    }
}
Also used : DBColumnFamilyDefinition(org.apache.hadoop.hdds.utils.db.DBColumnFamilyDefinition) RocksIterator(org.rocksdb.RocksIterator) ColumnFamilyHandle(org.rocksdb.ColumnFamilyHandle)

Example 2 with DBColumnFamilyDefinition

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

the class DBScanner method constructColumnFamilyMap.

private void constructColumnFamilyMap(DBDefinition dbDefinition) {
    if (dbDefinition == null) {
        System.out.println("Incorrect Db Path");
        return;
    }
    this.columnFamilyMap = new HashMap<>();
    DBColumnFamilyDefinition[] columnFamilyDefinitions = dbDefinition.getColumnFamilies();
    for (DBColumnFamilyDefinition definition : columnFamilyDefinitions) {
        System.out.println("Added definition for table:" + definition.getTableName());
        this.columnFamilyMap.put(definition.getTableName(), definition);
    }
}
Also used : DBColumnFamilyDefinition(org.apache.hadoop.hdds.utils.db.DBColumnFamilyDefinition)

Example 3 with DBColumnFamilyDefinition

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

the class OzoneManagerDoubleBuffer method addCleanupEntry.

private void addCleanupEntry(DoubleBufferEntry entry, Map<String, List<Long>> cleanupEpochs) {
    Class<? extends OMClientResponse> responseClass = entry.getResponse().getClass();
    CleanupTableInfo cleanupTableInfo = responseClass.getAnnotation(CleanupTableInfo.class);
    if (cleanupTableInfo != null) {
        String[] cleanupTables;
        if (cleanupTableInfo.cleanupAll()) {
            cleanupTables = Arrays.stream(new OMDBDefinition().getColumnFamilies()).map(DBColumnFamilyDefinition::getTableName).toArray(String[]::new);
        } else {
            cleanupTables = cleanupTableInfo.cleanupTables();
        }
        for (String table : cleanupTables) {
            cleanupEpochs.computeIfAbsent(table, list -> new ArrayList<>()).add(entry.getTrxLogIndex());
        }
    } else {
        // add CleanupTableInfo annotation.
        throw new RuntimeException("CleanupTableInfo Annotation is missing " + "for" + responseClass);
    }
}
Also used : TransactionInfo(org.apache.hadoop.hdds.utils.TransactionInfo) Arrays(java.util.Arrays) TRANSACTION_INFO_KEY(org.apache.hadoop.ozone.OzoneConsts.TRANSACTION_INFO_KEY) LoggerFactory(org.slf4j.LoggerFactory) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) CleanupTableInfo(org.apache.hadoop.ozone.om.response.CleanupTableInfo) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) ArrayList(java.util.ArrayList) OMClientResponse(org.apache.hadoop.ozone.om.response.OMClientResponse) Map(java.util.Map) OMResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse) BatchOperation(org.apache.hadoop.hdds.utils.db.BatchOperation) Logger(org.slf4j.Logger) DoubleBufferEntry(org.apache.hadoop.ozone.om.ratis.helpers.DoubleBufferEntry) IOException(java.io.IOException) SupplierWithIOException(org.apache.hadoop.hdds.function.SupplierWithIOException) OMDBDefinition(org.apache.hadoop.ozone.om.codec.OMDBDefinition) Collectors(java.util.stream.Collectors) Daemon(org.apache.hadoop.util.Daemon) AtomicLong(java.util.concurrent.atomic.AtomicLong) List(java.util.List) TracingUtil(org.apache.hadoop.hdds.tracing.TracingUtil) ExitUtils(org.apache.ratis.util.ExitUtils) DBColumnFamilyDefinition(org.apache.hadoop.hdds.utils.db.DBColumnFamilyDefinition) Time(org.apache.hadoop.util.Time) Preconditions(com.google.common.base.Preconditions) Queue(java.util.Queue) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Collections(java.util.Collections) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) OMMetadataManager(org.apache.hadoop.ozone.om.OMMetadataManager) OzoneManagerDoubleBufferMetrics(org.apache.hadoop.ozone.om.ratis.metrics.OzoneManagerDoubleBufferMetrics) OMDBDefinition(org.apache.hadoop.ozone.om.codec.OMDBDefinition) DBColumnFamilyDefinition(org.apache.hadoop.hdds.utils.db.DBColumnFamilyDefinition) ArrayList(java.util.ArrayList) CleanupTableInfo(org.apache.hadoop.ozone.om.response.CleanupTableInfo)

Example 4 with DBColumnFamilyDefinition

use of org.apache.hadoop.hdds.utils.db.DBColumnFamilyDefinition 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 DBColumnFamilyDefinition

use of org.apache.hadoop.hdds.utils.db.DBColumnFamilyDefinition 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

DBColumnFamilyDefinition (org.apache.hadoop.hdds.utils.db.DBColumnFamilyDefinition)6 ArrayList (java.util.ArrayList)2 DBStoreBuilder (org.apache.hadoop.hdds.utils.db.DBStoreBuilder)2 OMDBDefinition (org.apache.hadoop.ozone.om.codec.OMDBDefinition)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Preconditions (com.google.common.base.Preconditions)1 File (java.io.File)1 IOException (java.io.IOException)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Queue (java.util.Queue)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Function (java.util.function.Function)1