From 49a5053b3889f3becf976f781b1798be0fef3230 Mon Sep 17 00:00:00 2001 From: Coooder-X <55648333+Coooder-X@users.noreply.github.com> Date: Tue, 26 Jan 2021 17:28:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20(=E6=B5=8B=E8=AF=95=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=B1=A0)=20=E4=BB=85=E5=BD=93IP=E5=92=8C=E7=AB=AF=E5=8F=A3?= =?UTF-8?q?=E5=90=8C=E6=97=B6=E9=87=8D=E5=A4=8D=E6=97=B6=EF=BC=8C=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E6=B7=BB=E5=8A=A0=E5=A4=B1=E8=B4=A5=20(#1264)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: (测试资源池)增加资源池中端口重复判断 * fix: (测试资源池) 仅当IP和端口同时重复时,提示添加失败 Co-authored-by: jianxing <41557596+AgAngle@users.noreply.github.com> --- .../service/NodeResourcePoolService.java | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/backend/src/main/java/io/metersphere/service/NodeResourcePoolService.java b/backend/src/main/java/io/metersphere/service/NodeResourcePoolService.java index fc16e3c70c..d6067166d0 100644 --- a/backend/src/main/java/io/metersphere/service/NodeResourcePoolService.java +++ b/backend/src/main/java/io/metersphere/service/NodeResourcePoolService.java @@ -10,6 +10,7 @@ import io.metersphere.commons.utils.LogUtil; import io.metersphere.dto.NodeDTO; import io.metersphere.dto.TestResourcePoolDTO; import io.metersphere.i18n.Translator; +import javafx.util.Pair; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.http.HttpStatus; @@ -39,26 +40,16 @@ public class NodeResourcePoolService { } deleteTestResource(testResourcePool.getId()); - List nodeIps = testResourcePool.getResources().stream() + List Ip_Port = testResourcePool.getResources().stream() .map(resource -> { NodeDTO nodeDTO = JSON.parseObject(resource.getConfiguration(), NodeDTO.class); - return nodeDTO.getIp(); + return new Pair(nodeDTO.getIp(), nodeDTO.getPort()); }) .distinct() .collect(Collectors.toList()); - List nodePorts = testResourcePool.getResources().stream() - .map(resource -> { - NodeDTO nodeDTO = JSON.parseObject(resource.getConfiguration(), NodeDTO.class); - return nodeDTO.getPort(); - }) - .distinct() - .collect(Collectors.toList()); - if (nodeIps.size() < testResourcePool.getResources().size() && nodePorts.size() < testResourcePool.getResources().size()) { + if (Ip_Port.size() < testResourcePool.getResources().size()) { MSException.throwException(Translator.get("duplicate_node_ip_port")); } - else if (nodeIps.size() < testResourcePool.getResources().size()) { - MSException.throwException(Translator.get("duplicate_node_ip")); - } else if (nodePorts.size() < testResourcePool.getResources().size()) { MSException.throwException(Translator.get("duplicate_node_port")); }