This is an automated email from the ASF dual-hosted git repository.
aloyszhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/inlong.git
The following commit(s) were added to refs/heads/master by this push:
new 54e0cd3b02 [INLONG-11375][Manager] Add a restriction that an IP can
only belong to one cluster (#11376)
54e0cd3b02 is described below
commit 54e0cd3b02961f27e34d046c592d2f1debaf7868
Author: fuweng11 <[email protected]>
AuthorDate: Mon Oct 21 17:20:29 2024 +0800
[INLONG-11375][Manager] Add a restriction that an IP can only belong to one
cluster (#11376)
---
.../manager/service/cluster/InlongClusterServiceImpl.java | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git
a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/cluster/InlongClusterServiceImpl.java
b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/cluster/InlongClusterServiceImpl.java
index c97971900e..2b18ba582f 100644
---
a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/cluster/InlongClusterServiceImpl.java
+++
b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/cluster/InlongClusterServiceImpl.java
@@ -714,6 +714,19 @@ public class InlongClusterServiceImpl implements
InlongClusterService {
LOGGER.error(errMsg);
throw new BusinessException(errMsg);
}
+
+ // check ip if belongs to two different clusters at the same time
+ List<InlongClusterNodeEntity> existList =
+ clusterNodeMapper.selectByIpAndType(request.getIp(),
request.getType());
+ if (CollectionUtils.isNotEmpty(existList)) {
+ InlongClusterEntity currentCluster =
clusterMapper.selectById(existList.get(0).getParentId());
+ InlongClusterEntity targetCluster =
clusterMapper.selectById(request.getParentId());
+ if (!Objects.equals(currentCluster.getId(),
targetCluster.getId())) {
+ throw new BusinessException(
+ String.format("current ip can not belong to cluster %s
and %s at the same time",
+ currentCluster.getName(),
targetCluster.getName()));
+ }
+ }
InlongClusterNodeOperator instance =
clusterNodeOperatorFactory.getInstance(request.getType());
Integer id = instance.saveOpt(request, operator);
if (request.getIsInstall()) {