Skip to content

Commit

Permalink
fix issue qunarcorp#41
Browse files Browse the repository at this point in the history
  • Loading branch information
keliwang committed Feb 20, 2019
1 parent 582f3b7 commit 0c0f094
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,16 @@ public void sendRequest(final MetaInfoRequest request) {
final Datagram datagram = RemotingBuilder.buildRequestDatagram(CommandCode.CLIENT_REGISTER, new MetaInfoRequestPayloadHolder(request));
channel.writeAndFlush(datagram).addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
public void operationComplete(ChannelFuture future) {
if (future.isSuccess()) {
LOGGER.debug("MetaInfoClientNettyImpl", "request meta info send success. {}", request);
LOGGER.debug("request meta info send success. {}", request);
} else {
LOGGER.debug("MetaInfoClientNettyImpl", "request meta info send fail. {}", request);
LOGGER.debug("request meta info send fail. {}", request);
}
}
});
} catch (Exception e) {
LOGGER.debug("MetaInfoClientNettyImpl", "request meta info exception. {}", request, e);
LOGGER.debug("request meta info exception. {}", request, e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Channel getOrCreateChannel(final String remoteAddr) throws ClientSendException {

if (needCreateChannel) {
ChannelFuture cf = bootstrap.connect(RemoteHelper.string2SocketAddress(remoteAddr));
LOGGER.debug("NettyConnectManageHandler", "begin to connect remote host: {}", remoteAddr);
LOGGER.debug("begin to connect remote host: {}", remoteAddr);
cw = new ChannelWrapper(cf);
channelTables.put(remoteAddr, cw);
}
Expand All @@ -116,7 +116,7 @@ Channel getOrCreateChannel(final String remoteAddr) throws ClientSendException {
ChannelFuture cf = cw.getChannelFuture();
if (cf.awaitUninterruptibly(connectTimeout)) {
if (cw.isOK()) {
LOGGER.debug("NettyConnectManageHandler", "connect remote host success: {}", remoteAddr);
LOGGER.debug("connect remote host success: {}", remoteAddr);
return cw.getChannel();
} else {
if (connectFailLogLimit.tryAcquire()) {
Expand All @@ -136,22 +136,22 @@ Channel getOrCreateChannel(final String remoteAddr) throws ClientSendException {
public void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) throws Exception {
final String local = localAddress == null ? "UNKNOWN" : RemoteHelper.parseSocketAddressAddress(localAddress);
final String remote = remoteAddress == null ? "UNKNOWN" : RemoteHelper.parseSocketAddressAddress(remoteAddress);
LOGGER.debug("NettyConnectManageHandler", "NETTY CLIENT PIPELINE: CONNECT {} => {}", local, remote);
LOGGER.debug("NETTY CLIENT PIPELINE: CONNECT {} => {}", local, remote);
super.connect(ctx, remoteAddress, localAddress, promise);
}

@Override
public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
final String remoteAddress = RemoteHelper.parseChannelRemoteAddress(ctx.channel());
LOGGER.debug("NettyConnectManageHandler", "NETTY CLIENT PIPELINE: DISCONNECT {}", remoteAddress);
LOGGER.debug("NETTY CLIENT PIPELINE: DISCONNECT {}", remoteAddress);
closeChannel(ctx.channel());
super.disconnect(ctx, promise);
}

@Override
public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
final String remoteAddress = RemoteHelper.parseChannelRemoteAddress(ctx.channel());
LOGGER.debug("NettyConnectManageHandler", "NETTY CLIENT PIPELINE: CLOSE {}", remoteAddress);
LOGGER.debug("NETTY CLIENT PIPELINE: CLOSE {}", remoteAddress);
closeChannel(ctx.channel());
super.close(ctx, promise);
}
Expand Down Expand Up @@ -194,7 +194,7 @@ private void closeChannel(final Channel channel) {
}
}
if (oldCw == null) {
LOGGER.debug("NettyConnectManageHandler", "close channel but not found in channelTable");
LOGGER.debug("close channel but not found in channelTable");
return;
}

Expand Down

0 comments on commit 0c0f094

Please sign in to comment.