@Override public InetSocketAddress getRemoteAddress() { Channel channel = getChannel(); if (channel == null) { return getUrl().toInetSocketAddress(); } return channel.getRemoteAddress(); }
@Override public InetSocketAddress getRemoteAddress() { Channel channel = getChannel(); if (channel == null) { return getUrl().toInetSocketAddress(); } return channel.getRemoteAddress(); }
@Override public void send(Object message, boolean sent) throws RemotingException { if (needReconnect && !isConnected()) { connect(); } Channel channel = getChannel(); //TODO Can the value returned by getChannel() be null? need improvement. if (channel == null || !channel.isConnected()) { throw new RemotingException(this, "message can not send, because channel is closed . url:" + getUrl()); } channel.send(message, sent); }
@Override public void send(Object message, boolean sent) throws RemotingException { if (needReconnect && !isConnected()) { connect(); } Channel channel = getChannel(); //TODO Can the value returned by getChannel() be null? need improvement. if (channel == null || !channel.isConnected()) { throw new RemotingException(this, "message can not send, because channel is closed . url:" + getUrl()); } channel.send(message, sent); }
protected ExecutorService createExecutor() { return Executors.newCachedThreadPool(new NamedThreadFactory(CLIENT_THREAD_POOL_NAME + CLIENT_THREAD_POOL_ID.incrementAndGet() + "-" + getUrl().getAddress(), true)); }
protected ExecutorService createExecutor() { return Executors.newCachedThreadPool(new NamedThreadFactory(CLIENT_THREAD_POOL_NAME + CLIENT_THREAD_POOL_ID.incrementAndGet() + "-" + getUrl().getAddress(), true)); }
int reconnect = getReconnectParam(getUrl()); if (reconnect > 0 && (reconnectExecutorFuture == null || reconnectExecutorFuture.isCancelled())) { Runnable connectStatusCheckCommand = new Runnable() {
int reconnect = getReconnectParam(getUrl()); if (reconnect > 0 && (reconnectExecutorFuture == null || reconnectExecutorFuture.isCancelled())) { Runnable connectStatusCheckCommand = new Runnable() {
@Override public void run() { try { if (!isConnected()) { connect(); } else { lastConnectedTime = System.currentTimeMillis(); } } catch (Throwable t) { String errorMsg = "client reconnect to " + getUrl().getAddress() + " find error . url: " + getUrl(); // wait registry sync provider list if (System.currentTimeMillis() - lastConnectedTime > shutdown_timeout) { if (!reconnect_error_log_flag.get()) { reconnect_error_log_flag.set(true); logger.error(errorMsg, t); return; } } if (reconnect_count.getAndIncrement() % reconnect_warning_period == 0) { logger.warn(errorMsg, t); } } } };
@Override public void run() { try { if (!isConnected()) { connect(); } else { lastConnectedTime = System.currentTimeMillis(); } } catch (Throwable t) { String errorMsg = "client reconnect to " + getUrl().getAddress() + " find error . url: " + getUrl(); // wait registry sync provider list if (System.currentTimeMillis() - lastConnectedTime > shutdown_timeout) { if (!reconnect_error_log_flag.get()) { reconnect_error_log_flag.set(true); logger.error(errorMsg, t); return; } } if (reconnect_count.getAndIncrement() % reconnect_warning_period == 0) { logger.warn(errorMsg, t); } } } };
@Override public InetSocketAddress getRemoteAddress() { Channel channel = getChannel(); if (channel == null) { return getUrl().toInetSocketAddress(); } return channel.getRemoteAddress(); }
@Override public InetSocketAddress getRemoteAddress() { Channel channel = getChannel(); if (channel == null) { return getUrl().toInetSocketAddress(); } return channel.getRemoteAddress(); }
@Override public void send(Object message, boolean sent) throws RemotingException { if (send_reconnect && !isConnected()) { connect(); } Channel channel = getChannel(); //TODO Can the value returned by getChannel() be null? need improvement. if (channel == null || !channel.isConnected()) { throw new RemotingException(this, "message can not send, because channel is closed . url:" + getUrl()); } channel.send(message, sent); }
@Override public void send(Object message, boolean sent) throws RemotingException { if (send_reconnect && !isConnected()) { connect(); } Channel channel = getChannel(); //TODO Can the value returned by getChannel() be null? need improvement. if (channel == null || !channel.isConnected()) { throw new RemotingException(this, "message can not send, because channel is closed . url:" + getUrl()); } channel.send(message, sent); }