|
22 | 22 | import org.apache.fluss.config.ConfigOptions; |
23 | 23 | import org.apache.fluss.config.Configuration; |
24 | 24 | import org.apache.fluss.config.ReadableConfig; |
| 25 | +import org.apache.fluss.utils.FileUtils; |
25 | 26 | import org.apache.fluss.utils.IOUtils; |
26 | 27 |
|
27 | 28 | import org.rocksdb.BlockBasedTableConfig; |
|
42 | 43 | import javax.annotation.Nullable; |
43 | 44 |
|
44 | 45 | import java.io.File; |
| 46 | +import java.io.IOException; |
45 | 47 | import java.util.ArrayList; |
46 | 48 | import java.util.Collection; |
47 | 49 | import java.util.List; |
@@ -99,7 +101,7 @@ public RocksDBResourceContainer( |
99 | 101 | } |
100 | 102 |
|
101 | 103 | /** Gets the RocksDB {@link DBOptions} to be used for RocksDB instances. */ |
102 | | - public DBOptions getDbOptions() { |
| 104 | + public DBOptions getDbOptions() throws IOException { |
103 | 105 | // initial options from common profile |
104 | 106 | DBOptions opt = createBaseCommonDBOptions(); |
105 | 107 | handlesToClose.add(opt); |
@@ -175,7 +177,8 @@ private <T> T internalGetOption(ConfigOption<T> option) { |
175 | 177 | } |
176 | 178 |
|
177 | 179 | @SuppressWarnings("ConstantConditions") |
178 | | - private DBOptions setDBOptionsFromConfigurableOptions(DBOptions currentOptions) { |
| 180 | + private DBOptions setDBOptionsFromConfigurableOptions(DBOptions currentOptions) |
| 181 | + throws IOException { |
179 | 182 | currentOptions.setMaxBackgroundJobs( |
180 | 183 | internalGetOption(ConfigOptions.KV_MAX_BACKGROUND_THREADS)); |
181 | 184 |
|
@@ -280,12 +283,16 @@ private ColumnFamilyOptions setColumnFamilyOptionsFromConfigurableOptions( |
280 | 283 | * |
281 | 284 | * @param dbOptions The RocksDB {@link DBOptions}. |
282 | 285 | */ |
283 | | - private void relocateDefaultDbLogDir(DBOptions dbOptions) { |
| 286 | + private void relocateDefaultDbLogDir(DBOptions dbOptions) throws IOException { |
284 | 287 | String logFilePath = System.getProperty("log.file"); |
285 | 288 | if (logFilePath != null) { |
286 | 289 | File logFile = resolveFileLocation(logFilePath); |
287 | 290 | if (logFile != null && resolveFileLocation(logFile.getParent()) != null) { |
288 | | - dbOptions.setDbLogDir(logFile.getParent()); |
| 291 | + File logFileDirectory = logFile.getParentFile(); |
| 292 | + File rocksDbLogDirectory = FileUtils.createDirectory(logFileDirectory, "rocksdb"); |
| 293 | + if (resolveFileLocation(rocksDbLogDirectory.getAbsolutePath()) != null) { |
| 294 | + dbOptions.setDbLogDir(rocksDbLogDirectory.getAbsolutePath()); |
| 295 | + } |
289 | 296 | } |
290 | 297 | } |
291 | 298 | } |
|
0 commit comments