Skip to content
Permalink
Browse files
fix variable param is used in multi threads (#48)
fix variable param is used in multi threads
  • Loading branch information
liruixl committed Apr 18, 2022
1 parent b537b9b commit e87035e5aa65a9a5d0f47a588a911f86877968bd
Showing 1 changed file with 10 additions and 4 deletions.
@@ -115,10 +115,6 @@ public void startOperation(long resourceClusterId, long requestId) throws Except
PMResourceClusterAccessInfo.class);
// TODO:The path can be set separately for each machine later
List<ResourceNodeEntity> nodeEntities = nodeRepository.getByResourceClusterId(resourceClusterId);
AgentInstallEventConfigInfo configInfo = new AgentInstallEventConfigInfo();
configInfo.setSshUser(accessInfo.getSshUser());
configInfo.setSshPort(accessInfo.getSshPort());
configInfo.setSshKey(accessInfo.getSshKey());

log.debug("check agent port for resource cluster {} all nodes", resourceClusterId);

@@ -127,6 +123,11 @@ public void startOperation(long resourceClusterId, long requestId) throws Except
// but it may expose this problem early if the port has been used.
List<Pair<ResourceNodeEntity, CompletableFuture<Boolean>>> nodeFutures = new ArrayList<>();
for (ResourceNodeEntity nodeEntity : nodeEntities) {
AgentInstallEventConfigInfo configInfo = new AgentInstallEventConfigInfo();
configInfo.setSshUser(accessInfo.getSshUser());
configInfo.setSshPort(accessInfo.getSshPort());
configInfo.setSshKey(accessInfo.getSshKey());

CompletableFuture<Boolean> portCheckFuture = CompletableFuture.supplyAsync(() -> {
try {
nodeAndAgentManager.checkSshConnect(nodeEntity, configInfo);
@@ -169,6 +170,11 @@ public void startOperation(long resourceClusterId, long requestId) throws Except
log.debug("install agent for resource cluster {} all nodes", resourceClusterId);
for (ResourceNodeEntity nodeEntity : nodeEntities) {
log.info("start to install agent to {} node {}", nodeEntity.getId(), nodeEntity.getHost());
AgentInstallEventConfigInfo configInfo = new AgentInstallEventConfigInfo();
configInfo.setSshUser(accessInfo.getSshUser());
configInfo.setSshPort(accessInfo.getSshPort());
configInfo.setSshKey(accessInfo.getSshKey());

nodeAndAgentManager.installAgentOperation(nodeEntity, configInfo, requestId);
}
}

0 comments on commit e87035e

Please sign in to comment.