Skip to content

Commit

Permalink
fix(dongtai-agent): fix monitor thread interrupt exception;
Browse files Browse the repository at this point in the history
  • Loading branch information
quericy committed Mar 29, 2022
1 parent 24afad5 commit ebe678e
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,19 @@ public void check() throws Exception {

@Override
public void run() {
while (!MonitorDaemonThread.isExit) {
// 延迟启动DongTaiThreadMonitor,以防首次加载时其他Monitor未能启动的情形出现。
ThreadUtils.threadSleep(10);
try {
this.check();
} catch (Throwable t) {
DongTaiLog.warn("Monitor thread checked error, monitor:{}, msg:{}, err:{}", getName(), t.getMessage(), t.getCause());
try {
while (!MonitorDaemonThread.isExit) {
// 延迟启动DongTaiThreadMonitor,以防首次加载时其他Monitor未能启动的情形出现。
ThreadUtils.threadSleep(10);
try {
this.check();
} catch (Throwable t) {
DongTaiLog.warn("Monitor thread checked error, monitor:{}, msg:{}, err:{}", getName(), t.getMessage(), t.getCause());
}
ThreadUtils.threadSleep(50);
}
ThreadUtils.threadSleep(50);
} catch (Throwable t) {
DongTaiLog.info("DongTaiThreadMonitor interrupted, msg:{}", t.getMessage());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,17 @@ public void startEngine() {

@Override
public void run() {
while (!MonitorDaemonThread.isExit) {
try {
this.check();
} catch (Throwable t) {
DongTaiLog.warn("Monitor thread checked error, monitor:{}, msg:{}, err:{}", getName(), t.getMessage(), t.getCause());
try {
while (!MonitorDaemonThread.isExit) {
try {
this.check();
} catch (Throwable t) {
DongTaiLog.warn("Monitor thread checked error, monitor:{}, msg:{}, err:{}", getName(), t.getMessage(), t.getCause());
}
ThreadUtils.threadSleep(30);
}
ThreadUtils.threadSleep(30);
} catch (Throwable t) {
DongTaiLog.info("EngineMonitor interrupted, msg:{}", t.getMessage());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ public void check() throws Exception {

@Override
public void run() {
while (!MonitorDaemonThread.isExit) {
try {
this.check();
} catch (Throwable t) {
DongTaiLog.warn("Monitor thread checked error, monitor:{}, msg:{}, err:{}", getName(), t.getMessage(), t.getCause());
try {
while (!MonitorDaemonThread.isExit) {
try {
this.check();
} catch (Throwable t) {
DongTaiLog.warn("Monitor thread checked error, monitor:{}, msg:{}, err:{}", getName(), t.getMessage(), t.getCause());
}
ThreadUtils.threadSleep(30);
}
ThreadUtils.threadSleep(30);
} catch (Throwable t) {
DongTaiLog.info("HeartBeatMonitor interrupted, msg:{}", t.getMessage());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,17 @@ private static String getThresholdValue() {

@Override
public void run() {
while(!MonitorDaemonThread.isExit) {
try {
this.check();
} catch (Throwable t) {
DongTaiLog.warn("Monitor thread checked error, monitor:{}, msg:{}, err:{}", getName(), t.getMessage(), t.getCause());
try {
while (!MonitorDaemonThread.isExit) {
try {
this.check();
} catch (Throwable t) {
DongTaiLog.warn("Monitor thread checked error, monitor:{}, msg:{}, err:{}", getName(), t.getMessage(), t.getCause());
}
ThreadUtils.threadSleep(30);
}
ThreadUtils.threadSleep(30);
} catch (Throwable t) {
DongTaiLog.info("PerformanceMonitor interrupted, msg:{}", t.getMessage());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@ public String getName() {

@Override
public void run() {
while (!MonitorDaemonThread.isExit) {
try {
this.check();
} catch (Throwable t) {
DongTaiLog.warn("Monitor thread checked error, monitor:{}, msg:{}, err:{}", getName(), t.getMessage(), t.getCause());
try {
while (!MonitorDaemonThread.isExit) {
try {
this.check();
} catch (Throwable t) {
DongTaiLog.warn("Monitor thread checked error, monitor:{}, msg:{}, err:{}", getName(), t.getMessage(), t.getCause());
}
ThreadUtils.threadSleep(60);
}
ThreadUtils.threadSleep(60);
} catch (Throwable t) {
DongTaiLog.info("SecondFallbackMonitor interrupted, msg:{}", t.getMessage());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@ public void check() throws Exception {

@Override
public void run() {
while (!MonitorDaemonThread.isExit) {
ThreadUtils.threadSleep(60);
try {
// EngineManger初始化时会请求配置一次,所以ServerConfigMonitor首次不用运行
this.check();
} catch (Throwable t) {
DongTaiLog.warn("Monitor thread checked error, monitor:{}, msg:{}, err:{}", getName(), t.getMessage(), t.getCause());
try {
while (!MonitorDaemonThread.isExit) {
ThreadUtils.threadSleep(60);
try {
// EngineManger初始化时会请求配置一次,所以ServerConfigMonitor首次不用运行
this.check();
} catch (Throwable t) {
DongTaiLog.warn("Monitor thread checked error, monitor:{}, msg:{}, err:{}", getName(), t.getMessage(), t.getCause());
}
}
} catch (Throwable t) {
DongTaiLog.info("ServerConfigMonitor interrupted, msg:{}", t.getMessage());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ public static void threadSleep(int seconds) {
long milliseconds = seconds * 1000L;
Thread.sleep(milliseconds);
} catch (InterruptedException e) {
DongTaiLog.warn("DongTai thread threadSleep failed, msg: {} , error: {}", e.getMessage(), e.getCause());
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
}

Expand Down

0 comments on commit ebe678e

Please sign in to comment.