From 2ed49ae12773f195ab3fc895f420491d9461ad8d Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Sat, 18 Sep 2021 10:26:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=80=A7=E8=83=BD?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=9F=A5=E8=AF=A2=E7=9B=91=E6=8E=A7=E7=BC=93?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/consul/ConsulService.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/backend/src/main/java/io/metersphere/consul/ConsulService.java b/backend/src/main/java/io/metersphere/consul/ConsulService.java index 5e797d06cb..2bdcd6652b 100644 --- a/backend/src/main/java/io/metersphere/consul/ConsulService.java +++ b/backend/src/main/java/io/metersphere/consul/ConsulService.java @@ -1,16 +1,15 @@ package io.metersphere.consul; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import io.metersphere.base.domain.TestResource; -import io.metersphere.commons.constants.PerformanceTestStatus; import io.metersphere.commons.constants.ResourcePoolTypeEnum; import io.metersphere.commons.constants.ResourceStatusEnum; import io.metersphere.controller.request.resourcepool.QueryResourcePoolRequest; import io.metersphere.dto.LoadTestDTO; import io.metersphere.dto.NodeDTO; import io.metersphere.dto.TestResourcePoolDTO; -import io.metersphere.performance.dto.Monitor; import io.metersphere.performance.request.QueryTestPlanRequest; import io.metersphere.performance.service.PerformanceTestService; import io.metersphere.service.TestResourcePoolService; @@ -19,7 +18,10 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.*; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @Service @@ -49,13 +51,16 @@ public class ConsulService { for (LoadTestDTO loadTestDTO : list) { String advancedConfiguration = performanceTestService.getAdvancedConfiguration(loadTestDTO.getId()); JSONObject adv = JSON.parseObject(advancedConfiguration); - Object monitorParams = adv.get("monitorParams"); - if (monitorParams == null) { + Object o1 = adv.get("monitorParams"); + if (o1 == null) { continue; } - List monitors = JSON.parseArray(monitorParams.toString(), Monitor.class); - for (Monitor monitor : monitors) { - result.put(monitor.getIp() + "-" + monitor.getPort(), Collections.singletonList("metersphere")); + + JSONArray monitorParams = adv.getJSONArray("monitorParams"); + + for (int i = 0; i < monitorParams.size(); i++) { + JSONObject o = monitorParams.getJSONObject(i); + result.put(o.getString("ip") + "-" + o.getInteger("port"), Collections.singletonList("metersphere")); } } for (TestResourcePoolDTO pool : testResourcePoolDTOS) {