@Override public void reconnect(int timeoutInSeconds) throws TimeoutException, InterruptedException { if (delegate != null) { delegate.reconnect(timeoutInSeconds); } }
@Override public void reconnect(int timeoutInSeconds) throws TimeoutException, InterruptedException { delegate.reconnect(timeoutInSeconds); }
private void waitUntilServerIsRunning(boolean reconnect) throws IOException, InterruptedException, TimeoutException { Thread.sleep(500); // this value is taken from implementation of CLI "reload" if (reconnect) { client.reconnect(timeoutInSeconds); } long endTime = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(timeoutInSeconds); while (System.currentTimeMillis() < endTime) { try { if (isServerRunning()) { break; } } catch (Throwable ignored) { // server is probably down, will retry } Thread.sleep(200); // this value is completely arbitrary } boolean running = false; try { running = isServerRunning(); } catch (Throwable ignored) { // server probably down } if (!running) { throw new TimeoutException("Waiting for server timed out"); } }
client.reconnect(timeoutInSeconds);