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) {