@Test public void testHarborIsReady() throws Throwable { HarborClient harborClient = setupMockHarborClient(true); HarborStatusChecker checker = new HarborStatusChecker(harborClient); final CountDownLatch latch = new CountDownLatch(1); checker.checkNodeStatus(SERVER_ADDRESS, new FutureCallback<Boolean>() { @Override public void onSuccess(@Nullable Boolean isReady) { assertTrue(isReady); latch.countDown(); } @Override public void onFailure(Throwable t) { fail(t.toString()); latch.countDown(); } }); assertThat(latch.await(LATCH_AWAIT_TIMEOUT, TimeUnit.SECONDS), is(true)); }
@Override public void checkNodeStatus(final String nodeAddress, final FutureCallback<Boolean> callback) { logger.info("Checking Harbor: {}", nodeAddress); try { String connectionString = createConnectionString(nodeAddress); harborClient.checkStatus(connectionString, new FutureCallback<Boolean>() { @Override public void onSuccess(@Nullable Boolean isReady) { try { callback.onSuccess(isReady); } catch (Throwable t) { logger.warn("Harbor node status check failed: ", t); callback.onFailure(t); } } @Override public void onFailure(Throwable t) { logger.warn("Harbor node status check failed: ", t); callback.onSuccess(false); } }); } catch (Exception e) { logger.warn("Harbor node status check failed: ", e); callback.onSuccess(false); } }
HarborStatusChecker implements StatusChecker { @Override public void checkNodeStatus(final String nodeAddress, final FutureCallback<Boolean> callback) { logger.info("Checking Harbor: {}", nodeAddress); try { String connectionString = createConnectionString(nodeAddress); harborClient.checkStatus(connectionString, new FutureCallback<Boolean>() { @Override public void onSuccess(@Nullable Boolean isReady) { try { callback.onSuccess(isReady); } catch (Throwable t) { logger.warn("Harbor node status check failed: ", t); callback.onFailure(t); } } @Override public void onFailure(Throwable t) { logger.warn("Harbor node status check failed: ", t); callback.onSuccess(false); } }); } catch (Exception e) { logger.warn("Harbor node status check failed: ", e); callback.onSuccess(false); } } }
HarborStatusChecker implements StatusChecker { @Override public void checkNodeStatus(final String nodeAddress, final FutureCallback<Boolean> callback) { logger.info("Checking Harbor: {}", nodeAddress); try { String connectionString = createConnectionString(nodeAddress); harborClient.checkStatus(connectionString, new FutureCallback<Boolean>() { @Override public void onSuccess(@Nullable Boolean isReady) { try { callback.onSuccess(isReady); } catch (Throwable t) { logger.warn("Harbor node status check failed: ", t); callback.onFailure(t); } } @Override public void onFailure(Throwable t) { logger.warn("Harbor node status check failed: ", t); callback.onSuccess(false); } }); } catch (Exception e) { logger.warn("Harbor node status check failed: ", e); callback.onSuccess(false); } } HarborStatusChecker(HarborClient harborClient); }
HarborStatusChecker implements StatusChecker { @Override public void checkNodeStatus(final String nodeAddress, final FutureCallback<Boolean> callback) { logger.info("Checking Harbor: {}", nodeAddress); try { String connectionString = createConnectionString(nodeAddress); harborClient.checkStatus(connectionString, new FutureCallback<Boolean>() { @Override public void onSuccess(@Nullable Boolean isReady) { try { callback.onSuccess(isReady); } catch (Throwable t) { logger.warn("Harbor node status check failed: ", t); callback.onFailure(t); } } @Override public void onFailure(Throwable t) { logger.warn("Harbor node status check failed: ", t); callback.onSuccess(false); } }); } catch (Exception e) { logger.warn("Harbor node status check failed: ", e); callback.onSuccess(false); } } HarborStatusChecker(HarborClient harborClient); @Override void checkNodeStatus(final String nodeAddress,
                              final FutureCallback<Boolean> callback); }
HarborStatusChecker implements StatusChecker { @Override public void checkNodeStatus(final String nodeAddress, final FutureCallback<Boolean> callback) { logger.info("Checking Harbor: {}", nodeAddress); try { String connectionString = createConnectionString(nodeAddress); harborClient.checkStatus(connectionString, new FutureCallback<Boolean>() { @Override public void onSuccess(@Nullable Boolean isReady) { try { callback.onSuccess(isReady); } catch (Throwable t) { logger.warn("Harbor node status check failed: ", t); callback.onFailure(t); } } @Override public void onFailure(Throwable t) { logger.warn("Harbor node status check failed: ", t); callback.onSuccess(false); } }); } catch (Exception e) { logger.warn("Harbor node status check failed: ", e); callback.onSuccess(false); } } HarborStatusChecker(HarborClient harborClient); @Override void checkNodeStatus(final String nodeAddress,
                              final FutureCallback<Boolean> callback);  }