[STORM-3910] Enahnced logging for rocksdb metrics store. (#3535)
diff --git a/storm-server/pom.xml b/storm-server/pom.xml
index 77adf6f..d9ee561 100644
--- a/storm-server/pom.xml
+++ b/storm-server/pom.xml
@@ -60,6 +60,7 @@
<dependency>
<groupId>org.rocksdb</groupId>
<artifactId>rocksdbjni</artifactId>
+ <version>${rocksdb-version}</version>
</dependency>
<!-- jline is included to make the zk shell work through the cli for debugging -->
diff --git a/storm-server/src/main/java/org/apache/storm/metricstore/MetricStoreConfig.java b/storm-server/src/main/java/org/apache/storm/metricstore/MetricStoreConfig.java
index c375c06..22cff7c 100644
--- a/storm-server/src/main/java/org/apache/storm/metricstore/MetricStoreConfig.java
+++ b/storm-server/src/main/java/org/apache/storm/metricstore/MetricStoreConfig.java
@@ -27,13 +27,19 @@
*/
public static MetricStore configure(Map<String, Object> conf, StormMetricsRegistry metricsRegistry) throws MetricException {
+ String storeClass = "None";
try {
- String storeClass = (String) conf.get(DaemonConfig.STORM_METRIC_STORE_CLASS);
+ storeClass = (String) conf.get(DaemonConfig.STORM_METRIC_STORE_CLASS);
MetricStore store = (MetricStore) (Class.forName(storeClass)).newInstance();
store.prepare(conf, metricsRegistry);
return store;
} catch (Exception e) {
- throw new MetricException("Failed to create metric store", e);
+ String rocksdbSpecificMsg = "";
+ if (storeClass.contains("rocksdb")
+ && System.getenv("ROCKSDB_SHAREDLIB_DIR") == null) {
+ rocksdbSpecificMsg = ", missing env var ROCKSDB_SHAREDLIB_DIR required to load JNI library in org.rocksdb.RocksDB class";
+ }
+ throw new MetricException("Failed to create metric store using store class " + storeClass + rocksdbSpecificMsg, e);
}
}
diff --git a/storm-server/src/main/java/org/apache/storm/metricstore/rocksdb/RocksDbStore.java b/storm-server/src/main/java/org/apache/storm/metricstore/rocksdb/RocksDbStore.java
index 89e4cec..59355c1 100644
--- a/storm-server/src/main/java/org/apache/storm/metricstore/rocksdb/RocksDbStore.java
+++ b/storm-server/src/main/java/org/apache/storm/metricstore/rocksdb/RocksDbStore.java
@@ -75,7 +75,7 @@
options.useCappedPrefixExtractor(RocksDbKey.KEY_SIZE);
String path = getRocksDbAbsoluteDir(config);
- LOG.info("Opening RocksDB from {}", path);
+ LOG.info("Opening RocksDB from {}, {}={}", path, DaemonConfig.STORM_ROCKSDB_CREATE_IF_MISSING, createIfMissing);
db = RocksDB.open(options, path);
} catch (RocksDBException e) {
String message = "Error opening RockDB database";
diff --git a/storm-server/src/main/java/org/apache/storm/metricstore/rocksdb/StringMetadataCache.java b/storm-server/src/main/java/org/apache/storm/metricstore/rocksdb/StringMetadataCache.java
index e8428c3..5ee50a7 100644
--- a/storm-server/src/main/java/org/apache/storm/metricstore/rocksdb/StringMetadataCache.java
+++ b/storm-server/src/main/java/org/apache/storm/metricstore/rocksdb/StringMetadataCache.java
@@ -51,17 +51,17 @@
}
/**
- * Initializes the cache instance.
+ * Initializes the cache instance. Should be called only once in the JVM, subsequent calls
+ * will be ignored unless preceded by {@link #init(RocksDbMetricsWriter, int)}.
*
* @param dbWriter the RocksDB writer instance to handle writing evicted cache data
* @param capacity the number of StringMetadata instances to hold in memory
- * @throws MetricException if creating multiple cache instances
*/
- static void init(RocksDbMetricsWriter dbWriter, int capacity) throws MetricException {
+ static void init(RocksDbMetricsWriter dbWriter, int capacity) {
if (instance == null) {
instance = new StringMetadataCache(dbWriter, capacity);
} else {
- throw new MetricException("StringMetadataCache already created");
+ LOG.error("Ignoring call to init() since StringMetadataCache already created");
}
}