@Test public void testConfigFileContainsSingleNode_noMatchesForSpecifiedNodeName() { Node node1 = Testing.newTestNode("node1", "localhost"); Cluster cluster = Testing.newTestCluster(new Stripe().addNodes(node1)); assertThat( () -> STARTUP_MANAGER.getMatchingNodeFromConfigFileUsingNodeName("blah", CONFIG_FILE, cluster), is(throwing(instanceOf(IllegalArgumentException.class)).andMessage(containsString("Did not find a matching node entry in config file"))) ); }
Node getMatchingNodeFromConfigFileUsingNodeName(String specifiedNodeName, String configFilePath, Cluster cluster) { requireNonNull(configFilePath); requireNonNull(specifiedNodeName); Collection<Node> allNodes = cluster.getNodes(); List<Node> matchingNodes = allNodes.stream() .filter(node -> node.getName().equals(specifiedNodeName)) .collect(Collectors.toList()); HashMap<String, String> logParams = new HashMap<>(); logParams.put(NODE_NAME, specifiedNodeName); if (matchingNodes.size() == 1) { server.console(log("Found matching node entry", configFilePath, logParams)); return matchingNodes.get(0); } else if (matchingNodes.size() > 1) { throw new IllegalArgumentException(log("Found multiple matching node entries", configFilePath, logParams)); } else { throw new IllegalArgumentException(log("Did not find a matching node entry", configFilePath, logParams)); } }
ConfigurationGeneratorVisitor { Node getMatchingNodeFromConfigFileUsingNodeName(String specifiedNodeName, String configFilePath, Cluster cluster) { requireNonNull(configFilePath); requireNonNull(specifiedNodeName); Collection<Node> allNodes = cluster.getNodes(); List<Node> matchingNodes = allNodes.stream() .filter(node -> node.getName().equals(specifiedNodeName)) .collect(Collectors.toList()); HashMap<String, String> logParams = new HashMap<>(); logParams.put(NODE_NAME, specifiedNodeName); if (matchingNodes.size() == 1) { server.console(log("Found matching node entry", configFilePath, logParams)); return matchingNodes.get(0); } else if (matchingNodes.size() > 1) { throw new IllegalArgumentException(log("Found multiple matching node entries", configFilePath, logParams)); } else { throw new IllegalArgumentException(log("Did not find a matching node entry", configFilePath, logParams)); } } }
ConfigurationGeneratorVisitor { Node getMatchingNodeFromConfigFileUsingNodeName(String specifiedNodeName, String configFilePath, Cluster cluster) { requireNonNull(configFilePath); requireNonNull(specifiedNodeName); Collection<Node> allNodes = cluster.getNodes(); List<Node> matchingNodes = allNodes.stream() .filter(node -> node.getName().equals(specifiedNodeName)) .collect(Collectors.toList()); HashMap<String, String> logParams = new HashMap<>(); logParams.put(NODE_NAME, specifiedNodeName); if (matchingNodes.size() == 1) { server.console(log("Found matching node entry", configFilePath, logParams)); return matchingNodes.get(0); } else if (matchingNodes.size() > 1) { throw new IllegalArgumentException(log("Found multiple matching node entries", configFilePath, logParams)); } else { throw new IllegalArgumentException(log("Did not find a matching node entry", configFilePath, logParams)); } } ConfigurationGeneratorVisitor(IParameterSubstitutor parameterSubstitutor,
                                       NomadServerManager nomadServerManager,
                                       ClassLoader classLoader,
                                       PathResolver pathResolver,
                                       ObjectMapperFactory objectMapperFactory,
                                       Server server); }
ConfigurationGeneratorVisitor { Node getMatchingNodeFromConfigFileUsingNodeName(String specifiedNodeName, String configFilePath, Cluster cluster) { requireNonNull(configFilePath); requireNonNull(specifiedNodeName); Collection<Node> allNodes = cluster.getNodes(); List<Node> matchingNodes = allNodes.stream() .filter(node -> node.getName().equals(specifiedNodeName)) .collect(Collectors.toList()); HashMap<String, String> logParams = new HashMap<>(); logParams.put(NODE_NAME, specifiedNodeName); if (matchingNodes.size() == 1) { server.console(log("Found matching node entry", configFilePath, logParams)); return matchingNodes.get(0); } else if (matchingNodes.size() > 1) { throw new IllegalArgumentException(log("Found multiple matching node entries", configFilePath, logParams)); } else { throw new IllegalArgumentException(log("Did not find a matching node entry", configFilePath, logParams)); } } ConfigurationGeneratorVisitor(IParameterSubstitutor parameterSubstitutor,
                                       NomadServerManager nomadServerManager,
                                       ClassLoader classLoader,
                                       PathResolver pathResolver,
                                       ObjectMapperFactory objectMapperFactory,
                                       Server server); boolean isUnConfiguredMode(); boolean isRepairMode(); StartupConfiguration generateConfiguration(); }
ConfigurationGeneratorVisitor { Node getMatchingNodeFromConfigFileUsingNodeName(String specifiedNodeName, String configFilePath, Cluster cluster) { requireNonNull(configFilePath); requireNonNull(specifiedNodeName); Collection<Node> allNodes = cluster.getNodes(); List<Node> matchingNodes = allNodes.stream() .filter(node -> node.getName().equals(specifiedNodeName)) .collect(Collectors.toList()); HashMap<String, String> logParams = new HashMap<>(); logParams.put(NODE_NAME, specifiedNodeName); if (matchingNodes.size() == 1) { server.console(log("Found matching node entry", configFilePath, logParams)); return matchingNodes.get(0); } else if (matchingNodes.size() > 1) { throw new IllegalArgumentException(log("Found multiple matching node entries", configFilePath, logParams)); } else { throw new IllegalArgumentException(log("Did not find a matching node entry", configFilePath, logParams)); } } ConfigurationGeneratorVisitor(IParameterSubstitutor parameterSubstitutor,
                                       NomadServerManager nomadServerManager,
                                       ClassLoader classLoader,
                                       PathResolver pathResolver,
                                       ObjectMapperFactory objectMapperFactory,
                                       Server server); boolean isUnConfiguredMode(); boolean isRepairMode(); StartupConfiguration generateConfiguration();  }