You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@eventmesh.apache.org by "Alonexc (via GitHub)" <gi...@apache.org> on 2023/06/02 02:59:36 UTC
[GitHub] [eventmesh] Alonexc commented on a diff in pull request #4063: [ISSUE #4062]Implement the method printRetryThreadPoolState() in EventMeshTcpRetryer
Alonexc commented on code in PR #4063:
URL: https://github.com/apache/eventmesh/pull/4063#discussion_r1213866713
##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/ThreadPoolHelper.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.runtime.util;
+
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class ThreadPoolHelper {
+
+ public static void printState(ThreadPoolExecutor threadPool) {
+ if (threadPool == null) {
+ log.warn("No thread pool is provided!");
+ return;
+ }
+
+ boolean shutdown = threadPool.isShutdown();
+ boolean terminating = threadPool.isTerminating();
+ boolean terminated = threadPool.isTerminated();
+ int activeCount = threadPool.getActiveCount();
+ long completedTaskCount = threadPool.getCompletedTaskCount();
+ long taskCount = threadPool.getTaskCount();
+ int queueSize = threadPool.getQueue().size();
+ int corePoolSize = threadPool.getCorePoolSize();
+ int maximumPoolSize = threadPool.getMaximumPoolSize();
+ long keepAliveTime = threadPool.getKeepAliveTime(TimeUnit.MILLISECONDS);
+ String rejectPolicy = threadPool.getRejectedExecutionHandler().getClass().getSimpleName();
+ if (log.isInfoEnabled()) {
+ log.info("The ThreadPool's state==================");
+ log.info("Shutdown | Terminating | Terminated: {} | {} | {}" + shutdown, terminating, terminated);
+ log.info("Active Threads: " + activeCount);
+ log.info("Completed Tasks / Tasks: {} / {}" + completedTaskCount, taskCount);
+ log.info("Queue Size: " + queueSize);
+ log.info("Core Pool Size: " + corePoolSize);
+ log.info("Maximum Pool Size: " + maximumPoolSize);
+ log.info("Keep Alive Time(ms): " + keepAliveTime);
+ log.info("The rejection policy: " + rejectPolicy);
+ log.info("========================================");
+ } else {
+ System.out.print("The ThreadPool's state==================\n");
Review Comment:
I don't think it's necessary to use `System.out` printing here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org