@Test public void onlyWritesConfigsForRunningContainers() { List<LogstashConfig> frameworks = asFrameworkInfoList(framework1, framework2, framework3); List<LogstashConfig> hostFrameworks = asFrameworkInfoList(framework4); configureAsRunningFrameworks(framework1, framework2, framework3); String generateConfigFile = ConfigUtil.generateConfigFile(client, frameworks, hostFrameworks); Assert.assertTrue(generateConfigFile.contains(String.format("# %s\n%s\n",framework1.frameworkInfo.getFrameworkName(), framework1.frameworkInfo.getConfig()))); Assert.assertTrue(generateConfigFile.contains(String.format("# %s\n%s\n",framework2.frameworkInfo.getFrameworkName(), framework2.frameworkInfo.getConfig()))); Assert.assertTrue(generateConfigFile.contains(String.format("# %s\n%s\n",framework3.frameworkInfo.getFrameworkName(), framework3.frameworkInfo.getConfig()))); }
public static String generateConfigFile(ContainerizerClient client, List<LogstashConfig> dockerInfo, List<LogstashConfig> hostInfo) { final StringBuilder text = new StringBuilder(); Map<String, LogstashConfig> dockerConfigs = dockerInfo.stream().collect( toMap(LogstashConfig::getFrameworkName, x -> x)); client.getRunningContainers().forEach(containerId -> { String name = client.getImageNameOfContainer(containerId); if (dockerConfigs.containsKey(name)) { LogstashConfig info = dockerConfigs.get(name); DockerFramework framework = new DockerFramework(info, new DockerFramework.ContainerId(containerId)); text.append(framework.getConfiguration()).append("\n"); } }); hostInfo.forEach(config -> { text.append(String.format("# %s\n%s\n", config.getFrameworkName(), config.getConfig())); }); return text.toString(); }
ConfigUtil { public static String generateConfigFile(ContainerizerClient client, List<LogstashConfig> dockerInfo, List<LogstashConfig> hostInfo) { final StringBuilder text = new StringBuilder(); Map<String, LogstashConfig> dockerConfigs = dockerInfo.stream().collect( toMap(LogstashConfig::getFrameworkName, x -> x)); client.getRunningContainers().forEach(containerId -> { String name = client.getImageNameOfContainer(containerId); if (dockerConfigs.containsKey(name)) { LogstashConfig info = dockerConfigs.get(name); DockerFramework framework = new DockerFramework(info, new DockerFramework.ContainerId(containerId)); text.append(framework.getConfiguration()).append("\n"); } }); hostInfo.forEach(config -> { text.append(String.format("# %s\n%s\n", config.getFrameworkName(), config.getConfig())); }); return text.toString(); } }
ConfigUtil { public static String generateConfigFile(ContainerizerClient client, List<LogstashConfig> dockerInfo, List<LogstashConfig> hostInfo) { final StringBuilder text = new StringBuilder(); Map<String, LogstashConfig> dockerConfigs = dockerInfo.stream().collect( toMap(LogstashConfig::getFrameworkName, x -> x)); client.getRunningContainers().forEach(containerId -> { String name = client.getImageNameOfContainer(containerId); if (dockerConfigs.containsKey(name)) { LogstashConfig info = dockerConfigs.get(name); DockerFramework framework = new DockerFramework(info, new DockerFramework.ContainerId(containerId)); text.append(framework.getConfiguration()).append("\n"); } }); hostInfo.forEach(config -> { text.append(String.format("# %s\n%s\n", config.getFrameworkName(), config.getConfig())); }); return text.toString(); } protected  ConfigUtil(); }
ConfigUtil { public static String generateConfigFile(ContainerizerClient client, List<LogstashConfig> dockerInfo, List<LogstashConfig> hostInfo) { final StringBuilder text = new StringBuilder(); Map<String, LogstashConfig> dockerConfigs = dockerInfo.stream().collect( toMap(LogstashConfig::getFrameworkName, x -> x)); client.getRunningContainers().forEach(containerId -> { String name = client.getImageNameOfContainer(containerId); if (dockerConfigs.containsKey(name)) { LogstashConfig info = dockerConfigs.get(name); DockerFramework framework = new DockerFramework(info, new DockerFramework.ContainerId(containerId)); text.append(framework.getConfiguration()).append("\n"); } }); hostInfo.forEach(config -> { text.append(String.format("# %s\n%s\n", config.getFrameworkName(), config.getConfig())); }); return text.toString(); } protected  ConfigUtil(); static String generateConfigFile(ContainerizerClient client,
        List<LogstashConfig> dockerInfo, List<LogstashConfig> hostInfo); }
ConfigUtil { public static String generateConfigFile(ContainerizerClient client, List<LogstashConfig> dockerInfo, List<LogstashConfig> hostInfo) { final StringBuilder text = new StringBuilder(); Map<String, LogstashConfig> dockerConfigs = dockerInfo.stream().collect( toMap(LogstashConfig::getFrameworkName, x -> x)); client.getRunningContainers().forEach(containerId -> { String name = client.getImageNameOfContainer(containerId); if (dockerConfigs.containsKey(name)) { LogstashConfig info = dockerConfigs.get(name); DockerFramework framework = new DockerFramework(info, new DockerFramework.ContainerId(containerId)); text.append(framework.getConfiguration()).append("\n"); } }); hostInfo.forEach(config -> { text.append(String.format("# %s\n%s\n", config.getFrameworkName(), config.getConfig())); }); return text.toString(); } protected  ConfigUtil(); static String generateConfigFile(ContainerizerClient client,
        List<LogstashConfig> dockerInfo, List<LogstashConfig> hostInfo);  }