fix : Change the log level to debug

pull/983/head
pizihao 3 years ago
parent 6f0889435b
commit 88eba9c749

@ -73,11 +73,14 @@ public class NettyClientConnection implements ClientConnection {
public Response connect(Request request) { public Response connect(Request request) {
activeProcessChain.applyPreHandle(request); activeProcessChain.applyPreHandle(request);
this.channel = connectionPool.acquire(timeout); this.channel = connectionPool.acquire(timeout);
boolean debugEnabled = log.isDebugEnabled();
Response response = null; Response response = null;
try { try {
String key = request.getKey(); String key = request.getKey();
this.future = channel.writeAndFlush(request); this.future = channel.writeAndFlush(request);
log.info("Call successful, target address is {}:{}, request key is {}", address.getHostName(), address.getPort(), key); if (debugEnabled) {
log.debug("Call successful, target address is {}:{}, request key is {}", address.getHostName(), address.getPort(), key);
}
// Wait for execution to complete // Wait for execution to complete
ResultHolder.putThread(key, Thread.currentThread()); ResultHolder.putThread(key, Thread.currentThread());
LockSupport.parkNanos(timeout() * 1000000); LockSupport.parkNanos(timeout() * 1000000);
@ -86,7 +89,9 @@ public class NettyClientConnection implements ClientConnection {
throw new TimeOutException("Timeout waiting for server-side response"); throw new TimeOutException("Timeout waiting for server-side response");
} }
activeProcessChain.applyPostHandle(request, response); activeProcessChain.applyPostHandle(request, response);
log.info("The response from {}:{} was received successfully with the response key {}.", address.getHostName(), address.getPort(), key); if (debugEnabled) {
log.debug("The response from {}:{} was received successfully with the response key {}.", address.getHostName(), address.getPort(), key);
}
return response; return response;
} catch (Exception ex) { } catch (Exception ex) {
activeProcessChain.afterCompletion(request, response, ex); activeProcessChain.afterCompletion(request, response, ex);

@ -17,7 +17,6 @@
package cn.hippo4j.rpc.handler; package cn.hippo4j.rpc.handler;
import cn.hippo4j.rpc.coder.NettyDecoder;
import cn.hippo4j.rpc.coder.NettyEncoder; import cn.hippo4j.rpc.coder.NettyEncoder;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import io.netty.channel.Channel; import io.netty.channel.Channel;
@ -26,6 +25,7 @@ import io.netty.channel.ChannelPipeline;
import io.netty.channel.pool.ChannelPoolHandler; import io.netty.channel.pool.ChannelPoolHandler;
import io.netty.channel.socket.nio.NioSocketChannel; import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.serialization.ClassResolvers; import io.netty.handler.codec.serialization.ClassResolvers;
import io.netty.handler.codec.serialization.ObjectDecoder;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.util.List; import java.util.List;
@ -75,7 +75,9 @@ public class NettyClientPoolHandler extends AbstractNettyHandlerManager implemen
@Override @Override
public void channelReleased(Channel ch) { public void channelReleased(Channel ch) {
ch.writeAndFlush(Unpooled.EMPTY_BUFFER); ch.writeAndFlush(Unpooled.EMPTY_BUFFER);
log.info("The connection buffer has been emptied of data"); if (log.isDebugEnabled()) {
log.debug("The connection buffer has been emptied of data");
}
} }
@Override @Override
@ -90,7 +92,7 @@ public class NettyClientPoolHandler extends AbstractNettyHandlerManager implemen
.setTcpNoDelay(false); .setTcpNoDelay(false);
ChannelPipeline pipeline = ch.pipeline(); ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(new NettyEncoder()); pipeline.addLast(new NettyEncoder());
pipeline.addLast(new NettyDecoder(ClassResolvers.cacheDisabled(null))); pipeline.addLast(new ObjectDecoder(Integer.MAX_VALUE, ClassResolvers.cacheDisabled(null)));
this.handlerEntities.stream() this.handlerEntities.stream()
.sorted() .sorted()
.forEach(h -> { .forEach(h -> {

@ -19,13 +19,13 @@ package cn.hippo4j.rpc.handler;
import cn.hippo4j.common.toolkit.Assert; import cn.hippo4j.common.toolkit.Assert;
import cn.hippo4j.common.toolkit.ReflectUtil; import cn.hippo4j.common.toolkit.ReflectUtil;
import cn.hippo4j.rpc.process.ActivePostProcess;
import cn.hippo4j.rpc.process.ActiveProcessChain;
import cn.hippo4j.rpc.model.Request;
import cn.hippo4j.rpc.model.DefaultResponse;
import cn.hippo4j.rpc.model.Response;
import cn.hippo4j.rpc.discovery.ClassRegistry; import cn.hippo4j.rpc.discovery.ClassRegistry;
import cn.hippo4j.rpc.discovery.Instance; import cn.hippo4j.rpc.discovery.Instance;
import cn.hippo4j.rpc.model.DefaultResponse;
import cn.hippo4j.rpc.model.Request;
import cn.hippo4j.rpc.model.Response;
import cn.hippo4j.rpc.process.ActivePostProcess;
import cn.hippo4j.rpc.process.ActiveProcessChain;
import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;

@ -94,9 +94,11 @@ public final class ActiveProcessChain {
try { try {
handle.afterCompletion(request, response, ex); handle.afterCompletion(request, response, ex);
} catch (Throwable e) { } catch (Throwable e) {
if (log.isErrorEnabled()) {
log.error("HandlerInterceptor.afterCompletion threw exception", e); log.error("HandlerInterceptor.afterCompletion threw exception", e);
} }
} }
} }
}
} }

@ -18,7 +18,6 @@
package cn.hippo4j.rpc.server; package cn.hippo4j.rpc.server;
import cn.hippo4j.common.toolkit.Assert; import cn.hippo4j.common.toolkit.Assert;
import cn.hippo4j.rpc.coder.NettyDecoder;
import cn.hippo4j.rpc.coder.NettyEncoder; import cn.hippo4j.rpc.coder.NettyEncoder;
import cn.hippo4j.rpc.discovery.ServerPort; import cn.hippo4j.rpc.discovery.ServerPort;
import cn.hippo4j.rpc.exception.ConnectionException; import cn.hippo4j.rpc.exception.ConnectionException;
@ -29,6 +28,7 @@ import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.codec.serialization.ClassResolvers; import io.netty.handler.codec.serialization.ClassResolvers;
import io.netty.handler.codec.serialization.ObjectDecoder;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.util.Arrays; import java.util.Arrays;
@ -80,7 +80,7 @@ public class NettyServerConnection extends AbstractNettyHandlerManager implement
protected void initChannel(SocketChannel ch) throws Exception { protected void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline(); ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(new NettyEncoder()); pipeline.addLast(new NettyEncoder());
pipeline.addLast(new NettyDecoder(ClassResolvers.cacheDisabled(null))); pipeline.addLast(new ObjectDecoder(Integer.MAX_VALUE, ClassResolvers.cacheDisabled(null)));
handlerEntities.stream() handlerEntities.stream()
.sorted() .sorted()
.forEach(h -> { .forEach(h -> {
@ -95,7 +95,9 @@ public class NettyServerConnection extends AbstractNettyHandlerManager implement
try { try {
this.future = server.bind(port.getPort()).sync(); this.future = server.bind(port.getPort()).sync();
this.channel = this.future.channel(); this.channel = this.future.channel();
log.info("The server is started and can receive requests. The listening port is {}", port.getPort()); if (log.isDebugEnabled()) {
log.debug("The server is started and can receive requests. The listening port is {}", port.getPort());
}
this.port = port; this.port = port;
this.future.channel().closeFuture().sync(); this.future.channel().closeFuture().sync();
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
@ -112,7 +114,9 @@ public class NettyServerConnection extends AbstractNettyHandlerManager implement
leader.shutdownGracefully(); leader.shutdownGracefully();
worker.shutdownGracefully(); worker.shutdownGracefully();
this.future.channel().close(); this.future.channel().close();
log.info("The server is shut down and no more requests are received. The release port is {}", port.getPort()); if (log.isDebugEnabled()) {
log.debug("The server is shut down and no more requests are received. The release port is {}", port.getPort());
}
} }
@Override @Override

@ -58,7 +58,9 @@ public class NettyConnectPool {
this.handler = handler; this.handler = handler;
this.pool = new FixedChannelPool(bootstrap, handler, healthCheck, acquireTimeoutAction, this.pool = new FixedChannelPool(bootstrap, handler, healthCheck, acquireTimeoutAction,
timeout, maxConnect, maxPendingAcquires, true, true); timeout, maxConnect, maxPendingAcquires, true, true);
if (log.isDebugEnabled()) {
log.info("The connection pool is established with the connection target {}:{}", address.getHostName(), address.getPort()); log.info("The connection pool is established with the connection target {}:{}", address.getHostName(), address.getPort());
}
NettyConnectPoolHolder.createPool(address, this); NettyConnectPoolHolder.createPool(address, this);
} }

Loading…
Cancel
Save