You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by he...@apache.org on 2022/07/11 11:14:09 UTC
[inlong] branch master updated: [INLONG-4951][Manager] Fix cluster tag property update error (#4955)
This is an automated email from the ASF dual-hosted git repository.
healchow 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 2b30c6ad5 [INLONG-4951][Manager] Fix cluster tag property update error (#4955)
2b30c6ad5 is described below
commit 2b30c6ad5a7f62e5a724d76630b2572efc1a7d00
Author: woofyzhao <49...@qq.com>
AuthorDate: Mon Jul 11 19:14:05 2022 +0800
[INLONG-4951][Manager] Fix cluster tag property update error (#4955)
---
.../service/cluster/InlongClusterServiceImpl.java | 61 +++++++++++-----------
1 file changed, 30 insertions(+), 31 deletions(-)
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 3859e0935..7f72d1ae0 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
@@ -171,42 +171,41 @@ public class InlongClusterServiceImpl implements InlongClusterService {
LOGGER.warn("inlong cluster tag was not exist for id={}", id);
return true;
}
- InlongClusterTagEntity tagExist = clusterTagMapper.selectByTag(newClusterTag);
- if (tagExist != null) {
- String errMsg = String.format("inlong cluster tag [%s] already exist", newClusterTag);
- LOGGER.error(errMsg);
- throw new BusinessException(errMsg);
- }
- // check if there are some InlongGroups that uses this tag
+ // if the cluster tag was changed, need to check whether the new tag already exists
String oldClusterTag = exist.getClusterTag();
- this.assertNoInlongGroupExists(oldClusterTag);
+ if (!newClusterTag.equals(oldClusterTag)) {
+ InlongClusterTagEntity tagConflict = clusterTagMapper.selectByTag(newClusterTag);
+ if (tagConflict != null) {
+ String errMsg = String.format("inlong cluster tag [%s] already exist", newClusterTag);
+ LOGGER.error(errMsg);
+ throw new BusinessException(errMsg);
+ }
- // update the associated cluster tag in inlong_cluster
- Date now = new Date();
- List<InlongClusterEntity> clusterEntities = clusterMapper.selectByKey(newClusterTag, null, null);
- if (CollectionUtils.isNotEmpty(clusterEntities)) {
- clusterEntities.forEach(entity -> {
- HashSet<String> tagSet = Sets.newHashSet(entity.getClusterTags().split(","));
- tagSet.remove(oldClusterTag);
- tagSet.add(newClusterTag);
- String updateTags = Joiner.on(",").join(tagSet);
- entity.setClusterTags(updateTags);
- entity.setModifier(operator);
- entity.setModifyTime(now);
- clusterMapper.updateByIdSelective(entity);
- });
+ // check if there are some InlongGroups that uses this tag
+ this.assertNoInlongGroupExists(oldClusterTag);
+
+ // update the associated cluster tag in inlong_cluster
+ Date now = new Date();
+ List<InlongClusterEntity> clusterEntities = clusterMapper.selectByKey(oldClusterTag, null, null);
+ if (CollectionUtils.isNotEmpty(clusterEntities)) {
+ clusterEntities.forEach(entity -> {
+ HashSet<String> tagSet = Sets.newHashSet(entity.getClusterTags().split(","));
+ tagSet.remove(oldClusterTag);
+ tagSet.add(newClusterTag);
+ String updateTags = Joiner.on(",").join(tagSet);
+ entity.setClusterTags(updateTags);
+ entity.setModifier(operator);
+ entity.setModifyTime(now);
+ clusterMapper.updateByIdSelective(entity);
+ });
+ }
}
- InlongClusterTagEntity entity = clusterTagMapper.selectById(id);
- if (entity == null) {
- LOGGER.error("cluster tag not found by id={}", id);
- throw new BusinessException(ErrorCodeEnum.CLUSTER_NOT_FOUND);
- }
- CommonBeanUtils.copyProperties(request, entity, true);
- entity.setModifier(operator);
- entity.setModifyTime(new Date());
- clusterTagMapper.updateById(entity);
+ CommonBeanUtils.copyProperties(request, exist, true);
+ exist.setModifier(operator);
+ exist.setModifyTime(new Date());
+ clusterTagMapper.updateById(exist);
LOGGER.info("success to update cluster tag={}", request);
return true;
}