优化日志级别调用方式
This commit is contained in:
@@ -33,8 +33,6 @@ public final class ClassFilter<T> {
|
|||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(ClassFilter.class.getName()); //日志对象
|
private static final Logger logger = Logger.getLogger(ClassFilter.class.getName()); //日志对象
|
||||||
|
|
||||||
private static final boolean finest = logger.isLoggable(Level.FINEST); //日志级别
|
|
||||||
|
|
||||||
private final Set<FilterEntry<T>> entrys = new HashSet<>(); //符合条件的结果
|
private final Set<FilterEntry<T>> entrys = new HashSet<>(); //符合条件的结果
|
||||||
|
|
||||||
private final Set<FilterEntry<T>> expectEntrys = new HashSet<>(); //准备符合条件的结果
|
private final Set<FilterEntry<T>> expectEntrys = new HashSet<>(); //准备符合条件的结果
|
||||||
@@ -210,7 +208,7 @@ public final class ClassFilter<T> {
|
|||||||
entrys.add(new FilterEntry(clazz, autoscan, false, property));
|
entrys.add(new FilterEntry(clazz, autoscan, false, property));
|
||||||
}
|
}
|
||||||
} catch (Throwable cfe) {
|
} catch (Throwable cfe) {
|
||||||
if (finest && !clazzname.startsWith("sun.") && !clazzname.startsWith("javax.")
|
if (logger.isLoggable(Level.FINEST) && !clazzname.startsWith("sun.") && !clazzname.startsWith("javax.")
|
||||||
&& !clazzname.startsWith("com.sun.") && !clazzname.startsWith("jdk.") && !clazzname.startsWith("META-INF")
|
&& !clazzname.startsWith("com.sun.") && !clazzname.startsWith("jdk.") && !clazzname.startsWith("META-INF")
|
||||||
&& !clazzname.startsWith("com.mysql.") && !clazzname.startsWith("com.microsoft.") && !clazzname.startsWith("freemarker.")
|
&& !clazzname.startsWith("com.mysql.") && !clazzname.startsWith("com.microsoft.") && !clazzname.startsWith("freemarker.")
|
||||||
&& !clazzname.startsWith("org.redkale") && (clazzname.contains("Service") || clazzname.contains("Servlet"))) {
|
&& !clazzname.startsWith("org.redkale") && (clazzname.contains("Service") || clazzname.contains("Servlet"))) {
|
||||||
|
|||||||
@@ -380,7 +380,6 @@ public class NodeHttpServer extends NodeServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
final ClassFilter restFilter = ClassFilter.create(serverClassLoader, null, application.isCompileMode() ? "" : restConf.getValue("includes", ""), application.isCompileMode() ? "" : restConf.getValue("excludes", ""), includeValues, excludeValues);
|
final ClassFilter restFilter = ClassFilter.create(serverClassLoader, null, application.isCompileMode() ? "" : restConf.getValue("includes", ""), application.isCompileMode() ? "" : restConf.getValue("excludes", ""), includeValues, excludeValues);
|
||||||
final boolean finest = logger.isLoggable(Level.FINEST);
|
|
||||||
|
|
||||||
List<FilterEntry<? extends WebSocket>> list = new ArrayList(webSocketFilter.getFilterEntrys());
|
List<FilterEntry<? extends WebSocket>> list = new ArrayList(webSocketFilter.getFilterEntrys());
|
||||||
for (FilterEntry<? extends WebSocket> en : list) {
|
for (FilterEntry<? extends WebSocket> en : list) {
|
||||||
@@ -412,7 +411,9 @@ public class NodeHttpServer extends NodeServer {
|
|||||||
WebServlet ws = servlet.getClass().getAnnotation(WebServlet.class);
|
WebServlet ws = servlet.getClass().getAnnotation(WebServlet.class);
|
||||||
if (ws != null && !ws.repair()) prefix2 = "";
|
if (ws != null && !ws.repair()) prefix2 = "";
|
||||||
resourceFactory.inject(servlet, NodeHttpServer.this);
|
resourceFactory.inject(servlet, NodeHttpServer.this);
|
||||||
if (finest) logger.finest(localThreadName + " " + stype.getName() + " create a RestWebSocketServlet");
|
if (logger.isLoggable(Level.FINEST)) {
|
||||||
|
logger.finest(localThreadName + " " + stype.getName() + " create a RestWebSocketServlet");
|
||||||
|
}
|
||||||
if (webss != null) {
|
if (webss != null) {
|
||||||
String[] mappings = servlet.getClass().getAnnotation(WebServlet.class).value();
|
String[] mappings = servlet.getClass().getAnnotation(WebServlet.class).value();
|
||||||
for (int i = 0; i < mappings.length; i++) {
|
for (int i = 0; i < mappings.length; i++) {
|
||||||
|
|||||||
@@ -52,9 +52,6 @@ public class HttpMessageClusterClient extends HttpMessageClient {
|
|||||||
Objects.requireNonNull(clusterAgent);
|
Objects.requireNonNull(clusterAgent);
|
||||||
this.localClient = new HttpMessageLocalClient(application, resourceName);
|
this.localClient = new HttpMessageLocalClient(application, resourceName);
|
||||||
this.clusterAgent = clusterAgent;
|
this.clusterAgent = clusterAgent;
|
||||||
this.finest = logger.isLoggable(Level.FINEST);
|
|
||||||
this.finer = logger.isLoggable(Level.FINER);
|
|
||||||
this.fine = logger.isLoggable(Level.FINE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -89,7 +86,7 @@ public class HttpMessageClusterClient extends HttpMessageClient {
|
|||||||
final String localModule = module;
|
final String localModule = module;
|
||||||
return clusterAgent.queryMqtpAddress("mqtp", module, resname).thenCompose(addrmap -> {
|
return clusterAgent.queryMqtpAddress("mqtp", module, resname).thenCompose(addrmap -> {
|
||||||
if (addrmap == null || addrmap.isEmpty()) {
|
if (addrmap == null || addrmap.isEmpty()) {
|
||||||
if (fine) logger.log(Level.FINE, "mqtpAsync.broadcastMessage: module=" + localModule + ", resname=" + resname + ", addrmap is empty");
|
if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE, "mqtpAsync.broadcastMessage: module=" + localModule + ", resname=" + resname + ", addrmap is empty");
|
||||||
return new HttpResult<byte[]>().status(404).toFuture();
|
return new HttpResult<byte[]>().status(404).toFuture();
|
||||||
}
|
}
|
||||||
final Map<String, String> clientHeaders = new LinkedHashMap<>();
|
final Map<String, String> clientHeaders = new LinkedHashMap<>();
|
||||||
@@ -118,7 +115,7 @@ public class HttpMessageClusterClient extends HttpMessageClient {
|
|||||||
if (paramstr != null) clientBody = paramstr.getBytes(StandardCharsets.UTF_8);
|
if (paramstr != null) clientBody = paramstr.getBytes(StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
List<CompletableFuture> futures = new ArrayList<>();
|
List<CompletableFuture> futures = new ArrayList<>();
|
||||||
if (finest) logger.log(Level.FINEST, "mqtpAsync: module=" + localModule + ", resname=" + resname + ", addrmap=" + addrmap);
|
if (logger.isLoggable(Level.FINEST)) logger.log(Level.FINEST, "mqtpAsync: module=" + localModule + ", resname=" + resname + ", addrmap=" + addrmap);
|
||||||
for (Map.Entry<String, Collection<InetSocketAddress>> en : addrmap.entrySet()) {
|
for (Map.Entry<String, Collection<InetSocketAddress>> en : addrmap.entrySet()) {
|
||||||
String realmodule = en.getKey();
|
String realmodule = en.getKey();
|
||||||
Collection<InetSocketAddress> addrs = en.getValue();
|
Collection<InetSocketAddress> addrs = en.getValue();
|
||||||
@@ -126,7 +123,7 @@ public class HttpMessageClusterClient extends HttpMessageClient {
|
|||||||
String suburi = req.getRequestURI();
|
String suburi = req.getRequestURI();
|
||||||
suburi = suburi.substring(1); //跳过 /
|
suburi = suburi.substring(1); //跳过 /
|
||||||
suburi = "/" + realmodule + suburi.substring(suburi.indexOf('/'));
|
suburi = "/" + realmodule + suburi.substring(suburi.indexOf('/'));
|
||||||
futures.add(forEachCollectionFuture(finest, userid, req, (req.getPath() != null && !req.getPath().isEmpty() ? req.getPath() : "") + suburi, clientHeaders, clientBody, addrs.iterator()));
|
futures.add(forEachCollectionFuture(logger.isLoggable(Level.FINEST), userid, req, (req.getPath() != null && !req.getPath().isEmpty() ? req.getPath() : "") + suburi, clientHeaders, clientBody, addrs.iterator()));
|
||||||
}
|
}
|
||||||
if (futures.isEmpty()) return CompletableFuture.completedFuture(null);
|
if (futures.isEmpty()) return CompletableFuture.completedFuture(null);
|
||||||
return CompletableFuture.allOf(futures.toArray(new CompletableFuture[futures.size()])).thenApply(v -> null);
|
return CompletableFuture.allOf(futures.toArray(new CompletableFuture[futures.size()])).thenApply(v -> null);
|
||||||
@@ -140,10 +137,10 @@ public class HttpMessageClusterClient extends HttpMessageClient {
|
|||||||
Map<String, String> headers = req.getHeaders();
|
Map<String, String> headers = req.getHeaders();
|
||||||
String resname = headers == null ? "" : headers.getOrDefault(Rest.REST_HEADER_RESOURCE_NAME, "");
|
String resname = headers == null ? "" : headers.getOrDefault(Rest.REST_HEADER_RESOURCE_NAME, "");
|
||||||
final String localModule = module;
|
final String localModule = module;
|
||||||
if (finest) logger.log(Level.FINEST, "httpAsync.queryHttpAddress: module=" + localModule + ", resname=" + resname);
|
if (logger.isLoggable(Level.FINEST)) logger.log(Level.FINEST, "httpAsync.queryHttpAddress: module=" + localModule + ", resname=" + resname);
|
||||||
return clusterAgent.queryHttpAddress("http", module, resname).thenCompose(addrs -> {
|
return clusterAgent.queryHttpAddress("http", module, resname).thenCompose(addrs -> {
|
||||||
if (addrs == null || addrs.isEmpty()) {
|
if (addrs == null || addrs.isEmpty()) {
|
||||||
if (fine) logger.log(Level.FINE, "httpAsync." + (produce ? "produceMessage" : "sendMessage") + ": module=" + localModule + ", resname=" + resname + ", addrmap is empty");
|
if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE, "httpAsync." + (produce ? "produceMessage" : "sendMessage") + ": module=" + localModule + ", resname=" + resname + ", addrmap is empty");
|
||||||
return new HttpResult<byte[]>().status(404).toFuture();
|
return new HttpResult<byte[]>().status(404).toFuture();
|
||||||
}
|
}
|
||||||
final Map<String, String> clientHeaders = new LinkedHashMap<>();
|
final Map<String, String> clientHeaders = new LinkedHashMap<>();
|
||||||
@@ -176,8 +173,8 @@ public class HttpMessageClusterClient extends HttpMessageClient {
|
|||||||
String paramstr = req.getParametersToString();
|
String paramstr = req.getParametersToString();
|
||||||
if (paramstr != null) clientBody = paramstr.getBytes(StandardCharsets.UTF_8);
|
if (paramstr != null) clientBody = paramstr.getBytes(StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
if (finest) logger.log(Level.FINEST, "httpAsync: module=" + localModule + ", resname=" + resname + ", enter forEachCollectionFuture");
|
if (logger.isLoggable(Level.FINEST)) logger.log(Level.FINEST, "httpAsync: module=" + localModule + ", resname=" + resname + ", enter forEachCollectionFuture");
|
||||||
return forEachCollectionFuture(finest, userid, req, (req.getPath() != null && !req.getPath().isEmpty() ? req.getPath() : "") + req.getRequestURI(), clientHeaders, clientBody, addrs.iterator());
|
return forEachCollectionFuture(logger.isLoggable(Level.FINEST), userid, req, (req.getPath() != null && !req.getPath().isEmpty() ? req.getPath() : "") + req.getRequestURI(), clientHeaders, clientBody, addrs.iterator());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public class HttpMessageLocalClient extends HttpMessageClient {
|
|||||||
HttpServlet servlet = findHttpServlet(topic);
|
HttpServlet servlet = findHttpServlet(topic);
|
||||||
CompletableFuture future = new CompletableFuture();
|
CompletableFuture future = new CompletableFuture();
|
||||||
if (servlet == null) {
|
if (servlet == null) {
|
||||||
if (fine) logger.log(Level.FINE, "sendMessage: request=" + request + ", not found servlet");
|
if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE, "sendMessage: request=" + request + ", not found servlet");
|
||||||
future.completeExceptionally(new RuntimeException("404 Not Found " + topic));
|
future.completeExceptionally(new RuntimeException("404 Not Found " + topic));
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,7 @@ public class HttpMessageLocalClient extends HttpMessageClient {
|
|||||||
public CompletableFuture<HttpResult<byte[]>> sendMessage(String topic, Serializable userid, String groupid, HttpSimpleRequest request, AtomicLong counter) {
|
public CompletableFuture<HttpResult<byte[]>> sendMessage(String topic, Serializable userid, String groupid, HttpSimpleRequest request, AtomicLong counter) {
|
||||||
HttpServlet servlet = findHttpServlet(topic);
|
HttpServlet servlet = findHttpServlet(topic);
|
||||||
if (servlet == null) {
|
if (servlet == null) {
|
||||||
if (fine) logger.log(Level.FINE, "sendMessage: request=" + request + ", not found servlet");
|
if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE, "sendMessage: request=" + request + ", not found servlet");
|
||||||
return CompletableFuture.completedFuture(new HttpResult().status(404));
|
return CompletableFuture.completedFuture(new HttpResult().status(404));
|
||||||
}
|
}
|
||||||
HttpRequest req = new HttpMessageLocalRequest(context(), request, userid);
|
HttpRequest req = new HttpMessageLocalRequest(context(), request, userid);
|
||||||
@@ -144,7 +144,7 @@ public class HttpMessageLocalClient extends HttpMessageClient {
|
|||||||
HttpDispatcherServlet ps = dispatcherServlet();
|
HttpDispatcherServlet ps = dispatcherServlet();
|
||||||
HttpServlet servlet = ps.findServletByTopic(topic);
|
HttpServlet servlet = ps.findServletByTopic(topic);
|
||||||
if (servlet == null) {
|
if (servlet == null) {
|
||||||
if (fine) logger.log(Level.FINE, "produceMessage: request=" + request + ", not found servlet");
|
if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE, "produceMessage: request=" + request + ", not found servlet");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
HttpRequest req = new HttpMessageLocalRequest(context(), request, userid);
|
HttpRequest req = new HttpMessageLocalRequest(context(), request, userid);
|
||||||
|
|||||||
@@ -25,12 +25,6 @@ import org.redkale.util.*;
|
|||||||
*/
|
*/
|
||||||
public class HttpMessageProcessor implements MessageProcessor {
|
public class HttpMessageProcessor implements MessageProcessor {
|
||||||
|
|
||||||
protected final boolean finest;
|
|
||||||
|
|
||||||
protected final boolean finer;
|
|
||||||
|
|
||||||
protected final boolean fine;
|
|
||||||
|
|
||||||
protected final Logger logger;
|
protected final Logger logger;
|
||||||
|
|
||||||
protected HttpMessageClient messageClient;
|
protected HttpMessageClient messageClient;
|
||||||
@@ -65,9 +59,6 @@ public class HttpMessageProcessor implements MessageProcessor {
|
|||||||
|
|
||||||
public HttpMessageProcessor(Logger logger, HttpMessageClient messageClient, MessageProducers producers, NodeHttpServer server, Service service, HttpServlet servlet) {
|
public HttpMessageProcessor(Logger logger, HttpMessageClient messageClient, MessageProducers producers, NodeHttpServer server, Service service, HttpServlet servlet) {
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.finest = logger.isLoggable(Level.FINEST);
|
|
||||||
this.finer = logger.isLoggable(Level.FINER);
|
|
||||||
this.fine = logger.isLoggable(Level.FINE);
|
|
||||||
this.messageClient = messageClient;
|
this.messageClient = messageClient;
|
||||||
this.producers = producers;
|
this.producers = producers;
|
||||||
this.server = server;
|
this.server = server;
|
||||||
@@ -110,16 +101,16 @@ public class HttpMessageProcessor implements MessageProcessor {
|
|||||||
|
|
||||||
server.getHttpServer().getContext().execute(servlet, request, response);
|
server.getHttpServer().getContext().execute(servlet, request, response);
|
||||||
long o = System.currentTimeMillis() - now;
|
long o = System.currentTimeMillis() - now;
|
||||||
if ((cha > 1000 || e > 100 || o > 1000) && fine) {
|
if ((cha > 1000 || e > 100 || o > 1000) && logger.isLoggable(Level.FINE)) {
|
||||||
logger.log(Level.FINE, "HttpMessageProcessor.process (mqs.delays = " + cha + " ms, mqs.blocks = " + e + " ms, mqs.executes = " + o + " ms) message: " + message);
|
logger.log(Level.FINE, "HttpMessageProcessor.process (mqs.delays = " + cha + " ms, mqs.blocks = " + e + " ms, mqs.executes = " + o + " ms) message: " + message);
|
||||||
} else if ((cha > 50 || e > 10 || o > 50) && finer) {
|
} else if ((cha > 50 || e > 10 || o > 50) && logger.isLoggable(Level.FINER)) {
|
||||||
logger.log(Level.FINER, "HttpMessageProcessor.process (mq.delays = " + cha + " ms, mq.blocks = " + e + " ms, mq.executes = " + o + " ms) message: " + message);
|
logger.log(Level.FINER, "HttpMessageProcessor.process (mq.delays = " + cha + " ms, mq.blocks = " + e + " ms, mq.executes = " + o + " ms) message: " + message);
|
||||||
} else if (finest) {
|
} else if (logger.isLoggable(Level.FINEST)) {
|
||||||
logger.log(Level.FINEST, "HttpMessageProcessor.process (mq.delay = " + cha + " ms, mq.block = " + e + " ms, mq.execute = " + o + " ms) message: " + message);
|
logger.log(Level.FINEST, "HttpMessageProcessor.process (mq.delay = " + cha + " ms, mq.block = " + e + " ms, mq.execute = " + o + " ms) message: " + message);
|
||||||
}
|
}
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
if (message.getRespTopic() != null && !message.getRespTopic().isEmpty()) {
|
if (message.getRespTopic() != null && !message.getRespTopic().isEmpty()) {
|
||||||
HttpMessageResponse.finishHttpResult(finest, request == null ? null : request.getRespConvert(),
|
HttpMessageResponse.finishHttpResult(logger.isLoggable(Level.FINEST), request == null ? null : request.getRespConvert(),
|
||||||
null, message, callback, messageClient, producers.getProducer(message), message.getRespTopic(), new HttpResult().status(500));
|
null, message, callback, messageClient, producers.getProducer(message), message.getRespTopic(), new HttpResult().status(500));
|
||||||
}
|
}
|
||||||
logger.log(Level.SEVERE, HttpMessageProcessor.class.getSimpleName() + " process error, message=" + message, ex instanceof CompletionException ? ((CompletionException) ex).getCause() : ex);
|
logger.log(Level.SEVERE, HttpMessageProcessor.class.getSimpleName() + " process error, message=" + message, ex instanceof CompletionException ? ((CompletionException) ex).getCause() : ex);
|
||||||
|
|||||||
@@ -36,8 +36,6 @@ public class HttpMessageResponse extends HttpResponse {
|
|||||||
|
|
||||||
protected MessageProducer producer;
|
protected MessageProducer producer;
|
||||||
|
|
||||||
protected boolean finest;
|
|
||||||
|
|
||||||
protected Runnable callback;
|
protected Runnable callback;
|
||||||
|
|
||||||
public HttpMessageResponse(HttpContext context, HttpMessageClient messageClient, final Supplier<HttpMessageResponse> respSupplier, final Consumer<HttpMessageResponse> respConsumer) {
|
public HttpMessageResponse(HttpContext context, HttpMessageClient messageClient, final Supplier<HttpMessageResponse> respSupplier, final Consumer<HttpMessageResponse> respConsumer) {
|
||||||
@@ -61,7 +59,6 @@ public class HttpMessageResponse extends HttpResponse {
|
|||||||
this.message = message;
|
this.message = message;
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
this.producer = producer;
|
this.producer = producer;
|
||||||
this.finest = producer.logger.isLoggable(Level.FINEST);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HttpMessageRequest request() {
|
public HttpMessageRequest request() {
|
||||||
@@ -69,11 +66,11 @@ public class HttpMessageResponse extends HttpResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void finishHttpResult(Type type, HttpResult result) {
|
public void finishHttpResult(Type type, HttpResult result) {
|
||||||
finishHttpResult(this.finest, ((HttpMessageRequest) this.request).getRespConvert(), type, this.message, this.callback, this.messageClient, this.producer, message.getRespTopic(), result);
|
finishHttpResult(producer.logger.isLoggable(Level.FINEST), ((HttpMessageRequest) this.request).getRespConvert(), type, this.message, this.callback, this.messageClient, this.producer, message.getRespTopic(), result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void finishHttpResult(Type type, Convert respConvert, HttpResult result) {
|
public void finishHttpResult(Type type, Convert respConvert, HttpResult result) {
|
||||||
finishHttpResult(this.finest, respConvert == null ? ((HttpMessageRequest) this.request).getRespConvert() : respConvert, type, this.message, this.callback, this.messageClient, this.producer, message.getRespTopic(), result);
|
finishHttpResult(producer.logger.isLoggable(Level.FINEST), respConvert == null ? ((HttpMessageRequest) this.request).getRespConvert() : respConvert, type, this.message, this.callback, this.messageClient, this.producer, message.getRespTopic(), result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void finishHttpResult(boolean finest, Convert respConvert, Type type, MessageRecord msg, Runnable callback, MessageClient messageClient, MessageProducer producer, String resptopic, HttpResult result) {
|
public static void finishHttpResult(boolean finest, Convert respConvert, Type type, MessageRecord msg, Runnable callback, MessageClient messageClient, MessageProducer producer, String resptopic, HttpResult result) {
|
||||||
@@ -109,7 +106,6 @@ public class HttpMessageResponse extends HttpResponse {
|
|||||||
this.message = null;
|
this.message = null;
|
||||||
this.producer = null;
|
this.producer = null;
|
||||||
this.callback = null;
|
this.callback = null;
|
||||||
this.finest = false;
|
|
||||||
return rs;
|
return rs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,7 +203,7 @@ public class HttpMessageResponse extends HttpResponse {
|
|||||||
public void finish(int status, String msg) {
|
public void finish(int status, String msg) {
|
||||||
if (status > 400) {
|
if (status > 400) {
|
||||||
producer.logger.log(Level.WARNING, "HttpMessageResponse.finish status: " + status + ", uri: " + this.request.getRequestURI() + ", message: " + this.message);
|
producer.logger.log(Level.WARNING, "HttpMessageResponse.finish status: " + status + ", uri: " + this.request.getRequestURI() + ", message: " + this.message);
|
||||||
} else if (finest) {
|
} else if (producer.logger.isLoggable(Level.FINEST)) {
|
||||||
producer.logger.log(Level.FINEST, "HttpMessageResponse.finish status: " + status);
|
producer.logger.log(Level.FINEST, "HttpMessageResponse.finish status: " + status);
|
||||||
}
|
}
|
||||||
if (this.message.isEmptyRespTopic()) {
|
if (this.message.isEmptyRespTopic()) {
|
||||||
|
|||||||
@@ -38,20 +38,11 @@ public abstract class MessageClient {
|
|||||||
|
|
||||||
protected String respConsumerid;
|
protected String respConsumerid;
|
||||||
|
|
||||||
protected boolean finest;
|
|
||||||
|
|
||||||
protected boolean finer;
|
|
||||||
|
|
||||||
protected boolean fine;
|
|
||||||
|
|
||||||
private final String clazzName;
|
private final String clazzName;
|
||||||
|
|
||||||
protected MessageClient(MessageAgent messageAgent) {
|
protected MessageClient(MessageAgent messageAgent) {
|
||||||
this.messageAgent = messageAgent;
|
this.messageAgent = messageAgent;
|
||||||
this.msgSeqno = messageAgent == null ? new AtomicLong() : messageAgent.msgSeqno;
|
this.msgSeqno = messageAgent == null ? new AtomicLong() : messageAgent.msgSeqno;
|
||||||
this.finest = messageAgent == null ? false : messageAgent.logger.isLoggable(Level.FINEST);
|
|
||||||
this.finer = messageAgent == null ? false : messageAgent.logger.isLoggable(Level.FINER);
|
|
||||||
this.fine = messageAgent == null ? false : messageAgent.logger.isLoggable(Level.FINE);
|
|
||||||
this.clazzName = getClass().getSimpleName();
|
this.clazzName = getClass().getSimpleName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,6 +53,7 @@ public abstract class MessageClient {
|
|||||||
|
|
||||||
protected CompletableFuture<MessageRecord> sendMessage(final MessageRecord message, boolean needresp, AtomicLong counter) {
|
protected CompletableFuture<MessageRecord> sendMessage(final MessageRecord message, boolean needresp, AtomicLong counter) {
|
||||||
CompletableFuture<MessageRecord> future = new CompletableFuture<>();
|
CompletableFuture<MessageRecord> future = new CompletableFuture<>();
|
||||||
|
boolean finest = messageAgent != null && messageAgent.logger.isLoggable(Level.FINEST);
|
||||||
try {
|
try {
|
||||||
if (this.respConsumer == null) {
|
if (this.respConsumer == null) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
@@ -81,9 +73,9 @@ public abstract class MessageClient {
|
|||||||
if (finest) messageAgent.logger.log(Level.FINEST, clazzName + ".MessageRespFutureNode.receive (mq.delay = " + cha + "ms, mq.seqid = " + msg.getSeqid() + ")");
|
if (finest) messageAgent.logger.log(Level.FINEST, clazzName + ".MessageRespFutureNode.receive (mq.delay = " + cha + "ms, mq.seqid = " + msg.getSeqid() + ")");
|
||||||
node.future.complete(msg);
|
node.future.complete(msg);
|
||||||
long cha2 = System.currentTimeMillis() - now;
|
long cha2 = System.currentTimeMillis() - now;
|
||||||
if ((cha > 1000 || cha2 > 1000) && fine) {
|
if ((cha > 1000 || cha2 > 1000) && messageAgent != null && messageAgent.logger.isLoggable(Level.FINE)) {
|
||||||
messageAgent.logger.log(Level.FINE, clazzName + ".MessageRespFutureNode.complete (mqs.delays = " + cha + "ms, mqs.completes = " + cha2 + "ms, mqs.counters = " + ncer + ") mqresp.msg: " + formatRespMessage(msg));
|
messageAgent.logger.log(Level.FINE, clazzName + ".MessageRespFutureNode.complete (mqs.delays = " + cha + "ms, mqs.completes = " + cha2 + "ms, mqs.counters = " + ncer + ") mqresp.msg: " + formatRespMessage(msg));
|
||||||
} else if ((cha > 50 || cha2 > 50) && finer) {
|
} else if ((cha > 50 || cha2 > 50) && messageAgent != null && messageAgent.logger.isLoggable(Level.FINER)) {
|
||||||
messageAgent.logger.log(Level.FINER, clazzName + ".MessageRespFutureNode.complete (mq.delays = " + cha + "ms, mq.completes = " + cha2 + "ms, mq.counters = " + ncer + ") mqresp.msg: " + formatRespMessage(msg));
|
messageAgent.logger.log(Level.FINER, clazzName + ".MessageRespFutureNode.complete (mq.delays = " + cha + "ms, mq.completes = " + cha2 + "ms, mq.counters = " + ncer + ") mqresp.msg: " + formatRespMessage(msg));
|
||||||
} else if (finest) {
|
} else if (finest) {
|
||||||
messageAgent.logger.log(Level.FINEST, clazzName + ".MessageRespFutureNode.complete (mq.delay = " + cha + "ms, mq.complete = " + cha2 + "ms, mq.counter = " + ncer + ") mqresp.msg: " + formatRespMessage(msg));
|
messageAgent.logger.log(Level.FINEST, clazzName + ".MessageRespFutureNode.complete (mq.delay = " + cha + "ms, mq.complete = " + cha2 + "ms, mq.counter = " + ncer + ") mqresp.msg: " + formatRespMessage(msg));
|
||||||
|
|||||||
@@ -24,12 +24,6 @@ import org.redkale.util.Traces;
|
|||||||
*/
|
*/
|
||||||
public class SncpMessageProcessor implements MessageProcessor {
|
public class SncpMessageProcessor implements MessageProcessor {
|
||||||
|
|
||||||
protected final boolean finest;
|
|
||||||
|
|
||||||
protected final boolean finer;
|
|
||||||
|
|
||||||
protected final boolean fine;
|
|
||||||
|
|
||||||
protected final Logger logger;
|
protected final Logger logger;
|
||||||
|
|
||||||
protected MessageClient messageClient;
|
protected MessageClient messageClient;
|
||||||
@@ -52,9 +46,6 @@ public class SncpMessageProcessor implements MessageProcessor {
|
|||||||
|
|
||||||
public SncpMessageProcessor(Logger logger, SncpMessageClient messageClient, MessageProducers producer, NodeSncpServer server, Service service, SncpServlet servlet) {
|
public SncpMessageProcessor(Logger logger, SncpMessageClient messageClient, MessageProducers producer, NodeSncpServer server, Service service, SncpServlet servlet) {
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.finest = logger.isLoggable(Level.FINEST);
|
|
||||||
this.finer = logger.isLoggable(Level.FINER);
|
|
||||||
this.fine = logger.isLoggable(Level.FINE);
|
|
||||||
this.messageClient = messageClient;
|
this.messageClient = messageClient;
|
||||||
this.producer = producer;
|
this.producer = producer;
|
||||||
this.server = server;
|
this.server = server;
|
||||||
@@ -86,11 +77,11 @@ public class SncpMessageProcessor implements MessageProcessor {
|
|||||||
|
|
||||||
context.execute(servlet, request, response);
|
context.execute(servlet, request, response);
|
||||||
long o = System.currentTimeMillis() - now;
|
long o = System.currentTimeMillis() - now;
|
||||||
if ((cha > 1000 || e > 100 || o > 1000) && fine) {
|
if ((cha > 1000 || e > 100 || o > 1000) && logger.isLoggable(Level.FINE)) {
|
||||||
logger.log(Level.FINE, "SncpMessageProcessor.process (mqs.delays = " + cha + " ms, mqs.blocks = " + e + " ms, mqs.executes = " + o + " ms) message: " + message);
|
logger.log(Level.FINE, "SncpMessageProcessor.process (mqs.delays = " + cha + " ms, mqs.blocks = " + e + " ms, mqs.executes = " + o + " ms) message: " + message);
|
||||||
} else if ((cha > 50 || e > 10 || o > 50) && finer) {
|
} else if ((cha > 50 || e > 10 || o > 50) && logger.isLoggable(Level.FINER)) {
|
||||||
logger.log(Level.FINER, "SncpMessageProcessor.process (mq.delays = " + cha + " ms, mq.blocks = " + e + " ms, mq.executes = " + o + " ms) message: " + message);
|
logger.log(Level.FINER, "SncpMessageProcessor.process (mq.delays = " + cha + " ms, mq.blocks = " + e + " ms, mq.executes = " + o + " ms) message: " + message);
|
||||||
} else if (finest) {
|
} else if (logger.isLoggable(Level.FINEST)) {
|
||||||
logger.log(Level.FINEST, "SncpMessageProcessor.process (mq.delay = " + cha + " ms, mq.block = " + e + " ms, mq.execute = " + o + " ms) message: " + message);
|
logger.log(Level.FINEST, "SncpMessageProcessor.process (mq.delay = " + cha + " ms, mq.block = " + e + " ms, mq.execute = " + o + " ms) message: " + message);
|
||||||
}
|
}
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
|
|||||||
@@ -30,8 +30,6 @@ public abstract class Client<R extends ClientRequest, P> {
|
|||||||
|
|
||||||
protected final Logger logger = Logger.getLogger(this.getClass().getSimpleName());
|
protected final Logger logger = Logger.getLogger(this.getClass().getSimpleName());
|
||||||
|
|
||||||
protected final boolean finest = logger.isLoggable(Level.FINEST);
|
|
||||||
|
|
||||||
protected final AsyncGroup group; //连接构造器
|
protected final AsyncGroup group; //连接构造器
|
||||||
|
|
||||||
protected final boolean tcp; //是否TCP协议
|
protected final boolean tcp; //是否TCP协议
|
||||||
|
|||||||
Reference in New Issue
Block a user