ivandika3 commented on code in PR #8818:
URL: https://github.com/apache/ozone/pull/8818#discussion_r2224850872
##########
hadoop-hdds/managed-rocksdb/src/main/java/org/apache/hadoop/hdds/utils/db/managed/ManagedRocksDB.java:
##########
@@ -85,13 +86,28 @@ public static ManagedRocksDB open(
);
}
- public static ManagedRocksDB open(
- final String path,
+ /**
+ * Open a RocksDB option with the latest options. Other than {@link
ManagedConfigOptions} and
+ * path, the other options and handles should be empty since it will be
populated with
+ * loadLatestOptions. Nevertheless, the caller is still responsible in
cleaning up / closing the resources.
+ * @param configOptions Config options.
+ * @param options DBOptions. This would be modified based on the latest
options.
+ * @param path DB path.
+ * @param columnFamilyDescriptors Column family descriptors. These would be
modified based on the latest options.
+ * @param columnFamilyHandles Column family handles. The underlying column
family
+ * @return A RocksDB instance.
+ * @throws RocksDBException exception if thrown when opening a RocksDB
instance.
Review Comment:
Thanks for catching this. Fixed. The RocksDBException is taken verbatim from
the `RocksDB#open` javadoc.
##########
hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/repair/ldb/TestLdbRepair.java:
##########
@@ -165,4 +178,169 @@ private long calculateSstFileSize(Path db) throws
IOException {
.sum();
}
}
+
+ /**
+ * Helper method to read the latest RocksDB options from a database and test
column family.
+ */
+ private DatabaseOptions readDatabaseOptions() throws Exception {
+ assertNotNull(dbPath);
+ ManagedConfigOptions configOptions = new ManagedConfigOptions();
+ ManagedDBOptions dbOptions = new ManagedDBOptions();
+ List<ColumnFamilyHandle> cfHandleList = new ArrayList<>();
+ List<ColumnFamilyDescriptor> cfDescList = new ArrayList<>();
+
+ try {
+ try (ManagedRocksDB db = ManagedRocksDB.openWithLatestOptions(
+ configOptions, dbOptions, dbPath.toString(), cfDescList,
cfHandleList)) {
+ DatabaseOptions.Builder builder = new DatabaseOptions.Builder();
+
builder.setMaxBackgroundCompactions(dbOptions.maxBackgroundCompactions())
+ .setMaxBackgroundFlushes(dbOptions.maxBackgroundFlushes())
+ .setBytesPerSync(dbOptions.bytesPerSync())
+ .setMaxLogFileSize(dbOptions.maxLogFileSize())
+ .setKeepLogFileNum(dbOptions.keepLogFileNum())
+ .setWalTTL(dbOptions.walTtlSeconds())
+ .setWalSizeLimit(dbOptions.walSizeLimitMB());
+
+ Optional<ColumnFamilyDescriptor> testCfDesc =
cfDescList.stream().filter(cfDesc ->
+
TableConfig.toName(cfDesc.getName()).equals(TEST_CF_NAME)).findFirst();
+ if (testCfDesc.isPresent()) {
+ ColumnFamilyOptions cfOptions = testCfDesc.get().getOptions();
+ builder.setWriteBufferSize(cfOptions.writeBufferSize());
+ if (cfOptions.tableFormatConfig() instanceof
ManagedBlockBasedTableConfig) {
+ ManagedBlockBasedTableConfig tableConfig =
(ManagedBlockBasedTableConfig) cfOptions.tableFormatConfig();
+ builder.setBlockSize(tableConfig.blockSize());
+
builder.setPinL0FilterAndIndexBlocksInCache(tableConfig.pinL0FilterAndIndexBlocksInCache());
+ }
+ }
+ return builder.build();
+ }
+ } finally {
+ configOptions.close();
+ dbOptions.close();
+ IOUtils.closeQuietly(cfHandleList);
+ }
+ }
+
+ /**
+ * Simple data class to hold database options for comparison.
+ * This consist of sampled options from the options set in {@link
org.apache.hadoop.hdds.utils.db.DBProfile}.
+ */
+ private static final class DatabaseOptions {
+ // DBOptions
+ private final int maxBackgroundCompactions;
+ private final int maxBackgroundFlushes;
+ private final long bytesPerSync;
+ private final long maxLogFileSize;
+ private final long keepLogFileNum;
+ private final long walTTL;
+ private final long walSizeLimit;
+
+ // ColumnFamilyOptions
+ private final long writeBufferSize;
+ // BlockBasedTableConfig
+ private final long blockSize;
+ private final boolean pinL0FilterAndIndexBlocksInCache;
+
+ private DatabaseOptions(Builder b) {
+ this.maxBackgroundCompactions = b.maxBackgroundCompactions;
+ this.maxBackgroundFlushes = b.maxBackgroundFlushes;
+ this.bytesPerSync = b.bytesPerSync;
+ this.maxLogFileSize = b.maxLogFileSize;
+ this.keepLogFileNum = b.keepLogFileNum;
+ this.walTTL = b.walTTL;
+ this.walSizeLimit = b.walSizeLimit;
+ this.writeBufferSize = b.writeBufferSize;
+ this.blockSize = b.blockSize;
+ this.pinL0FilterAndIndexBlocksInCache =
b.pinL0FilterAndIndexBlocksInCache;
+ }
+
+ public void assertEqualOptions(DatabaseOptions other) {
+ assertEquals(this.maxBackgroundCompactions,
other.maxBackgroundCompactions);
+ assertEquals(this.maxBackgroundFlushes, other.maxBackgroundFlushes);
+ assertEquals(this.maxLogFileSize, other.maxLogFileSize);
+ assertEquals(this.keepLogFileNum, other.keepLogFileNum);
+ assertEquals(this.walTTL, other.walTTL);
+ assertEquals(this.walSizeLimit, other.walSizeLimit);
+
+
+ assertEquals(this.bytesPerSync, other.bytesPerSync);
+ assertEquals(this.writeBufferSize, other.writeBufferSize);
+ assertEquals(this.blockSize, other.blockSize);
+ assertEquals(this.pinL0FilterAndIndexBlocksInCache,
other.pinL0FilterAndIndexBlocksInCache);
+ }
+
+ private static class Builder {
+ // DBOptions
+ private int maxBackgroundCompactions;
+ private int maxBackgroundFlushes;
+ private long bytesPerSync;
+ private long maxLogFileSize;
+ private long keepLogFileNum;
+ private long walTTL;
+ private long walSizeLimit;
+
+ // ColumnFamilyOptions
+ private long writeBufferSize;
+ // BlockBasedTableConfig
+ private long blockSize;
+ private boolean pinL0FilterAndIndexBlocksInCache;
+
+ Builder() {
+ }
Review Comment:
Removed. There are other places that used this (e.g.
`HeartbeatEndpointTask.Builder`).
##########
hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/repair/ldb/TestLdbRepair.java:
##########
@@ -165,4 +178,169 @@ private long calculateSstFileSize(Path db) throws
IOException {
.sum();
}
}
+
+ /**
+ * Helper method to read the latest RocksDB options from a database and test
column family.
+ */
+ private DatabaseOptions readDatabaseOptions() throws Exception {
+ assertNotNull(dbPath);
+ ManagedConfigOptions configOptions = new ManagedConfigOptions();
+ ManagedDBOptions dbOptions = new ManagedDBOptions();
+ List<ColumnFamilyHandle> cfHandleList = new ArrayList<>();
+ List<ColumnFamilyDescriptor> cfDescList = new ArrayList<>();
+
+ try {
+ try (ManagedRocksDB db = ManagedRocksDB.openWithLatestOptions(
+ configOptions, dbOptions, dbPath.toString(), cfDescList,
cfHandleList)) {
+ DatabaseOptions.Builder builder = new DatabaseOptions.Builder();
+
builder.setMaxBackgroundCompactions(dbOptions.maxBackgroundCompactions())
+ .setMaxBackgroundFlushes(dbOptions.maxBackgroundFlushes())
+ .setBytesPerSync(dbOptions.bytesPerSync())
+ .setMaxLogFileSize(dbOptions.maxLogFileSize())
+ .setKeepLogFileNum(dbOptions.keepLogFileNum())
+ .setWalTTL(dbOptions.walTtlSeconds())
+ .setWalSizeLimit(dbOptions.walSizeLimitMB());
+
+ Optional<ColumnFamilyDescriptor> testCfDesc =
cfDescList.stream().filter(cfDesc ->
+
TableConfig.toName(cfDesc.getName()).equals(TEST_CF_NAME)).findFirst();
+ if (testCfDesc.isPresent()) {
+ ColumnFamilyOptions cfOptions = testCfDesc.get().getOptions();
+ builder.setWriteBufferSize(cfOptions.writeBufferSize());
+ if (cfOptions.tableFormatConfig() instanceof
ManagedBlockBasedTableConfig) {
+ ManagedBlockBasedTableConfig tableConfig =
(ManagedBlockBasedTableConfig) cfOptions.tableFormatConfig();
+ builder.setBlockSize(tableConfig.blockSize());
+
builder.setPinL0FilterAndIndexBlocksInCache(tableConfig.pinL0FilterAndIndexBlocksInCache());
+ }
+ }
+ return builder.build();
+ }
+ } finally {
+ configOptions.close();
+ dbOptions.close();
+ IOUtils.closeQuietly(cfHandleList);
+ }
+ }
+
+ /**
+ * Simple data class to hold database options for comparison.
+ * This consist of sampled options from the options set in {@link
org.apache.hadoop.hdds.utils.db.DBProfile}.
+ */
+ private static final class DatabaseOptions {
+ // DBOptions
+ private final int maxBackgroundCompactions;
+ private final int maxBackgroundFlushes;
+ private final long bytesPerSync;
+ private final long maxLogFileSize;
+ private final long keepLogFileNum;
+ private final long walTTL;
+ private final long walSizeLimit;
+
+ // ColumnFamilyOptions
+ private final long writeBufferSize;
+ // BlockBasedTableConfig
+ private final long blockSize;
+ private final boolean pinL0FilterAndIndexBlocksInCache;
+
+ private DatabaseOptions(Builder b) {
+ this.maxBackgroundCompactions = b.maxBackgroundCompactions;
+ this.maxBackgroundFlushes = b.maxBackgroundFlushes;
+ this.bytesPerSync = b.bytesPerSync;
+ this.maxLogFileSize = b.maxLogFileSize;
+ this.keepLogFileNum = b.keepLogFileNum;
+ this.walTTL = b.walTTL;
+ this.walSizeLimit = b.walSizeLimit;
+ this.writeBufferSize = b.writeBufferSize;
+ this.blockSize = b.blockSize;
+ this.pinL0FilterAndIndexBlocksInCache =
b.pinL0FilterAndIndexBlocksInCache;
+ }
+
+ public void assertEqualOptions(DatabaseOptions other) {
+ assertEquals(this.maxBackgroundCompactions,
other.maxBackgroundCompactions);
+ assertEquals(this.maxBackgroundFlushes, other.maxBackgroundFlushes);
+ assertEquals(this.maxLogFileSize, other.maxLogFileSize);
+ assertEquals(this.keepLogFileNum, other.keepLogFileNum);
+ assertEquals(this.walTTL, other.walTTL);
+ assertEquals(this.walSizeLimit, other.walSizeLimit);
+
+
Review Comment:
Fixed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]