|
|
@ -113,15 +113,11 @@ public class WorkerGroupServiceImpl extends BaseServiceImpl implements WorkerGro |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
Date now = new Date(); |
|
|
|
Date now = new Date(); |
|
|
|
WorkerGroup workerGroup; |
|
|
|
WorkerGroup workerGroup = null; |
|
|
|
if (id != 0) { |
|
|
|
if (id != 0) { |
|
|
|
workerGroup = workerGroupMapper.selectById(id); |
|
|
|
workerGroup = workerGroupMapper.selectById(id); |
|
|
|
// check exist
|
|
|
|
} |
|
|
|
if (workerGroup == null) { |
|
|
|
if (workerGroup == null) { |
|
|
|
workerGroup = new WorkerGroup(); |
|
|
|
|
|
|
|
workerGroup.setCreateTime(now); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
workerGroup = new WorkerGroup(); |
|
|
|
workerGroup = new WorkerGroup(); |
|
|
|
workerGroup.setCreateTime(now); |
|
|
|
workerGroup.setCreateTime(now); |
|
|
|
} |
|
|
|
} |
|
|
@ -165,23 +161,21 @@ public class WorkerGroupServiceImpl extends BaseServiceImpl implements WorkerGro |
|
|
|
* @return boolean |
|
|
|
* @return boolean |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private boolean checkWorkerGroupNameExists(WorkerGroup workerGroup) { |
|
|
|
private boolean checkWorkerGroupNameExists(WorkerGroup workerGroup) { |
|
|
|
|
|
|
|
// check database
|
|
|
|
List<WorkerGroup> workerGroupList = workerGroupMapper.queryWorkerGroupByName(workerGroup.getName()); |
|
|
|
List<WorkerGroup> workerGroupList = workerGroupMapper.queryWorkerGroupByName(workerGroup.getName()); |
|
|
|
if (CollectionUtils.isNotEmpty(workerGroupList)) { |
|
|
|
if (CollectionUtils.isNotEmpty(workerGroupList)) { |
|
|
|
// new group has same name
|
|
|
|
// create group, the same group name exists in the database
|
|
|
|
if (workerGroup.getId() == null) { |
|
|
|
if (workerGroup.getId() == null) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
// check group id
|
|
|
|
// update group, the database exists with the same group name except itself
|
|
|
|
for (WorkerGroup group : workerGroupList) { |
|
|
|
Optional<WorkerGroup> sameNameWorkGroupOptional = workerGroupList.stream() |
|
|
|
if (Objects.equals(group.getId(), workerGroup.getId())) { |
|
|
|
.filter(group -> !Objects.equals(group.getId(), workerGroup.getId())).findFirst(); |
|
|
|
return true; |
|
|
|
if (sameNameWorkGroupOptional.isPresent()) { |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// check zookeeper
|
|
|
|
return false; |
|
|
|
String workerGroupPath = |
|
|
|
|
|
|
|
Constants.REGISTRY_DOLPHINSCHEDULER_WORKERS + Constants.SINGLE_SLASH + workerGroup.getName(); |
|
|
|
|
|
|
|
return registryClient.exists(workerGroupPath); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|