From 6e3ad838e3101cf8df2a430e294fc634943bdc87 Mon Sep 17 00:00:00 2001 From: tomsun28 Date: Tue, 23 Nov 2021 21:14:40 +0800 Subject: [PATCH] =?UTF-8?q?[scheduler]=20=E8=A7=A3=E5=86=B3=E9=87=87?= =?UTF-8?q?=E9=9B=86=E4=BB=BB=E5=8A=A1=E5=86=85=E5=AE=B9=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=97=B6=E8=B0=83=E5=BA=A6=E5=A4=B1=E6=95=88=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E6=95=B0=E6=8D=AE=E5=BA=93=E8=BF=9E=E6=8E=A5=E5=A4=B1?= =?UTF-8?q?=E6=95=88=E5=AF=BC=E8=87=B4=E5=BA=94=E7=94=A8=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- RequestDemo.json | 2 +- .../support/GlobalExceptionHandler.java | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 84ee25c..31a0ac9 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ micronaut-cli.yml .mvn/ mvnw mvnw.bat -.log +*.log ### STS ### .apt_generated diff --git a/RequestDemo.json b/RequestDemo.json index f630186..6a29452 100644 --- a/RequestDemo.json +++ b/RequestDemo.json @@ -22,7 +22,7 @@ "id": 87584674384, "monitorId": 875846754543, "type": 1, - "value": "80" + "value": "8088" }, { "field": "host", diff --git a/manager/src/main/java/com/usthe/manager/support/GlobalExceptionHandler.java b/manager/src/main/java/com/usthe/manager/support/GlobalExceptionHandler.java index a0ee3ff..c384d4f 100644 --- a/manager/src/main/java/com/usthe/manager/support/GlobalExceptionHandler.java +++ b/manager/src/main/java/com/usthe/manager/support/GlobalExceptionHandler.java @@ -4,6 +4,7 @@ package com.usthe.manager.support; import com.usthe.common.entity.dto.Message; import com.usthe.manager.support.exception.MonitorDatabaseException; import com.usthe.manager.support.exception.MonitorDetectException; +import com.usthe.scheduler.ScheduleException; import lombok.extern.slf4j.Slf4j; import org.springframework.dao.DataAccessException; import org.springframework.http.HttpStatus; @@ -134,6 +135,23 @@ public class GlobalExceptionHandler { return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(message); } + /** + * 处理分发调度器异常问题 + * @param exception 调度器异常问题 + * @return response + */ + @ExceptionHandler(ScheduleException.class) + @ResponseBody + ResponseEntity> handleScheduleException(ScheduleException exception) { + String errorMessage = "scheduler warning"; + if (exception != null) { + errorMessage = exception.getMessage(); + } + log.warn("[scheduler warning]-{}", errorMessage); + Message message = Message.builder().msg(errorMessage).build(); + return ResponseEntity.status(HttpStatus.CONFLICT).body(message); + } + /** * handler the exception thrown for datastore error * @param exception datastore exception