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