@@ -1183,20 +1183,20 @@ protected void runInContext() {
11831183 private List <String > getFailingChecks (DomainRouterVO router , GetRouterMonitorResultsAnswer answer ) {
11841184
11851185 if (answer == null ) {
1186- logger .warn ("Unable to fetch monitor results for router " + router );
1187- resetRouterHealthChecksAndConnectivity (router .getId (), false , false , "Communication failed" );
1186+ logger .warn ("Unable to fetch monitor results for router {}" , router );
1187+ resetRouterHealthChecksAndConnectivity (router .getId (), RouterHealthStatus . UNKNOWN , RouterHealthStatus . UNKNOWN , "Communication failed" );
11881188 return Arrays .asList (CONNECTIVITY_TEST );
11891189 } else if (!answer .getResult ()) {
11901190 logger .warn ("Failed to fetch monitor results from router " + router + " with details: " + answer .getDetails ());
11911191 if (StringUtils .isNotBlank (answer .getDetails ()) && answer .getDetails ().equalsIgnoreCase (READONLY_FILESYSTEM_ERROR )) {
1192- resetRouterHealthChecksAndConnectivity (router .getId (), true , false , "Failed to write: " + answer .getDetails ());
1192+ resetRouterHealthChecksAndConnectivity (router .getId (), RouterHealthStatus . SUCCESS , RouterHealthStatus . FAILURE , "Failed to write: " + answer .getDetails ());
11931193 return Arrays .asList (FILESYSTEM_WRITABLE_TEST );
11941194 } else {
1195- resetRouterHealthChecksAndConnectivity (router .getId (), false , false , "Failed to fetch results with details: " + answer .getDetails ());
1195+ resetRouterHealthChecksAndConnectivity (router .getId (), RouterHealthStatus . FAILURE , RouterHealthStatus . UNKNOWN , "Failed to fetch results with details: " + answer .getDetails ());
11961196 return Arrays .asList (CONNECTIVITY_TEST );
11971197 }
11981198 } else {
1199- resetRouterHealthChecksAndConnectivity (router .getId (), true , true , "Successfully fetched data" );
1199+ resetRouterHealthChecksAndConnectivity (router .getId (), RouterHealthStatus . SUCCESS , RouterHealthStatus . SUCCESS , "Successfully fetched data" );
12001200 updateDbHealthChecksFromRouterResponse (router , answer .getMonitoringResults ());
12011201 return answer .getFailingChecks ();
12021202 }
@@ -1295,7 +1295,7 @@ private boolean restartGuestNetworkInDomainRouter(DomainRouterJoinVO router, Use
12951295
12961296 /**
12971297 * Attempts recreation of router by restarting with cleanup a VPC if any or a guest network associated in case no VPC.
1298- * @param routerId - the id of the router to be recreated.
1298+ * @param router - the router to be recreated.
12991299 * @return true if successfully restart is attempted else false.
13001300 */
13011301 private boolean recreateRouter (DomainRouterVO router ) {
@@ -1335,13 +1335,13 @@ private Map<String, Map<String, RouterHealthCheckResultVO>> getHealthChecksFromD
13351335 return healthCheckResults ;
13361336 }
13371337
1338- private void resetRouterHealthChecksAndConnectivity (final long routerId , boolean connected , boolean writable , String message ) {
1338+ private void resetRouterHealthChecksAndConnectivity (final long routerId , VirtualNetworkApplianceService . RouterHealthStatus connected , VirtualNetworkApplianceService . RouterHealthStatus writable , String message ) {
13391339 routerHealthCheckResultDao .expungeHealthChecks (routerId );
1340- updateRouterHealthCheckResult (routerId , CONNECTIVITY_TEST , "basic" , connected , connected ? "Successfully connected to router" : message );
1341- updateRouterHealthCheckResult (routerId , FILESYSTEM_WRITABLE_TEST , "basic" , writable , writable ? "Successfully written to file system" : message );
1340+ updateRouterHealthCheckResult (routerId , CONNECTIVITY_TEST , "basic" , connected , connected . equals ( RouterHealthStatus . SUCCESS ) ? "Successfully connected to router" : message );
1341+ updateRouterHealthCheckResult (routerId , FILESYSTEM_WRITABLE_TEST , "basic" , writable , writable . equals ( RouterHealthStatus . SUCCESS ) ? "Successfully written to file system" : message );
13421342 }
13431343
1344- private void updateRouterHealthCheckResult (final long routerId , String checkName , String checkType , boolean checkResult , String checkMessage ) {
1344+ private void updateRouterHealthCheckResult (final long routerId , String checkName , String checkType , VirtualNetworkApplianceService . RouterHealthStatus checkResult , String checkMessage ) {
13451345 boolean newHealthCheckEntry = false ;
13461346 RouterHealthCheckResultVO connectivityVO = routerHealthCheckResultDao .getRouterHealthCheckResult (routerId , checkName , checkType );
13471347 if (connectivityVO == null ) {
@@ -1365,7 +1365,7 @@ private void updateRouterHealthCheckResult(final long routerId, String checkName
13651365 private RouterHealthCheckResultVO parseHealthCheckVOFromJson (final long routerId ,
13661366 final String checkName , final String checkType , final Map <String , String > checkData ,
13671367 final Map <String , Map <String , RouterHealthCheckResultVO >> checksInDb ) {
1368- boolean success = Boolean . parseBoolean (checkData .get ("success" ));
1368+ VirtualNetworkApplianceService . RouterHealthStatus success = RouterHealthStatus . valueOf (checkData .get ("success" ));
13691369 Date lastUpdate = new Date (Long .parseLong (checkData .get ("lastUpdate" )));
13701370 double lastRunDuration = Double .parseDouble (checkData .get ("lastRunDuration" ));
13711371 String message = checkData .get ("message" );
@@ -1572,7 +1572,7 @@ public Pair<Boolean, String> performRouterHealthChecks(long routerId) {
15721572 List <String > failingChecks = getFailingChecks (router , answer );
15731573 handleFailingChecks (router , failingChecks );
15741574
1575- return new Pair <Boolean , String >(success , resultDetails );
1575+ return new Pair <>(success , resultDetails );
15761576 }
15771577
15781578 protected class UpdateRouterHealthChecksConfigTask extends ManagedContextRunnable {
0 commit comments