From e54bd0dc1481e52f543ac8da67fd537b1f42ef39 Mon Sep 17 00:00:00 2001 From: wenyann <64353056+wenyann@users.noreply.github.com> Date: Thu, 5 Nov 2020 14:54:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=8F=91=E9=80=81=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notice/PerformanceNoticeTask.java | 39 +++++++++---------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/backend/src/main/java/io/metersphere/performance/notice/PerformanceNoticeTask.java b/backend/src/main/java/io/metersphere/performance/notice/PerformanceNoticeTask.java index 2daeca53a3..5b041a02b4 100644 --- a/backend/src/main/java/io/metersphere/performance/notice/PerformanceNoticeTask.java +++ b/backend/src/main/java/io/metersphere/performance/notice/PerformanceNoticeTask.java @@ -47,27 +47,26 @@ public class PerformanceNoticeTask { } public void registerNoticeTask(LoadTestReportWithBLOBs loadTestReport) { - executorService.submit(() -> { - while (isRunning) { - LoadTestReportWithBLOBs loadTestReportFromDatabase = loadTestReportMapper.selectByPrimaryKey(loadTestReport.getId()); - - if (StringUtils.equals(loadTestReportFromDatabase.getStatus(), PerformanceTestStatus.Completed.name())) { - isRunning = false; - sendSuccessNotice(loadTestReportFromDatabase); - return; - } - if (StringUtils.equals(loadTestReportFromDatabase.getStatus(), PerformanceTestStatus.Error.name())) { - isRunning = false; - sendFailNotice(loadTestReportFromDatabase); - return; - } - try { - Thread.sleep(1000 * 60);// 每分钟检查 loadtest 的状态 - } catch (InterruptedException e) { - LogUtil.error(e); - } + int count = 20; + while (count-- > 0) { + LoadTestReportWithBLOBs loadTestReportFromDatabase = loadTestReportMapper.selectByPrimaryKey(loadTestReport.getId()); + if (StringUtils.equals(loadTestReportFromDatabase.getStatus(), PerformanceTestStatus.Completed.name())) { + isRunning = false; + sendSuccessNotice(loadTestReportFromDatabase); + return; } - }); + if (StringUtils.equals(loadTestReportFromDatabase.getStatus(), PerformanceTestStatus.Error.name())) { + isRunning = false; + sendFailNotice(loadTestReportFromDatabase); + return; + } + count--; + try { + Thread.sleep(1000 * 4L);// 每分钟检查 loadtest 的状态 + } catch (InterruptedException e) { + LogUtil.error(e); + } + } } public void sendSuccessNotice(LoadTestReportWithBLOBs loadTestReport) {