wonook commented on a change in pull request #192: [NEMO-335] DB for storing 
metrics
URL: https://github.com/apache/incubator-nemo/pull/192#discussion_r256397078
 
 

 ##########
 File path: 
runtime/master/src/main/java/org/apache/nemo/runtime/master/metric/MetricStore.java
 ##########
 @@ -206,17 +210,106 @@ public synchronized String dumpAllMetricToJson() throws 
IOException {
    * @param filePath path to dump JSON.
    */
   public void dumpAllMetricToFile(final String filePath) {
-    try {
+    try (final BufferedWriter writer = new BufferedWriter(new 
FileWriter(filePath))) {
       final String jsonDump = dumpAllMetricToJson();
-      final BufferedWriter writer = new BufferedWriter(new 
FileWriter(filePath));
-
       writer.write(jsonDump);
-      writer.close();
     } catch (final IOException e) {
-      throw new RuntimeException(e);
+      throw new MetricException(e);
     }
   }
 
+  /**
+   * Save the job metrics for the optimization to the DB, in the form of 
LibSVM, to SQLite.
+   * The metrics are as follows: the JCT (duration), and the IR DAG execution 
properties.
+   */
+  public void saveOptimizationMetricsToSQLite() {
+    final String optimizationDBName = "jdbc:sqlite:" + 
MetricUtils.fetchProjectRootPath() + "/optimization_db.sqlite3";
+    final String[] syntax = {"INTEGER PRIMARY KEY AUTOINCREMENT"};
+
+    try (final Connection c = DriverManager.getConnection(optimizationDBName)) 
{
+      LOG.info("Opened database successfully at {}", optimizationDBName);
+      saveOptimizationMetrics(c, syntax);
+    } catch (SQLException e) {
+      LOG.error("Error while saving optimization metrics to SQLite: {}", e);
+    }
+  }
+
+  /**
+   * Save the job metrics for the optimization to the DB, in the form of 
LibSVM, to PostgreSQL.
+   * The metrics are as follows: the JCT (duration), and the IR DAG execution 
properties.
+   */
+  public void saveOptimizationMetricsToPostgreSQL() {
+    final String optimizationDBName = "jdbc:postgresql://nemo-optimization."
+      + "cabbufr3evny.us-west-2.rds.amazonaws.com:5432/nemo_optimization";
 
 Review comment:
   You're right. I'll add it to JobConf.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to