From b7c3202246d43a0e8354a48122980ab2cc4d3a8c Mon Sep 17 00:00:00 2001 From: hengyunabc Date: Mon, 18 May 2020 01:30:45 +0800 Subject: [PATCH] add timmer in ArthasBootstrap --- .../com/taobao/arthas/core/server/ArthasBootstrap.java | 7 +++++++ .../core/shell/system/impl/GlobalJobControllerImpl.java | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/taobao/arthas/core/server/ArthasBootstrap.java b/core/src/main/java/com/taobao/arthas/core/server/ArthasBootstrap.java index 9dd1c2ef..ceab0842 100644 --- a/core/src/main/java/com/taobao/arthas/core/server/ArthasBootstrap.java +++ b/core/src/main/java/com/taobao/arthas/core/server/ArthasBootstrap.java @@ -13,6 +13,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Properties; +import java.util.Timer; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; @@ -77,6 +78,8 @@ public class ArthasBootstrap { private static LoggerContext loggerContext; + private Timer timer = new Timer("arthas-timer", true); + private ArthasBootstrap(Instrumentation instrumentation, String args) throws Throwable { this.instrumentation = instrumentation; @@ -387,6 +390,10 @@ public class ArthasBootstrap { return tunnelClient; } + public Timer getTimer() { + return this.timer; + } + private Logger logger() { return LoggerFactory.getLogger(this.getClass()); } diff --git a/core/src/main/java/com/taobao/arthas/core/shell/system/impl/GlobalJobControllerImpl.java b/core/src/main/java/com/taobao/arthas/core/shell/system/impl/GlobalJobControllerImpl.java index 00bb3f7a..47a18001 100644 --- a/core/src/main/java/com/taobao/arthas/core/shell/system/impl/GlobalJobControllerImpl.java +++ b/core/src/main/java/com/taobao/arthas/core/shell/system/impl/GlobalJobControllerImpl.java @@ -11,11 +11,11 @@ import java.util.concurrent.TimeUnit; import com.alibaba.arthas.deps.org.slf4j.Logger; import com.alibaba.arthas.deps.org.slf4j.LoggerFactory; import com.taobao.arthas.core.GlobalOptions; +import com.taobao.arthas.core.server.ArthasBootstrap; import com.taobao.arthas.core.shell.cli.CliToken; import com.taobao.arthas.core.shell.handlers.Handler; import com.taobao.arthas.core.shell.impl.ShellImpl; import com.taobao.arthas.core.shell.system.Job; -import com.taobao.arthas.core.shell.term.impl.httptelnet.HttpTelnetTermServer; /** * 全局的Job Controller,不应该存在启停的概念,不需要在连接的断开时关闭, @@ -24,10 +24,14 @@ import com.taobao.arthas.core.shell.term.impl.httptelnet.HttpTelnetTermServer; */ public class GlobalJobControllerImpl extends JobControllerImpl { - private Timer timer = new Timer("arthas-job-timeout", true); + private Timer timer; private Map jobTimeoutTaskMap = new HashMap(); private static final Logger logger = LoggerFactory.getLogger(GlobalJobControllerImpl.class); + public GlobalJobControllerImpl() { + timer = ArthasBootstrap.getInstance().getTimer(); + } + @Override public void close(final Handler completionHandler) { if (completionHandler != null) {