From 7db1411e16363dcb0d7bec000ff711a403018831 Mon Sep 17 00:00:00 2001 From: "lambert@arch" Date: Fri, 23 Feb 2024 18:42:49 +0800 Subject: [PATCH] chore: add HealthConstant --- .../console/constant/HealthConstant.java | 22 +++++++++++++++++++ .../console/health/CheckResultCache.java | 5 ++++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/constant/HealthConstant.java diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/constant/HealthConstant.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/constant/HealthConstant.java new file mode 100644 index 00000000..16052008 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/constant/HealthConstant.java @@ -0,0 +1,22 @@ +/* + * 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.dashboard.console.constant; + +public class HealthConstant { + public static final String HEALTH_NEW_LINE_ENDING = "\n"; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/CheckResultCache.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/CheckResultCache.java index 3fdf9601..135ba9f4 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/CheckResultCache.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/health/CheckResultCache.java @@ -17,6 +17,8 @@ package org.apache.eventmesh.dashboard.console.health; +import static org.apache.eventmesh.dashboard.console.constant.HealthConstant.HEALTH_NEW_LINE_ENDING; + import org.apache.eventmesh.dashboard.console.enums.health.HealthCheckStatus; import org.apache.eventmesh.dashboard.console.health.check.config.HealthCheckObjectConfig; @@ -41,7 +43,8 @@ public void update(String type, Long typeId, HealthCheckStatus status, String re cacheMap.put(type, subMap); } CheckResult oldResult = subMap.get(typeId); - String oldDesc = Objects.isNull(oldResult.getResultDesc()) || oldResult.getResultDesc().isEmpty() ? "" : oldResult.getResultDesc() + "\n"; + String oldDesc = Objects.isNull(oldResult.getResultDesc()) || oldResult.getResultDesc().isEmpty() ? "" + : oldResult.getResultDesc() + HEALTH_NEW_LINE_ENDING; String description = oldDesc + resultDesc; description += " Latency: " + latency.toString() + "ms"; CheckResult result = new CheckResult(status, description, LocalDateTime.now(),