public static void cleanup(NettyClientBase... clients) { for (NettyClientBase client : clients) { if (client != null) { try { client.close(); } catch (Exception e) { if (LOG.isDebugEnabled()) { LOG.debug("Exception in closing " + client.getKey(), e); } } } } }
public static void cleanup(NettyClientBase... clients) { for (NettyClientBase client : clients) { if (client != null) { try { client.close(); } catch (Exception e) { if (LOG.isDebugEnabled()) { LOG.debug("Exception in closing " + client.getKey(), e); } } } } }
public static void cleanup(NettyClientBase... clients) { for (NettyClientBase client : clients) { if (client != null) { try { client.close(); } catch (Exception e) { if (LOG.isDebugEnabled()) { LOG.debug("Exception in closing " + client.getKey(), e); } } } } }
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); } } }
@Override public void operationComplete(final ChannelFuture future) throws Exception { if (future.isSuccess()) { getHandler().registerCallback(rpcRequest.getId(), callback); } else { if (!future.channel().isActive() && retry < maxRetryNum) { /* schedule the current request for the retry */ LOG.warn(future.cause() + " Try to reconnect :" + getKey().addr); final EventLoop loop = future.channel().eventLoop(); loop.schedule(new Runnable() { @Override public void run() { doConnect(getKey().addr).addListener(new GenericFutureListener<ChannelFuture>() { @Override public void operationComplete(ChannelFuture future) throws Exception { invoke(rpcRequest, callback, retry + 1); } }); } }, RpcConstants.DEFAULT_PAUSE, TimeUnit.MILLISECONDS); } else { /* Max retry count has been exceeded or internal failure */ getHandler().registerCallback(rpcRequest.getId(), callback); getHandler().exceptionCaught(getChannel().pipeline().lastContext(), new RecoverableException(rpcRequest.getId(), future.cause())); } } } });
@Override public void operationComplete(final ChannelFuture future) throws Exception { if (future.isSuccess()) { getHandler().registerCallback(rpcRequest.getId(), callback); } else { if (!future.channel().isActive() && retry < maxRetryNum) { /* schedule the current request for the retry */ LOG.warn(future.cause() + " Try to reconnect :" + getKey().addr); final EventLoop loop = future.channel().eventLoop(); loop.schedule(new Runnable() { @Override public void run() { doConnect(getKey().addr).addListener(new GenericFutureListener<ChannelFuture>() { @Override public void operationComplete(ChannelFuture future) throws Exception { invoke(rpcRequest, callback, retry + 1); } }); } }, RpcConstants.DEFAULT_PAUSE, TimeUnit.MILLISECONDS); } else { /* Max retry count has been exceeded or internal failure */ getHandler().registerCallback(rpcRequest.getId(), callback); getHandler().exceptionCaught(getChannel().pipeline().lastContext(), new RecoverableException(rpcRequest.getId(), future.cause())); } } } });
client.subscribeEvent(target.getKey(), new ChannelEventListener() { @Override public void channelRegistered(ChannelHandlerContext ctx) {
client.subscribeEvent(target.getKey(), new ChannelEventListener() { @Override public void channelRegistered(ChannelHandlerContext ctx) {