ProtocolCodec优化
This commit is contained in:
@@ -33,7 +33,7 @@ public abstract class DispatcherServlet<K extends Serializable, C extends Contex
|
|||||||
|
|
||||||
private final LongAdder executeCounter = new LongAdder(); //执行请求次数
|
private final LongAdder executeCounter = new LongAdder(); //执行请求次数
|
||||||
|
|
||||||
private final LongAdder illRequestCounter = new LongAdder(); //错误请求次数
|
private final LongAdder illegalRequestCounter = new LongAdder(); //错误请求次数
|
||||||
|
|
||||||
private final Object servletLock = new Object();
|
private final Object servletLock = new Object();
|
||||||
|
|
||||||
@@ -53,8 +53,8 @@ public abstract class DispatcherServlet<K extends Serializable, C extends Contex
|
|||||||
executeCounter.increment();
|
executeCounter.increment();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void incrIllRequestCounter() {
|
protected void incrIllegalRequestCounter() {
|
||||||
illRequestCounter.increment();
|
illegalRequestCounter.increment();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void putServlet(S servlet) {
|
protected void putServlet(S servlet) {
|
||||||
@@ -279,7 +279,7 @@ public abstract class DispatcherServlet<K extends Serializable, C extends Contex
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Long getIllRequestCounter() {
|
public Long getIllRequestCounter() {
|
||||||
return illRequestCounter.longValue();
|
return illegalRequestCounter.longValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import java.util.function.*;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 一个AsyncConnection绑定一个ProtocolCodec实例
|
* 一个AsyncConnection绑定一个ProtocolCodec实例, 只会在读IOThread中运行
|
||||||
*
|
*
|
||||||
* @author zhangjx
|
* @author zhangjx
|
||||||
*/
|
*/
|
||||||
@@ -146,7 +146,7 @@ class ProtocolCodec implements CompletionHandler<Integer, ByteBuffer> {
|
|||||||
preparer.incrExecuteCounter();
|
preparer.incrExecuteCounter();
|
||||||
channel.offerReadBuffer(buffer);
|
channel.offerReadBuffer(buffer);
|
||||||
if (rs != Integer.MIN_VALUE) {
|
if (rs != Integer.MIN_VALUE) {
|
||||||
preparer.incrIllRequestCounter();
|
preparer.incrIllegalRequestCounter();
|
||||||
}
|
}
|
||||||
response.finish(true);
|
response.finish(true);
|
||||||
if (context.logger.isLoggable(Level.FINEST)) {
|
if (context.logger.isLoggable(Level.FINEST)) {
|
||||||
@@ -197,7 +197,7 @@ class ProtocolCodec implements CompletionHandler<Integer, ByteBuffer> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void failed(Throwable exc, ByteBuffer attachment) {
|
public void failed(Throwable exc, ByteBuffer attachment) {
|
||||||
context.prepare.incrIllRequestCounter();
|
context.prepare.incrIllegalRequestCounter();
|
||||||
channel.offerReadBuffer(attachment);
|
channel.offerReadBuffer(attachment);
|
||||||
response.finish(true);
|
response.finish(true);
|
||||||
if (exc != null) {
|
if (exc != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user