diff options
author | Harald Musum <musum@verizonmedia.com> | 2021-05-27 09:22:42 +0200 |
---|---|---|
committer | Harald Musum <musum@verizonmedia.com> | 2021-05-27 09:22:42 +0200 |
commit | e6d39d74bc81876ae16401a4bb831548a8781a17 (patch) | |
tree | 809887250f4107dc638e637a4edd7b171ee2af55 | |
parent | 40db354a2d0d8f8344bd2017bfbf861886a1550d (diff) |
Remove support for legacy file registry in zookeeper
File registry in top-level node for file registrhy has not been in
use for many years, remove
2 files changed, 17 insertions, 16 deletions
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 acb5e665c5f..1ab99db8985 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 @@ -66,7 +66,7 @@ public class ZooKeeperClient { USERAPP_ZK_SUBPATH, ZKApplicationPackage.fileRegistryNode)) { // TODO: The replaceFirst below is hackish. - configCurator.createNode(getZooKeeperAppPath(null).getAbsolute(), + configCurator.createNode(getZooKeeperAppPath().getAbsolute(), subPath.replaceFirst("/", "")); } } @@ -234,8 +234,7 @@ public class ZooKeeperClient { private void write(Version vespaVersion, FileRegistry fileRegistry) { String exportedRegistry = PreGeneratedFileRegistry.exportRegistry(fileRegistry); - - configCurator.putData(getZooKeeperAppPath(null).append(ZKApplicationPackage.fileRegistryNode).getAbsolute(), + configCurator.putData(getZooKeeperAppPath(ZKApplicationPackage.fileRegistryNode).getAbsolute(), vespaVersion.toFullString(), exportedRegistry); } @@ -261,8 +260,16 @@ public class ZooKeeperClient { } /** - * Gets a full ZK app path based on id set in Admin object + * Gets a full ZK application path * + * @return a String with the full ZK application path + */ + private Path getZooKeeperAppPath() { + return getZooKeeperAppPath(null); + } + + /** + * Gets a full ZK application path * * @param trailingPath trailing part of path to be appended to ZK app path * @return a String with the full ZK application path including trailing path, if set 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 6fd53d52e93..f01bf1fe6ef 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 @@ -45,7 +45,6 @@ public class ZKApplicationPackage implements ApplicationPackage { private final Map<Version, PreGeneratedFileRegistry> fileRegistryMap = new HashMap<>(); private final Optional<AllocatedHosts> allocatedHosts; - private static final Version legacyVersion = new Version(0, 0, 0); public static final String fileRegistryNode = "fileregistry"; public static final String allocatedHostsNode = "allocatedHosts"; @@ -78,14 +77,11 @@ public class ZKApplicationPackage implements ApplicationPackage { } private void importFileRegistries() { - List<String> fileRegistryNodes = zkApplication.getChildren(fileRegistryNode); - if (fileRegistryNodes.isEmpty()) { - fileRegistryMap.put(legacyVersion, importFileRegistry(fileRegistryNode)); - } else { - fileRegistryNodes.forEach(version -> - fileRegistryMap.put(Version.fromString(version), - importFileRegistry(Joiner.on("/").join(fileRegistryNode, version)))); - } + List<String> perVersionFileRegistryNodes = zkApplication.getChildren(fileRegistryNode); + perVersionFileRegistryNodes + .forEach(version -> + fileRegistryMap.put(Version.fromString(version), + importFileRegistry(Joiner.on("/").join(fileRegistryNode, version)))); } private PreGeneratedFileRegistry importFileRegistry(String fileRegistryNode) { @@ -266,9 +262,7 @@ public class ZKApplicationPackage implements ApplicationPackage { @Override public Reader getRankingExpression(String name) { Optional<Reader> reader = zkApplication.getOptionalDataReader(ConfigCurator.USERAPP_ZK_SUBPATH + "/" + SCHEMAS_DIR, name); - if (reader.isPresent()) - return reader.get(); - return zkApplication.getDataReader(ConfigCurator.USERAPP_ZK_SUBPATH + "/" + SEARCH_DEFINITIONS_DIR, name); + return reader.orElseGet(() -> zkApplication.getDataReader(ConfigCurator.USERAPP_ZK_SUBPATH + "/" + SEARCH_DEFINITIONS_DIR, name)); } @Override |