Source:
<code>public <T> List<ScriptResult<T>> executeScript(Script<T> script, String targetType, Set<String> targets) { <START> try { <END> checkPermissionAndGetClientIsSuccessful(); } catch (Exception e) { logger.error("Error while checking permission to execute script", e); return Collections.singletonList(new ScriptResult<>(new ScriptException(e))); } final TargetType tType = TargetType.valueOf(targetType); final HashSet<RMNode> selectedRMNodes = new HashSet<>(); switch (tType) { case NODESOURCE_NAME: for (String target : targets) { NodeSource nodeSource = this.deployedNodeSources.get(target); if (nodeSource != null) { Set<String> scriptExecutionHostNames = new HashSet<>(); for (RMNode candidateNode : this.allNodes.values()) { String candidateNodeHostName = candidateNode.getHostName(); if (candidateNode.getNodeSource().equals(nodeSource) && !scriptExecutionHostNames.contains(candidateNodeHostName)) { scriptExecutionHostNames.add(candidateNodeHostName); this.selectCandidateNode(selectedRMNodes, candidateNode); } } } } break; case NODE_URL: for (String target : targets) { RMNode candidateNode = this.allNodes.get(target); if (candidateNode != null) { this.selectCandidateNode(selectedRMNodes, candidateNode); } } break; case HOSTNAME: for (String target : targets) { for (RMNode node : this.allNodes.values()) { if (node.getHostName().equals(target)) { this.selectCandidateNode(selectedRMNodes, node); break; } } } break; default: throw new IllegalArgumentException("Unable to execute script, unknown target type: " + targetType); } return this.selectionManager.executeScript(script, selectedRMNodes, null); }</code><technical_language>this method service</technical_language>

Target:
public <T> List<ScriptResult<T>> executeScript(Script<T> script, String targetType, Set<String> targets) { try { checkPermissionAndGetClientIsSuccessful(); } catch (Exception e) { logger.error("Error while checking permission to execute node script", e); return Collections.singletonList(new ScriptResult<>(new ScriptException(e))); } final TargetType tType = TargetType.valueOf(targetType); final HashSet<RMNode> selectedRMNodes = new HashSet<>(); switch (tType) { case NODESOURCE_NAME: for (String target : targets) { NodeSource nodeSource = this.deployedNodeSources.get(target); if (nodeSource != null) { Set<String> scriptExecutionHostNames = new HashSet<>(); for (RMNode candidateNode : this.allNodes.values()) { String candidateNodeHostName = candidateNode.getHostName(); if (candidateNode.getNodeSource().equals(nodeSource) && !scriptExecutionHostNames.contains(candidateNodeHostName)) { scriptExecutionHostNames.add(candidateNodeHostName); this.selectCandidateNode(selectedRMNodes, candidateNode); } } } } break; case NODE_URL: for (String target : targets) { RMNode candidateNode = this.allNodes.get(target); if (candidateNode != null) { this.selectCandidateNode(selectedRMNodes, candidateNode); } } break; case HOSTNAME: for (String target : targets) { for (RMNode node : this.allNodes.values()) { if (node.getHostName().equals(target)) { this.selectCandidateNode(selectedRMNodes, node); break; } } } break; default: throw new IllegalArgumentException("Unable to execute node script, unknown target type: " + targetType); } return this.selectionManager.executeScript(script, selectedRMNodes, null); }