[NEMO-375] Clean up of remnants of #211 (#224)
JIRA: [NEMO-375: Add option to turn off metric collection to DB](https://issues.apache.org/jira/projects/NEMO/issues/NEMO-375)
**Major changes:**
- None
**Minor changes to note:**
- Removes the static actions that happen nevertheless of the configuration and misleads users
**Tests for the changes:**
- None
**Other comments:**
- None
Closes #224
diff --git a/runtime/common/src/main/java/org/apache/nemo/runtime/common/metric/MetricUtils.java b/runtime/common/src/main/java/org/apache/nemo/runtime/common/metric/MetricUtils.java
index 8d458ae..49bdd9f 100644
--- a/runtime/common/src/main/java/org/apache/nemo/runtime/common/metric/MetricUtils.java
+++ b/runtime/common/src/main/java/org/apache/nemo/runtime/common/metric/MetricUtils.java
@@ -65,7 +65,6 @@
} catch (ClassNotFoundException e) {
throw new MetricException("PostgreSQL Driver not found: " + e);
}
- loadMetaData();
}
public static final String SQLITE_DB_NAME =
@@ -83,9 +82,9 @@
/**
* Load the BiMaps (lightweight) Metadata from the DB.
*
- * @return the loaded BiMaps, or initialized ones.
+ * @return Whether or not the metadata has been successfully loaded from the DB.
*/
- private static void loadMetaData() {
+ public static Boolean loadMetaData() {
try (Connection c = DriverManager.getConnection(MetricUtils.POSTGRESQL_METADATA_DB_NAME,
"postgres", "fake_password")) {
try (Statement statement = c.createStatement()) {
@@ -121,6 +120,7 @@
} catch (Exception e) {
LOG.warn("Loading metadata from DB failed : ", e);
}
+ return metaDataLoaded();
}
public static Boolean metaDataLoaded() {
diff --git a/runtime/master/src/main/java/org/apache/nemo/runtime/master/metric/MetricStore.java b/runtime/master/src/main/java/org/apache/nemo/runtime/master/metric/MetricStore.java
index 5e55d84..3d3db4f 100644
--- a/runtime/master/src/main/java/org/apache/nemo/runtime/master/metric/MetricStore.java
+++ b/runtime/master/src/main/java/org/apache/nemo/runtime/master/metric/MetricStore.java
@@ -278,7 +278,7 @@
final String dbId, final String dbPasswd) {
final String[] syntax = {"SERIAL PRIMARY KEY"};
- if (!MetricUtils.metaDataLoaded()) {
+ if (!MetricUtils.metaDataLoaded() && !MetricUtils.loadMetaData()) {
saveOptimizationMetricsToLocal(jobId);
return;
}