diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2017-08-28 15:47:36 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2017-08-28 15:47:36 +0200 |
commit | 1701fa777723c1a7d55c7149d0a25429a5596a35 (patch) | |
tree | ca744569d77b6c6d49548e7f5ee300cbefbb0fc2 | |
parent | 8c50c885d8f3efb07e10dd585976004ba44cdbbe (diff) |
ProvisionInfo -> AllocatedHosts
8 files changed, 115 insertions, 113 deletions
diff --git a/config-provisioning/src/test/java/com/yahoo/config/provision/AllocatedHostsTest.java b/config-provisioning/src/test/java/com/yahoo/config/provision/AllocatedHostsTest.java index 54ce90d76fc..675af88596a 100644 --- a/config-provisioning/src/test/java/com/yahoo/config/provision/AllocatedHostsTest.java +++ b/config-provisioning/src/test/java/com/yahoo/config/provision/AllocatedHostsTest.java @@ -21,24 +21,25 @@ public class AllocatedHostsTest { private final HostSpec h3 = new HostSpec("host3", Optional.of(ClusterMembership.from("container/test/0", com.yahoo.component.Version.fromString("6.73.1")))); @Test - public void testProvisionInfoSerialization() throws IOException { + public void testAllocatedHostsSerialization() throws IOException { Set<HostSpec> hosts = new LinkedHashSet<>(); hosts.add(h1); hosts.add(h2); hosts.add(h3); AllocatedHosts info = AllocatedHosts.withHosts(hosts); - assertProvisionInfo(info); + assertAllocatedHosts(info); } - private void assertProvisionInfo(AllocatedHosts info) throws IOException { - AllocatedHosts serializedInfo = AllocatedHosts.fromJson(info.toJson(), Optional.empty()); - assertEquals(info.getHosts().size(), serializedInfo.getHosts().size()); - assertTrue(serializedInfo.getHosts().contains(h1)); - assertTrue(serializedInfo.getHosts().contains(h2)); - assertTrue(serializedInfo.getHosts().contains(h3)); - assertTrue(!getHost(h1.hostname(), serializedInfo.getHosts()).membership().isPresent()); - assertEquals("container/test/0", getHost(h3.hostname(), serializedInfo.getHosts()).membership().get().stringValue()); - assertEquals(h3.membership().get().cluster().vespaVersion(), getHost(h3.hostname(), serializedInfo.getHosts()).membership().get().cluster().vespaVersion()); + private void assertAllocatedHosts(AllocatedHosts info) throws IOException { + AllocatedHosts serializedAllocatedHosts = AllocatedHosts.fromJson(info.toJson(), Optional.empty()); + assertEquals(info.getHosts().size(), serializedAllocatedHosts.getHosts().size()); + assertTrue(serializedAllocatedHosts.getHosts().contains(h1)); + assertTrue(serializedAllocatedHosts.getHosts().contains(h2)); + assertTrue(serializedAllocatedHosts.getHosts().contains(h3)); + assertTrue(!getHost(h1.hostname(), serializedAllocatedHosts.getHosts()).membership().isPresent()); + assertEquals("container/test/0", getHost(h3.hostname(), serializedAllocatedHosts.getHosts()).membership().get().stringValue()); + assertEquals(h3.membership().get().cluster().vespaVersion(), getHost(h3.hostname(), + serializedAllocatedHosts.getHosts()).membership().get().cluster().vespaVersion()); } private HostSpec getHost(String hostname, Set<HostSpec> hosts) { diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClient.java b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClient.java index 0071ad6ca51..69266620e45 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClient.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClient.java @@ -30,7 +30,7 @@ public class ZooKeeperClient { private final ConfigCurator configCurator; private final DeployLogger logger; - private final boolean trace; + private final boolean logFine; /* This is the generation that will be used for reading and writing application data. (1 more than last deployed application) */ private final Path rootPath; @@ -41,10 +41,10 @@ public class ZooKeeperClient { } }; - public ZooKeeperClient(ConfigCurator configCurator, DeployLogger logger, boolean trace, Path rootPath) { + public ZooKeeperClient(ConfigCurator configCurator, DeployLogger logger, boolean logFine, Path rootPath) { this.configCurator = configCurator; this.logger = logger; - this.trace = trace; + this.logFine = logFine; this.rootPath = rootPath; } @@ -61,7 +61,7 @@ public class ZooKeeperClient { try { while (retries > 0) { try { - trace("Setting up ZooKeeper nodes for this application"); + logFine("Setting up ZooKeeper nodes for this application"); createZooKeeperNodes(); break; } catch (RuntimeException e) { @@ -104,28 +104,28 @@ public class ZooKeeperClient { * * @param app the application package to feed to zookeeper */ - void feedZooKeeper(ApplicationPackage app) { - trace("Feeding application config into ZooKeeper"); + void write(ApplicationPackage app) { + logFine("Feeding application config into ZooKeeper"); // gives lots and lots of debug output: // BasicConfigurator.configure(); try { - trace("zk operations: " + configCurator.getNumberOfOperations()); - trace("zk operations: " + configCurator.getNumberOfOperations()); - trace("Feeding user def files into ZooKeeper"); - feedZKUserDefs(app); - trace("zk operations: " + configCurator.getNumberOfOperations()); - trace("Feeding application package into ZooKeeper"); + logFine("zk operations: " + configCurator.getNumberOfOperations()); + logFine("zk operations: " + configCurator.getNumberOfOperations()); + logFine("Feeding user def files into ZooKeeper"); + writeUserDefs(app); + logFine("zk operations: " + configCurator.getNumberOfOperations()); + logFine("Feeding application package into ZooKeeper"); // TODO 1200 zk operations done in the below method - feedZKAppPkg(app); - feedSearchDefinitions(app); - feedZKUserIncludeDirs(app, app.getUserIncludeDirs()); - trace("zk operations: " + configCurator.getNumberOfOperations()); - trace("zk read operations: " + configCurator.getNumberOfReadOperations()); - trace("zk write operations: " + configCurator.getNumberOfWriteOperations()); - trace("Feeding sd from docproc bundle into ZooKeeper"); - trace("zk operations: " + configCurator.getNumberOfOperations()); - trace("Write application metadata into ZooKeeper"); - feedZKAppMetaData(app.getMetaData()); - trace("zk operations: " + configCurator.getNumberOfOperations()); + writeSomeOf(app); + writeSearchDefinitions(app); + writeUserIncludeDirs(app, app.getUserIncludeDirs()); + logFine("zk operations: " + configCurator.getNumberOfOperations()); + logFine("zk read operations: " + configCurator.getNumberOfReadOperations()); + logFine("zk write operations: " + configCurator.getNumberOfWriteOperations()); + logFine("Feeding sd from docproc bundle into ZooKeeper"); + logFine("zk operations: " + configCurator.getNumberOfOperations()); + logFine("Write application metadata into ZooKeeper"); + write(app.getMetaData()); + logFine("zk operations: " + configCurator.getNumberOfOperations()); } catch (Exception e) { throw new IllegalStateException("Unable to write vespa model to config server(s) " + System.getProperty("configsources") + "\n" + "Please ensure that cloudconfig_server is started on the config server node(s), " + @@ -133,7 +133,7 @@ public class ZooKeeperClient { } } - private void feedSearchDefinitions(ApplicationPackage app) throws IOException { + private void writeSearchDefinitions(ApplicationPackage app) throws IOException { Collection<NamedReader> sds = app.getSearchDefinitions(); if (sds.isEmpty()) { return; @@ -141,7 +141,7 @@ public class ZooKeeperClient { Path zkPath = getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH).append(ApplicationPackage.SEARCH_DEFINITIONS_DIR); configCurator.createNode(zkPath.getAbsolute()); // Ensures that ranking expressions and other files are also fed. - feedDirZooKeeper(app.getFile(ApplicationPackage.SEARCH_DEFINITIONS_DIR), zkPath, false); + writeDir(app.getFile(ApplicationPackage.SEARCH_DEFINITIONS_DIR), zkPath, false); for (NamedReader sd : sds) { String name = sd.getName(); Reader reader = sd.getReader(); @@ -152,12 +152,12 @@ public class ZooKeeperClient { } /** - * Puts the application package files into ZK + * Puts some of the application package files into ZK - see write(app). * * @param app The application package to use as input. * @throws java.io.IOException if not able to write to Zookeeper */ - void feedZKAppPkg(ApplicationPackage app) throws IOException { + void writeSomeOf(ApplicationPackage app) throws IOException { ApplicationFile.PathFilter srFilter = new ApplicationFile.PathFilter() { @Override public boolean accept(Path path) { @@ -166,40 +166,40 @@ public class ZooKeeperClient { }; // Copy app package files and subdirs into zk // TODO: We should have a way of doing this which doesn't require repeating all the content - feedFileZooKeeper(app.getFile(Path.fromString(ApplicationPackage.SERVICES)), - getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH)); - feedFileZooKeeper(app.getFile(Path.fromString(ApplicationPackage.HOSTS)), - getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH)); - feedFileZooKeeper(app.getFile(Path.fromString(ApplicationPackage.DEPLOYMENT_FILE.getName())), - getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH)); - feedFileZooKeeper(app.getFile(Path.fromString(ApplicationPackage.VALIDATION_OVERRIDES.getName())), - getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH)); + writeFile(app.getFile(Path.fromString(ApplicationPackage.SERVICES)), + getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH)); + writeFile(app.getFile(Path.fromString(ApplicationPackage.HOSTS)), + getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH)); + writeFile(app.getFile(Path.fromString(ApplicationPackage.DEPLOYMENT_FILE.getName())), + getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH)); + writeFile(app.getFile(Path.fromString(ApplicationPackage.VALIDATION_OVERRIDES.getName())), + getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH)); - feedDirZooKeeper(app.getFile(Path.fromString(ApplicationPackage.TEMPLATES_DIR)), - getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH), - true); - feedDirZooKeeper(app.getFile(ApplicationPackage.RULES_DIR), - getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH).append(ApplicationPackage.RULES_DIR), - srFilter, true); - feedDirZooKeeper(app.getFile(ApplicationPackage.QUERY_PROFILES_DIR), - getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH).append(ApplicationPackage.QUERY_PROFILES_DIR), - xmlFilter, true); - feedDirZooKeeper(app.getFile(ApplicationPackage.PAGE_TEMPLATES_DIR), - getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH).append(ApplicationPackage.PAGE_TEMPLATES_DIR), - xmlFilter, true); - feedDirZooKeeper(app.getFile(Path.fromString(ApplicationPackage.SEARCHCHAINS_DIR)), - getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH).append(ApplicationPackage.SEARCHCHAINS_DIR), - xmlFilter, true); - feedDirZooKeeper(app.getFile(Path.fromString(ApplicationPackage.DOCPROCCHAINS_DIR)), - getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH).append(ApplicationPackage.DOCPROCCHAINS_DIR), - xmlFilter, true); - feedDirZooKeeper(app.getFile(Path.fromString(ApplicationPackage.ROUTINGTABLES_DIR)), - getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH).append(ApplicationPackage.ROUTINGTABLES_DIR), - xmlFilter, true); + writeDir(app.getFile(Path.fromString(ApplicationPackage.TEMPLATES_DIR)), + getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH), + true); + writeDir(app.getFile(ApplicationPackage.RULES_DIR), + getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH).append(ApplicationPackage.RULES_DIR), + srFilter, true); + writeDir(app.getFile(ApplicationPackage.QUERY_PROFILES_DIR), + getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH).append(ApplicationPackage.QUERY_PROFILES_DIR), + xmlFilter, true); + writeDir(app.getFile(ApplicationPackage.PAGE_TEMPLATES_DIR), + getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH).append(ApplicationPackage.PAGE_TEMPLATES_DIR), + xmlFilter, true); + writeDir(app.getFile(Path.fromString(ApplicationPackage.SEARCHCHAINS_DIR)), + getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH).append(ApplicationPackage.SEARCHCHAINS_DIR), + xmlFilter, true); + writeDir(app.getFile(Path.fromString(ApplicationPackage.DOCPROCCHAINS_DIR)), + getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH).append(ApplicationPackage.DOCPROCCHAINS_DIR), + xmlFilter, true); + writeDir(app.getFile(Path.fromString(ApplicationPackage.ROUTINGTABLES_DIR)), + getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH).append(ApplicationPackage.ROUTINGTABLES_DIR), + xmlFilter, true); } - private void feedDirZooKeeper(ApplicationFile file, Path zooKeeperAppPath, boolean recurse) throws IOException { - feedDirZooKeeper(file, zooKeeperAppPath, new ApplicationFile.PathFilter() { + private void writeDir(ApplicationFile file, Path zooKeeperAppPath, boolean recurse) throws IOException { + writeDir(file, zooKeeperAppPath, new ApplicationFile.PathFilter() { @Override public boolean accept(Path path) { return true; @@ -207,7 +207,7 @@ public class ZooKeeperClient { }, recurse); } - private void feedDirZooKeeper(ApplicationFile dir, Path path, ApplicationFile.PathFilter filenameFilter, boolean recurse) throws IOException { + private void writeDir(ApplicationFile dir, Path path, ApplicationFile.PathFilter filenameFilter, boolean recurse) throws IOException { if (!dir.isDirectory()) { logger.log(LogLevel.FINE, dir.getPath().getAbsolute()+" is not a directory. Not feeding the files into ZooKeeper."); return; @@ -219,10 +219,10 @@ public class ZooKeeperClient { if (file.isDirectory()) { configCurator.createNode(path.append(name).getAbsolute()); if (recurse) { - feedDirZooKeeper(file, path.append(name), filenameFilter, recurse); + writeDir(file, path.append(name), filenameFilter, recurse); } } else { - feedFileZooKeeper(file, path); + writeFile(file, path); } } } @@ -247,7 +247,7 @@ public class ZooKeeperClient { return ret; } - private void feedFileZooKeeper(ApplicationFile file, Path zkPath) throws IOException { + private void writeFile(ApplicationFile file, Path zkPath) throws IOException { if (!file.exists()) { return; } @@ -259,7 +259,7 @@ public class ZooKeeperClient { } } - private void feedZKUserIncludeDirs(ApplicationPackage applicationPackage, List<String> userIncludeDirs) throws IOException { + private void writeUserIncludeDirs(ApplicationPackage applicationPackage, List<String> userIncludeDirs) throws IOException { // User defined include directories for (String userInclude : userIncludeDirs) { ApplicationFile dir = applicationPackage.getFile(Path.fromString(userInclude)); @@ -267,9 +267,9 @@ public class ZooKeeperClient { if (files == null || files.isEmpty()) { configCurator.createNode(getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH + "/" + userInclude).getAbsolute()); } - feedDirZooKeeper(dir, - getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH + "/" + userInclude), - xmlFilter, true); + writeDir(dir, + getZooKeeperAppPath(ConfigCurator.USERAPP_ZK_SUBPATH + "/" + userInclude), + xmlFilter, true); } } @@ -277,22 +277,22 @@ public class ZooKeeperClient { * Feeds all user-defined .def file from the application package into ZooKeeper (both into * /defconfigs and /userdefconfigs */ - private void feedZKUserDefs(ApplicationPackage applicationPackage) { + private void writeUserDefs(ApplicationPackage applicationPackage) { Map<ConfigDefinitionKey, UnparsedConfigDefinition> configDefs = applicationPackage.getAllExistingConfigDefs(); for (Map.Entry<ConfigDefinitionKey, UnparsedConfigDefinition> entry : configDefs.entrySet()) { ConfigDefinitionKey key = entry.getKey(); String contents = entry.getValue().getUnparsedContent(); - feedDefToZookeeper(key.getName(), key.getNamespace(), getZooKeeperAppPath(ConfigCurator.USER_DEFCONFIGS_ZK_SUBPATH).getAbsolute(), contents); - feedDefToZookeeper(key.getName(), key.getNamespace(), getZooKeeperAppPath(ConfigCurator.DEFCONFIGS_ZK_SUBPATH).getAbsolute(), contents); + write(key.getName(), key.getNamespace(), getZooKeeperAppPath(ConfigCurator.USER_DEFCONFIGS_ZK_SUBPATH).getAbsolute(), contents); + write(key.getName(), key.getNamespace(), getZooKeeperAppPath(ConfigCurator.DEFCONFIGS_ZK_SUBPATH).getAbsolute(), contents); } logger.log(LogLevel.FINE, configDefs.size() + " user config definitions"); } - private void feedDefToZookeeper(String name, String namespace, String path, String data) { - feedDefToZookeeper(name, namespace, "", path, com.yahoo.text.Utf8.toBytes(data)); + private void write(String name, String namespace, String path, String data) { + write(name, namespace, "", path, com.yahoo.text.Utf8.toBytes(data)); } - private void feedDefToZookeeper(String name, String namespace, String version, String path, byte[] data) { + private void write(String name, String namespace, String version, String path, byte[] data) { configCurator.putDefData( ("".equals(namespace)) ? name : (namespace + "." + name), version, @@ -300,8 +300,8 @@ public class ZooKeeperClient { data); } - private void feedZKFileRegistry(Version vespaVersion, FileRegistry fileRegistry) { - trace("Feeding file registry data into ZooKeeper"); + private void write(Version vespaVersion, FileRegistry fileRegistry) { + logFine("Feeding file registry data into ZooKeeper"); String exportedRegistry = PreGeneratedFileRegistry.exportRegistry(fileRegistry); configCurator.putData(getZooKeeperAppPath(null).append(ZKApplicationPackage.fileRegistryNode).getAbsolute(), @@ -315,12 +315,12 @@ public class ZooKeeperClient { * * @param metaData The application metadata. */ - private void feedZKAppMetaData(ApplicationMetaData metaData) { + private void write(ApplicationMetaData metaData) { configCurator.putData(getZooKeeperAppPath(ConfigCurator.META_ZK_PATH).getAbsolute(), metaData.asJsonString()); } void cleanupZooKeeper() { - trace("Exception occurred. Cleaning up ZooKeeper"); + logFine("Exception occurred. Cleaning up ZooKeeper"); try { for (String subPath : Arrays.asList( ConfigCurator.DEFCONFIGS_ZK_SUBPATH, @@ -349,19 +349,19 @@ public class ZooKeeperClient { } } - void trace(String msg) { - if (trace) { + void logFine(String msg) { + if (logFine) { logger.log(LogLevel.FINE, msg); } } - public void feedProvisionInfo(AllocatedHosts info) throws IOException { + public void write(AllocatedHosts info) throws IOException { configCurator.putData(rootPath.append(ZKApplicationPackage.allocatedHostsNode).getAbsolute(), info.toJson()); } - public void feedZKFileRegistries(Map<Version, FileRegistry> fileRegistryMap) { + public void write(Map<Version, FileRegistry> fileRegistryMap) { for (Map.Entry<Version, FileRegistry> versionFileRegistryEntry : fileRegistryMap.entrySet()) { - feedZKFileRegistry(versionFileRegistryEntry.getKey(), versionFileRegistryEntry.getValue()); + write(versionFileRegistryEntry.getKey(), versionFileRegistryEntry.getValue()); } } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ZooKeeperDeployer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ZooKeeperDeployer.java index 1b212e4fd5c..22ce952481d 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ZooKeeperDeployer.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ZooKeeperDeployer.java @@ -34,9 +34,9 @@ public class ZooKeeperDeployer { public void deploy(ApplicationPackage applicationPackage, Map<Version, FileRegistry> fileRegistryMap, AllocatedHosts allocatedHosts) throws IOException { zooKeeperClient.setupZooKeeper(); - zooKeeperClient.feedZooKeeper(applicationPackage); - zooKeeperClient.feedZKFileRegistries(fileRegistryMap); - zooKeeperClient.feedProvisionInfo(allocatedHosts); + zooKeeperClient.write(applicationPackage); + zooKeeperClient.write(fileRegistryMap); + zooKeeperClient.write(allocatedHosts); } public void cleanup() { diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackage.java b/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackage.java index 0e7eee71b65..05c301ddba8 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackage.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackage.java @@ -63,15 +63,16 @@ public class ZKApplicationPackage implements ApplicationPackage { if ( ! liveApp.exists(allocatedHostsPath)) return Optional.empty(); Optional<AllocatedHosts> allocatedHosts = readAllocatedHosts(allocatedHostsPath, nodeFlavors); if ( ! allocatedHosts.isPresent()) { // Read from legacy location. TODO: Remove when 6.143 is in production everywhere - List<String> provisionInfoByVersionNodes = liveApp.getChildren(allocatedHostsPath); - allocatedHosts = merge(readAllocatedHostsByVersion(provisionInfoByVersionNodes, nodeFlavors)); + List<String> allocatedHostsByVersionNodes = liveApp.getChildren(allocatedHostsPath); + allocatedHosts = merge(readAllocatedHostsByVersion(allocatedHostsByVersionNodes, nodeFlavors)); } return allocatedHosts; } - private Map<Version, AllocatedHosts> readAllocatedHostsByVersion(List<String> provisionInfoByVersionNodes, Optional<NodeFlavors> nodeFlavors) { + private Map<Version, AllocatedHosts> readAllocatedHostsByVersion(List<String> allocatedHostsByVersionNodes, + Optional<NodeFlavors> nodeFlavors) { Map<Version, AllocatedHosts> allocatedHostsByVersion = new HashMap<>(); - provisionInfoByVersionNodes.stream() + allocatedHostsByVersionNodes.stream() .forEach(versionStr -> { Version version = Version.fromString(versionStr); Optional<AllocatedHosts> allocatedHosts = readAllocatedHosts(Joiner.on("/").join(allocatedHostsNode, versionStr), @@ -81,12 +82,12 @@ public class ZKApplicationPackage implements ApplicationPackage { return allocatedHostsByVersion; } - private Optional<AllocatedHosts> merge(Map<Version, AllocatedHosts> provisionInfoMap) { - // Merge the provision infos in any order. This is wrong but preserves current behavior (modulo order differences) - if (provisionInfoMap.isEmpty()) return Optional.empty(); + private Optional<AllocatedHosts> merge(Map<Version, AllocatedHosts> allocatedHostsByVersion) { + // Merge the allocated hosts in any order. This is wrong but preserves current behavior (modulo order differences) + if (allocatedHostsByVersion.isEmpty()) return Optional.empty(); Map<String, HostSpec> merged = new HashMap<>(); - for (Map.Entry<Version, AllocatedHosts> entry : provisionInfoMap.entrySet()) { + for (Map.Entry<Version, AllocatedHosts> entry : allocatedHostsByVersion.entrySet()) { for (HostSpec host : entry.getValue().getHosts()) merged.put(host.hostname(), host); } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java index 44a39b5d4b4..301ae63fb8c 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java @@ -110,17 +110,17 @@ public class HostedDeployTest { final String vespaVersion = "6.51.1"; DeployTester tester = new DeployTester("src/test/apps/hosted/", createConfigserverConfig()); ApplicationId applicationId = tester.deployApp("myApp", vespaVersion, Instant.now()); - assertProvisionInfo(vespaVersion, tester, applicationId); + assertAllocatedHosts(vespaVersion, tester, applicationId); System.out.println("Redeploy"); Optional<com.yahoo.config.provision.Deployment> deployment = tester.redeployFromLocalActive(); assertTrue(deployment.isPresent()); deployment.get().prepare(); deployment.get().activate(); - //assertProvisionInfo(vespaVersion, tester, applicationId); + //assertAllocatedHosts(vespaVersion, tester, applicationId); } - private void assertProvisionInfo(String vespaVersion, DeployTester tester, ApplicationId applicationId) { + private void assertAllocatedHosts(String vespaVersion, DeployTester tester, ApplicationId applicationId) { tester.getAllocatedHostsOf(applicationId).getHosts().stream() .forEach(h -> assertEquals(vespaVersion, h.membership().get().cluster().vespaVersion())); } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClientTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClientTest.java index bd0d4287631..bf7f7038c1a 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClientTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClientTest.java @@ -47,8 +47,8 @@ public class ZooKeeperClientTest extends TestWithCurator { Map<Version, FileRegistry> fileRegistries = createFileRegistries(); app.writeMetaData(); zkc.setupZooKeeper(); - zkc.feedZooKeeper(app); - zkc.feedZKFileRegistries(fileRegistries); + zkc.write(app); + zkc.write(fileRegistries); } private Map<Version, FileRegistry> createFileRegistries() { @@ -178,7 +178,7 @@ public class ZooKeeperClientTest extends TestWithCurator { HostSpec host1 = new HostSpec("host1.yahoo.com", Collections.emptyList()); HostSpec host2 = new HostSpec("host2.yahoo.com", Collections.emptyList()); ImmutableSet<HostSpec> hosts = ImmutableSet.of(host1, host2); - zooKeeperClient.feedProvisionInfo(AllocatedHosts.withHosts(hosts)); + zooKeeperClient.write(AllocatedHosts.withHosts(hosts)); Path hostsPath = app.append(ZKApplicationPackage.allocatedHostsNode); assertTrue(zk.exists(hostsPath.getAbsolute())); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java index dfa2b687587..7fca78b087b 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java @@ -217,8 +217,8 @@ public class SessionActiveHandlerTest extends SessionHandlerTest { zkClient.writeStatus(status); ZooKeeperClient zkC = new ZooKeeperClient(configCurator, new BaseDeployLogger(), false, pathProvider.getSessionDirs().append(String.valueOf(sessionId))); VespaModelFactory modelFactory = new VespaModelFactory(new NullConfigModelRegistry()); - zkC.feedZKFileRegistries(Collections.singletonMap(modelFactory.getVersion(), new MockFileRegistry())); - zkC.feedProvisionInfo(AllocatedHosts.withHosts(Collections.emptySet())); + zkC.write(Collections.singletonMap(modelFactory.getVersion(), new MockFileRegistry())); + zkC.write(AllocatedHosts.withHosts(Collections.emptySet())); TestComponentRegistry componentRegistry = new TestComponentRegistry.Builder() .curator(curator) .configCurator(configCurator) diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionTest.java index e9417483932..be98f41c82a 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionTest.java @@ -160,9 +160,9 @@ public class LocalSessionTest { zkc.createWriteStatusTransaction(Session.Status.NEW).commit(); ZooKeeperClient zkClient = new ZooKeeperClient(configCurator, new BaseDeployLogger(), false, appPath); if (allocatedHosts.isPresent()) { - zkClient.feedProvisionInfo(allocatedHosts.get()); + zkClient.write(allocatedHosts.get()); } - zkClient.feedZKFileRegistries(Collections.singletonMap(Version.fromIntValues(0, 0, 0), new MockFileRegistry())); + zkClient.write(Collections.singletonMap(Version.fromIntValues(0, 0, 0), new MockFileRegistry())); File sessionDir = new File(tenantFileSystemDirs.path(), String.valueOf(sessionId)); sessionDir.createNewFile(); return new LocalSession(tenant, sessionId, preparer, new SessionContext(FilesApplicationPackage.fromFile(testApp), zkc, sessionDir, new MemoryTenantApplications(), new HostRegistry<>(), superModelGenerationCounter)); |