private void doHealthChecks() throws InterruptedException { while (shouldRun) { HAServiceStatus status = null; boolean healthy = false; try { status = proxy.getServiceStatus(); proxy.monitorHealth(); healthy = true; } catch (HealthCheckFailedException e) { LOG.warn("Service health check failed for " + targetToMonitor + ": " + e.getMessage()); enterState(State.SERVICE_UNHEALTHY); } catch (Throwable t) { LOG.warn( "Transport-level exception trying to monitor health of " + targetToMonitor + ": " + t.getLocalizedMessage()); RPC.stopProxy(proxy); proxy = null; enterState(State.SERVICE_NOT_RESPONDING); Thread.sleep(sleepAfterDisconnectMillis); return; } if (status != null) { setLastServiceStatus(status); } if (healthy) { enterState(State.SERVICE_HEALTHY); } Thread.sleep(checkIntervalMillis); } }
private void loopUntilConnected() throws InterruptedException { tryConnect(); while (proxy == null) { Thread.sleep(connectRetryInterval); tryConnect(); } assert proxy != null; }