Loading src/main/java/org/torproject/metrics/stats/ipv6servers/Database.java +3 −3 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ import java.util.TimeZone; /** Database wrapper to connect to the database, insert data, run the stored * procedure for aggregating data, and query aggregated data as output. */ class Database { class Database implements AutoCloseable { /** Database connection string. */ private String jdbcString; Loading Loading @@ -210,8 +210,8 @@ class Database { return statistics; } /** Disconnect from the database. */ void disconnect() throws SQLException { /** Release database connection. */ public void close() throws SQLException { this.connection.close(); } } Loading src/main/java/org/torproject/metrics/stats/ipv6servers/Main.java +51 −58 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ public class Main { File historyFile = new File(Configuration.history); reader.setHistoryFile(historyFile); Parser parser = new Parser(); Database database = new Database(Configuration.database); try (Database database = new Database(Configuration.database)) { try { for (Descriptor descriptor : reader.readDescriptors( new File(Configuration.descriptors Loading Loading @@ -78,29 +78,22 @@ public class Main { log.error("Cannot recover from SQL exception while inserting or " + "aggregating data. Rolling back and exiting.", sqle); database.rollback(); database.disconnect(); return; } reader.saveHistoryFile(historyFile); log.info("Querying aggregated statistics from the database."); Iterable<OutputLine> output; try { output = database.queryServersIpv6(); } catch (SQLException sqle) { log.error("Cannot recover from SQL exception while querying. Not writing " + "output file.", sqle); return; } finally { database.disconnect(); } Iterable<OutputLine> output = database.queryServersIpv6(); log.info("Writing aggregated statistics to {}.", Configuration.output); if (null != output) { new Writer().write(Paths.get(Configuration.output), output); } log.info("Terminating ipv6servers module."); } catch (SQLException sqle) { log.error("Cannot recover from SQL exception while querying. Not writing " + "output file.", sqle); } } } Loading
src/main/java/org/torproject/metrics/stats/ipv6servers/Database.java +3 −3 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ import java.util.TimeZone; /** Database wrapper to connect to the database, insert data, run the stored * procedure for aggregating data, and query aggregated data as output. */ class Database { class Database implements AutoCloseable { /** Database connection string. */ private String jdbcString; Loading Loading @@ -210,8 +210,8 @@ class Database { return statistics; } /** Disconnect from the database. */ void disconnect() throws SQLException { /** Release database connection. */ public void close() throws SQLException { this.connection.close(); } } Loading
src/main/java/org/torproject/metrics/stats/ipv6servers/Main.java +51 −58 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ public class Main { File historyFile = new File(Configuration.history); reader.setHistoryFile(historyFile); Parser parser = new Parser(); Database database = new Database(Configuration.database); try (Database database = new Database(Configuration.database)) { try { for (Descriptor descriptor : reader.readDescriptors( new File(Configuration.descriptors Loading Loading @@ -78,29 +78,22 @@ public class Main { log.error("Cannot recover from SQL exception while inserting or " + "aggregating data. Rolling back and exiting.", sqle); database.rollback(); database.disconnect(); return; } reader.saveHistoryFile(historyFile); log.info("Querying aggregated statistics from the database."); Iterable<OutputLine> output; try { output = database.queryServersIpv6(); } catch (SQLException sqle) { log.error("Cannot recover from SQL exception while querying. Not writing " + "output file.", sqle); return; } finally { database.disconnect(); } Iterable<OutputLine> output = database.queryServersIpv6(); log.info("Writing aggregated statistics to {}.", Configuration.output); if (null != output) { new Writer().write(Paths.get(Configuration.output), output); } log.info("Terminating ipv6servers module."); } catch (SQLException sqle) { log.error("Cannot recover from SQL exception while querying. Not writing " + "output file.", sqle); } } }