Skip to content

Commit

Permalink
[INLONG-11375][Manager] Add a restriction that an IP can only belong …
Browse files Browse the repository at this point in the history
…to one cluster (#11376)
  • Loading branch information
fuweng11 authored Oct 21, 2024
1 parent 8c7d31d commit 54e0cd3
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,19 @@ public Integer saveNode(ClusterNodeRequest request, String operator) {
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()) {
Expand Down

0 comments on commit 54e0cd3

Please sign in to comment.