Minor cleanup from PR review

This commit is contained in:
Ann Priestman 2018-04-10 07:29:51 -04:00
parent 1a437d8686
commit 30a364c417

View File

@ -310,13 +310,14 @@ public class ServicesHealthMonitor {
timingMapCopy = new HashMap<>(timingInfoMap); timingMapCopy = new HashMap<>(timingInfoMap);
timingInfoMap.clear(); timingInfoMap.clear();
} }
logger.log(Level.INFO, "Writing health monitor metrics to database");
// Check if there's anything to report (right now we only have the timing map) // Check if there's anything to report (right now we only have the timing map)
if(timingMapCopy.keySet().isEmpty()) { if(timingMapCopy.keySet().isEmpty()) {
return; return;
} }
logger.log(Level.INFO, "Writing health monitor metrics to database");
// Write to the database // Write to the database
CoordinationService.Lock lock = getSharedDbLock(); CoordinationService.Lock lock = getSharedDbLock();
if(lock == null) { if(lock == null) {
@ -380,7 +381,6 @@ public class ServicesHealthMonitor {
try (Connection connection = DriverManager.getConnection("jdbc:postgresql://" + db.getHost() + ":" + db.getPort() + "/postgres", db.getUserName(), db.getPassword()); //NON-NLS try (Connection connection = DriverManager.getConnection("jdbc:postgresql://" + db.getHost() + ":" + db.getPort() + "/postgres", db.getUserName(), db.getPassword()); //NON-NLS
Statement statement = connection.createStatement();) { Statement statement = connection.createStatement();) {
String createCommand = "SELECT 1 AS result FROM pg_database WHERE datname='" + DATABASE_NAME + "'"; String createCommand = "SELECT 1 AS result FROM pg_database WHERE datname='" + DATABASE_NAME + "'";
System.out.println(" query: " + createCommand);
rs = statement.executeQuery(createCommand); rs = statement.executeQuery(createCommand);
if(rs.next()) { if(rs.next()) {
logger.log(Level.INFO, "Existing Services Health Monitor database found"); logger.log(Level.INFO, "Existing Services Health Monitor database found");