优化
This commit is contained in:
@@ -144,8 +144,7 @@ class ProtocolCodec implements CompletionHandler<Integer, ByteBuffer> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void decode(
|
protected void decode(ByteBuffer buffer, Response response, int pipelineIndex, Request lastReq) {
|
||||||
final ByteBuffer buffer, final Response response, final int pipelineIndex, final Request lastReq) {
|
|
||||||
response.init(channel);
|
response.init(channel);
|
||||||
final Request request = response.request;
|
final Request request = response.request;
|
||||||
final int rs = request.readHeader(buffer, lastReq);
|
final int rs = request.readHeader(buffer, lastReq);
|
||||||
@@ -163,12 +162,8 @@ class ProtocolCodec implements CompletionHandler<Integer, ByteBuffer> {
|
|||||||
} else if (rs == 0) {
|
} else if (rs == 0) {
|
||||||
context.dispatcher.incrExecuteCounter();
|
context.dispatcher.incrExecuteCounter();
|
||||||
int pindex = pipelineIndex;
|
int pindex = pipelineIndex;
|
||||||
boolean pipeline = false;
|
|
||||||
boolean seted = false;
|
|
||||||
boolean completed = request.completed;
|
|
||||||
Request hreq = lastReq;
|
Request hreq = lastReq;
|
||||||
if (buffer.hasRemaining()) {
|
if (buffer.hasRemaining()) { // pipeline模式
|
||||||
pipeline = true;
|
|
||||||
if (pindex == 0) {
|
if (pindex == 0) {
|
||||||
pindex++;
|
pindex++;
|
||||||
}
|
}
|
||||||
@@ -178,15 +173,7 @@ class ProtocolCodec implements CompletionHandler<Integer, ByteBuffer> {
|
|||||||
if (hreq == null) {
|
if (hreq == null) {
|
||||||
hreq = request.copyHeader();
|
hreq = request.copyHeader();
|
||||||
}
|
}
|
||||||
} else {
|
context.executeDispatch(request, response);
|
||||||
if (request.getRequestid() == null) { // 存在requestid则无视pipeline模式
|
|
||||||
request.pipeline(pindex, pindex);
|
|
||||||
}
|
|
||||||
channel.setReadBuffer(buffer.clear());
|
|
||||||
seted = true;
|
|
||||||
}
|
|
||||||
context.executeDispatch(request, response);
|
|
||||||
if (pipeline) {
|
|
||||||
final Response pipelineResponse = createResponse();
|
final Response pipelineResponse = createResponse();
|
||||||
try {
|
try {
|
||||||
decode(buffer, pipelineResponse, pindex + 1, hreq);
|
decode(buffer, pipelineResponse, pindex + 1, hreq);
|
||||||
@@ -194,13 +181,15 @@ class ProtocolCodec implements CompletionHandler<Integer, ByteBuffer> {
|
|||||||
context.logger.log(Level.WARNING, "dispatch pipeline servlet abort, force to close channel ", t);
|
context.logger.log(Level.WARNING, "dispatch pipeline servlet abort, force to close channel ", t);
|
||||||
pipelineResponse.codecError(t);
|
pipelineResponse.codecError(t);
|
||||||
}
|
}
|
||||||
} else if (completed) {
|
} else {
|
||||||
if (!seted) {
|
if (request.getRequestid() == null) { // 存在requestid则无视pipeline模式
|
||||||
channel.setReadBuffer(buffer.clear());
|
request.pipeline(pindex, pindex);
|
||||||
}
|
}
|
||||||
|
channel.setReadBuffer(buffer.clear());
|
||||||
|
context.executeDispatch(request, response);
|
||||||
channel.readRegister(this);
|
channel.readRegister(this);
|
||||||
}
|
}
|
||||||
} else {
|
} else { // rs > 0
|
||||||
channel.setReadBuffer(buffer);
|
channel.setReadBuffer(buffer);
|
||||||
channel.read(readHandler.prepare(request, response, pipelineIndex, lastReq));
|
channel.read(readHandler.prepare(request, response, pipelineIndex, lastReq));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class HttpContext extends Context {
|
|||||||
protected final AnyValue rpcAuthenticatorConfig;
|
protected final AnyValue rpcAuthenticatorConfig;
|
||||||
|
|
||||||
// 延迟解析header
|
// 延迟解析header
|
||||||
protected final boolean lazyHeaders; // 存在动态改值
|
protected final boolean lazyHeaders;
|
||||||
|
|
||||||
// 不带通配符的mapping url的缓存对象
|
// 不带通配符的mapping url的缓存对象
|
||||||
final Map<ByteArray, String>[] uriPathCaches = new Map[100];
|
final Map<ByteArray, String>[] uriPathCaches = new Map[100];
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
import org.redkale.convert.ConvertDisabled;
|
||||||
import org.redkale.convert.TextConvert;
|
import org.redkale.convert.TextConvert;
|
||||||
import org.redkale.convert.json.JsonConvert;
|
import org.redkale.convert.json.JsonConvert;
|
||||||
import org.redkale.util.RedkaleException;
|
import org.redkale.util.RedkaleException;
|
||||||
@@ -164,6 +165,7 @@ public class HttpParameters implements RestParams, Serializable {
|
|||||||
return this.map;
|
return this.map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ConvertDisabled
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
return this.map == null || this.map.isEmpty();
|
return this.map == null || this.map.isEmpty();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1670,6 +1670,7 @@ public class HttpRequest extends Request<HttpContext> {
|
|||||||
*
|
*
|
||||||
* @return Annotation[]
|
* @return Annotation[]
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@ConvertDisabled
|
@ConvertDisabled
|
||||||
public Annotation[] getAnnotations() {
|
public Annotation[] getAnnotations() {
|
||||||
if (this.annotations == null) {
|
if (this.annotations == null) {
|
||||||
@@ -1687,6 +1688,7 @@ public class HttpRequest extends Request<HttpContext> {
|
|||||||
* @param annotationClass 注解类型
|
* @param annotationClass 注解类型
|
||||||
* @return Annotation
|
* @return Annotation
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
|
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
|
||||||
if (this.annotations == null) {
|
if (this.annotations == null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -1706,6 +1708,7 @@ public class HttpRequest extends Request<HttpContext> {
|
|||||||
* @param annotationClass 注解类型
|
* @param annotationClass 注解类型
|
||||||
* @return Annotation[]
|
* @return Annotation[]
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
|
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
|
||||||
if (this.annotations == null) {
|
if (this.annotations == null) {
|
||||||
return Creator.newArray(annotationClass, 0);
|
return Creator.newArray(annotationClass, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user