private void doReconnect(final InetSocketAddress address, ChannelFuture future, AtomicInteger retries) throws ConnectTimeoutException { for (; ; ) { if (numRetries >= retries.getAndIncrement()) { LOG.warn(future.cause().getMessage() + " Try to reconnect"); try { Thread.sleep(PAUSE); } catch (InterruptedException e) { } this.channelFuture = doConnect(address).awaitUninterruptibly(); if (this.channelFuture.isDone() && this.channelFuture.isSuccess()) { break; } } else { throw new ConnectTimeoutException("Max retry count has been exceeded. attempts=" + numRetries + " caused by: " + future.cause()); } } }
public synchronized void connect() throws ConnectTimeoutException { if (isConnected()) return; final AtomicInteger retries = new AtomicInteger(); InetSocketAddress address = key.addr; if (address.isUnresolved()) { address = resolveAddress(address); } /* do not call await() inside handler */ ChannelFuture f = doConnect(address).awaitUninterruptibly(); retries.incrementAndGet(); if (!f.isSuccess() && numRetries > 0) { doReconnect(address, f, retries); } }
public synchronized void connect() throws ConnectException { if (isConnected()) return; int retries = 0; InetSocketAddress address = key.addr; if (address.isUnresolved()) { address = resolveAddress(address); } /* do not call await() inside handler */ ChannelFuture f = doConnect(address).awaitUninterruptibly(); if (!f.isSuccess()) { if (maxRetryNum > 0) { doReconnect(address, f, ++retries); } else { throw makeConnectException(address, f); } } }
public synchronized void connect() throws ConnectException { if (isConnected()) return; int retries = 0; InetSocketAddress address = key.addr; if (address.isUnresolved()) { address = resolveAddress(address); } /* do not call await() inside handler */ ChannelFuture f = doConnect(address).awaitUninterruptibly(); if (!f.isSuccess()) { if (maxRetryNum > 0) { doReconnect(address, f, ++retries); } else { throw makeConnectException(address, f); } } }
private void doReconnect(final InetSocketAddress address, ChannelFuture future, int retries) throws ConnectException { for (; ; ) { if (maxRetryNum > retries) { retries++; if(getChannel().eventLoop().isShuttingDown()) { LOG.warn("RPC is shutting down"); return; } LOG.warn(getErrorMessage(ExceptionUtils.getMessage(future.cause())) + "\nTry to reconnect : " + getKey().addr); try { Thread.sleep(RpcConstants.DEFAULT_PAUSE); } catch (InterruptedException e) { } this.channelFuture = doConnect(address).awaitUninterruptibly(); if (this.channelFuture.isDone() && this.channelFuture.isSuccess()) { break; } } else { LOG.error("Max retry count has been exceeded. attempts=" + retries + " caused by: " + future.cause()); throw makeConnectException(address, future); } } }
private void doReconnect(final InetSocketAddress address, ChannelFuture future, int retries) throws ConnectException { for (; ; ) { if (maxRetryNum > retries) { retries++; if(getChannel().eventLoop().isShuttingDown()) { LOG.warn("RPC is shutting down"); return; } LOG.warn(getErrorMessage(ExceptionUtils.getMessage(future.cause())) + "\nTry to reconnect : " + getKey().addr); try { Thread.sleep(RpcConstants.DEFAULT_PAUSE); } catch (InterruptedException e) { } this.channelFuture = doConnect(address).awaitUninterruptibly(); if (this.channelFuture.isDone() && this.channelFuture.isSuccess()) { break; } } else { LOG.error("Max retry count has been exceeded. attempts=" + retries + " caused by: " + future.cause()); throw makeConnectException(address, future); } } }