@Test public void collectMissingNodesWhenAllNodeAndSaltNodeWithPostfix() { setupTargetWithPostfix(); Set<Node> allNode = allNodeWithPostFix(); baseSaltJobRunner = new BaseSaltJobRunner(targetHostnames, allNode) { @Override public String submit(SaltConnector saltConnector) { return ""; } }; Set<String> returnedNodes = new HashSet<>(); returnedNodes.add("host-10-0-0-1.example.com"); returnedNodes.add("host-10-0-0-2.example.com"); Set<String> collectedMissingNodes = baseSaltJobRunner.collectMissingHostnames(returnedNodes); Assert.assertEquals(1L, collectedMissingNodes.size()); Assert.assertEquals("host-10-0-0-3.example.com", collectedMissingNodes.iterator().next()); }
public Set<String> collectMissingHostnames(Collection<String> succeededHostnames) { Map<String, String> shortHostnameToHostnameMap = allNode.stream().collect(Collectors.toMap(node -> getShortHostName(node.getHostname()), Node::getHostname)); Set<String> resolvedSucceededHostnames = succeededHostnames.stream().map(hostname -> shortHostnameToHostnameMap.get(getShortHostName(hostname))).collect(Collectors.toSet()); return targetHostnames.stream().filter(t -> !resolvedSucceededHostnames.contains(t)).collect(Collectors.toSet()); }
BaseSaltJobRunner implements SaltJobRunner { public Set<String> collectMissingHostnames(Collection<String> succeededHostnames) { Map<String, String> shortHostnameToHostnameMap = allNode.stream().collect(Collectors.toMap(node -> getShortHostName(node.getHostname()), Node::getHostname)); Set<String> resolvedSucceededHostnames = succeededHostnames.stream().map(hostname -> shortHostnameToHostnameMap.get(getShortHostName(hostname))).collect(Collectors.toSet()); return targetHostnames.stream().filter(t -> !resolvedSucceededHostnames.contains(t)).collect(Collectors.toSet()); } }
BaseSaltJobRunner implements SaltJobRunner { public Set<String> collectMissingHostnames(Collection<String> succeededHostnames) { Map<String, String> shortHostnameToHostnameMap = allNode.stream().collect(Collectors.toMap(node -> getShortHostName(node.getHostname()), Node::getHostname)); Set<String> resolvedSucceededHostnames = succeededHostnames.stream().map(hostname -> shortHostnameToHostnameMap.get(getShortHostName(hostname))).collect(Collectors.toSet()); return targetHostnames.stream().filter(t -> !resolvedSucceededHostnames.contains(t)).collect(Collectors.toSet()); } protected  BaseSaltJobRunner(Set<String> targetHostnames, Set<Node> allNode); }
BaseSaltJobRunner implements SaltJobRunner { public Set<String> collectMissingHostnames(Collection<String> succeededHostnames) { Map<String, String> shortHostnameToHostnameMap = allNode.stream().collect(Collectors.toMap(node -> getShortHostName(node.getHostname()), Node::getHostname)); Set<String> resolvedSucceededHostnames = succeededHostnames.stream().map(hostname -> shortHostnameToHostnameMap.get(getShortHostName(hostname))).collect(Collectors.toSet()); return targetHostnames.stream().filter(t -> !resolvedSucceededHostnames.contains(t)).collect(Collectors.toSet()); } protected  BaseSaltJobRunner(Set<String> targetHostnames, Set<Node> allNode); @Override Set<String> getTargetHostnames(); @Override void setTargetHostnames(Set<String> targetHostnames); @Override JobId getJid(); @Override void setJid(JobId jid); @Override JobState getJobState(); @Override void setJobState(JobState jobState); @Override Multimap<String, String> getNodesWithError(); @Override void setNodesWithError(Multimap<String, String> nodesWithError); @Override StateType stateType(); Set<String> collectSucceededNodes(ApplyResponse applyResponse); Set<String> collectMissingHostnames(Collection<String> succeededHostnames); Set<Node> getAllNode(); @Override String toString(); }
BaseSaltJobRunner implements SaltJobRunner { public Set<String> collectMissingHostnames(Collection<String> succeededHostnames) { Map<String, String> shortHostnameToHostnameMap = allNode.stream().collect(Collectors.toMap(node -> getShortHostName(node.getHostname()), Node::getHostname)); Set<String> resolvedSucceededHostnames = succeededHostnames.stream().map(hostname -> shortHostnameToHostnameMap.get(getShortHostName(hostname))).collect(Collectors.toSet()); return targetHostnames.stream().filter(t -> !resolvedSucceededHostnames.contains(t)).collect(Collectors.toSet()); } protected  BaseSaltJobRunner(Set<String> targetHostnames, Set<Node> allNode); @Override Set<String> getTargetHostnames(); @Override void setTargetHostnames(Set<String> targetHostnames); @Override JobId getJid(); @Override void setJid(JobId jid); @Override JobState getJobState(); @Override void setJobState(JobState jobState); @Override Multimap<String, String> getNodesWithError(); @Override void setNodesWithError(Multimap<String, String> nodesWithError); @Override StateType stateType(); Set<String> collectSucceededNodes(ApplyResponse applyResponse); Set<String> collectMissingHostnames(Collection<String> succeededHostnames); Set<Node> getAllNode(); @Override String toString();  }