diff options
author | Harald Musum <musum@verizonmedia.com> | 2019-08-16 09:40:47 +0200 |
---|---|---|
committer | Harald Musum <musum@verizonmedia.com> | 2019-08-16 09:40:47 +0200 |
commit | 1bd483434a599372c04e34b699010cdb8f5e104a (patch) | |
tree | 04656a6ce4e816dcfbd2712625ea453ae837206d /configserver | |
parent | f9ab8f501a1b476d0f2f3aafec12093ca2929617 (diff) |
Cleanup
Remove some unused counters, update/remove some javadoc, access levels, unused methods
No functional changes
Diffstat (limited to 'configserver')
6 files changed, 23 insertions, 88 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 a99a2a2917d..401b6974596 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 @@ -42,12 +42,7 @@ public class ZooKeeperClient { /* This is the generation that will be used for reading and writing application data. (1 more than last deployed application) */ private final Path rootPath; - static final ApplicationFile.PathFilter xmlFilter = new ApplicationFile.PathFilter() { - @Override - public boolean accept(Path path) { - return path.getName().endsWith(".xml"); - } - }; + private static final ApplicationFile.PathFilter xmlFilter = path -> path.getName().endsWith(".xml"); public ZooKeeperClient(ConfigCurator configCurator, DeployLogger logger, boolean logFine, Path rootPath) { this.configCurator = configCurator; @@ -116,23 +111,15 @@ public class ZooKeeperClient { logFine("Feeding application config into ZooKeeper"); // gives lots and lots of debug output: // BasicConfigurator.configure(); try { - 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 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), " + @@ -164,7 +151,7 @@ public class ZooKeeperClient { * @param app The application package to use as input. * @throws java.io.IOException if not able to write to Zookeeper */ - void writeSomeOf(ApplicationPackage app) throws IOException { + private void writeSomeOf(ApplicationPackage app) throws IOException { ApplicationFile.PathFilter srFilter = new ApplicationFile.PathFilter() { @Override public boolean accept(Path path) { @@ -342,7 +329,7 @@ public class ZooKeeperClient { * @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 */ - Path getZooKeeperAppPath(String trailingPath) { + private Path getZooKeeperAppPath(String trailingPath) { if (trailingPath != null) { return rootPath.append(trailingPath); } else { @@ -350,7 +337,7 @@ public class ZooKeeperClient { } } - void logFine(String msg) { + private void logFine(String msg) { if (logFine) { logger.log(LogLevel.FINE, msg); } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ConfigCurator.java b/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ConfigCurator.java index 56709225c1d..6933af6bedf 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ConfigCurator.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ConfigCurator.java @@ -13,7 +13,6 @@ import java.io.FilenameFilter; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; /** * A (stateful) curator wrapper for the config server. This simplifies Curator method calls used by the config server @@ -23,17 +22,12 @@ import java.util.concurrent.atomic.AtomicInteger; * Config ids are stored as foo#bar#c0 instead of foo/bar/c0, for simplicity. * Keep the amount of domain-specific logic here to a minimum. * Data for one application x is stored on this form: - * /vespa/config/apps/x/defconfigs - * /vespa/config/apps/x/userapp - * The different types of configs are stored on this form (ie. names of the ZK nodes under their respective - * paths): + * /config/v2/tenants/x/sessions/y/defconfigs + * /config/v2/tenants/x/sessions/y/userapp * <p> - * Def configs are stored on the form name,version * The user application structure is exactly the same as in the user's app dir during deploy. - * The current live app id (for example x) is stored in the node /vespa/config/liveapp - * It is updated outside this class, typically in config server during reload-config. - * Some methods have retries and/or reconnect. This is necessary because ZK will throw on certain scenarios, - * even though it will recover from it itself, @see http://wiki.apache.org/hadoop/ZooKeeper/ErrorHandling + * The current live app id (for example y) is stored in the node //config/v2/tenants/x/applications/<application-id> + * It is updated outside this class, typically in config server when activating config * * @author Vegard Havdal * @author bratseth @@ -55,33 +49,15 @@ public class ConfigCurator { /** Path for session state */ public static final String SESSIONSTATE_ZK_SUBPATH = "/sessionState"; - protected static final FilenameFilter acceptsAllFileNameFilter = (dir, name) -> true; + private static final FilenameFilter acceptsAllFileNameFilter = (dir, name) -> true; private final Curator curator; public static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(ConfigCurator.class.getName()); - /** The number of zookeeper operations done with this ZKFacade instance */ - private final AtomicInteger operations = new AtomicInteger(); - - /** The number of zookeeper read operations done with this ZKFacade instance */ - private final AtomicInteger readOperations = new AtomicInteger(); - - /** The number of zookeeper write operations done with this ZKFacade instance */ - private final AtomicInteger writeOperations = new AtomicInteger(); - /** The maximum size of a ZooKeeper node */ private final int maxNodeSize; - /** - * Sets up thread local zk access if not done before and returns a facade object - * - * @return a ZKFacade object - */ - public static ConfigCurator create(Curator curator, int juteMaxBuffer) { - return new ConfigCurator(curator, juteMaxBuffer); - } - public static ConfigCurator create(Curator curator) { return new ConfigCurator(curator, 1024*1024*10); } @@ -102,10 +78,8 @@ public class ConfigCurator { public Curator curator() { return curator; } /** Cleans and creates a zookeeper completely */ - public void initAndClear(String path) { + void initAndClear(String path) { try { - operations.incrementAndGet(); - readOperations.incrementAndGet(); if (exists(path)) deleteRecurse(path); createRecurse(path); @@ -151,8 +125,6 @@ public class ConfigCurator { public byte[] getBytes(String path) { try { if ( ! exists(path)) return null; // TODO: Ugh - operations.incrementAndGet(); - readOperations.incrementAndGet(); return curator.framework().getData().forPath(path); } catch (Exception e) { @@ -179,8 +151,6 @@ public class ConfigCurator { public void createNode(String path) { if ( ! exists(path)) createRecurse(path); - operations.incrementAndGet(); - writeOperations.incrementAndGet(); } /** Creates a Zookeeper node synchronously. Replaces / by # in node names. */ @@ -218,8 +188,6 @@ public class ConfigCurator { public void putData(String path, byte[] data) { try { ensureDataIsNotTooLarge(data, path); - operations.incrementAndGet(); - writeOperations.incrementAndGet(); if (exists(path)) curator.framework().setData().forPath(path, data); else @@ -244,8 +212,6 @@ public class ConfigCurator { public void setData(String path, byte[] data) { try { ensureDataIsNotTooLarge(data, path); - operations.incrementAndGet(); - writeOperations.incrementAndGet(); curator.framework().setData().forPath(path, data); } catch (Exception e) { @@ -271,8 +237,6 @@ public class ConfigCurator { */ public List<String> getChildren(String path) { try { - operations.incrementAndGet(); - readOperations.incrementAndGet(); return curator.framework().getChildren().forPath(path); } catch (Exception e) { @@ -361,17 +325,6 @@ public class ConfigCurator { } } - public Integer getNumberOfOperations() { return operations.intValue(); } - - public Integer getNumberOfReadOperations() { - return readOperations.intValue(); - } - - public Integer getNumberOfWriteOperations() { - return writeOperations.intValue(); - } - - private void testZkConnection() { // This is not necessary, but allows us to give a useful error message if (curator.connectionSpec().isEmpty()) return; try { diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/InitializedCounter.java b/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/InitializedCounter.java index dc93886e0c0..773888a8a03 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/InitializedCounter.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/InitializedCounter.java @@ -17,10 +17,10 @@ import java.util.List; public class InitializedCounter { private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(InitializedCounter.class.getName()); - protected final CuratorCounter counter; + final CuratorCounter counter; private final String sessionsDirPath; - public InitializedCounter(ConfigCurator configCurator, String counterPath, String sessionsDirPath) { + InitializedCounter(ConfigCurator configCurator, String counterPath, String sessionsDirPath) { this.sessionsDirPath = sessionsDirPath; this.counter = new CuratorCounter(configCurator.curator(), counterPath); initializeCounterValue(getLatestSessionId(configCurator, sessionsDirPath)); diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationFile.java b/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationFile.java index c2d59844fde..839e5e3f024 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationFile.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationFile.java @@ -15,8 +15,7 @@ import java.util.logging.Logger; /** * @author Ulf Lilleengen - * @author vegardh - * @since 5.1 + * @author Vegard Havdal */ class ZKApplicationFile extends ApplicationFile { 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 e013244c80c..77ca73c4cb9 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 @@ -155,7 +155,7 @@ public class ZKApplicationPackage implements ApplicationPackage { private Optional<PreGeneratedFileRegistry> getPreGeneratedFileRegistry(Version vespaVersion) { // Assumes at least one file registry, which we always have. Optional<PreGeneratedFileRegistry> fileRegistry = Optional.ofNullable(fileRegistryMap.get(vespaVersion)); - if ( ! fileRegistry.isPresent()) { + if (fileRegistry.isEmpty()) { fileRegistry = Optional.of(fileRegistryMap.values().iterator().next()); } return fileRegistry; diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKLiveApp.java b/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKLiveApp.java index 383672b3639..fe7a8a0ef77 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKLiveApp.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKLiveApp.java @@ -9,11 +9,10 @@ import java.io.StringReader; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.logging.Logger; /** * Responsible for providing data from the currently live application subtree in zookeeper. - * (i.e. /vespa/config/apps/<id of currently active app>/). + * (i.e. /config/v2/tenants/x/<id of currently active app>/). * * Note: The application revision ("session") stored in this tree is not necessarily live, just complete, * preparable, prepared or active. @@ -22,12 +21,10 @@ import java.util.logging.Logger; */ public class ZKLiveApp { - private static final Logger log = Logger.getLogger(ZKLiveApp.class.getName()); - private final ConfigCurator zk; private final Path appPath; - public ZKLiveApp(ConfigCurator zk, Path appPath) { + ZKLiveApp(ConfigCurator zk, Path appPath) { this.zk = zk; this.appPath = appPath; } @@ -37,13 +34,13 @@ public class ZKLiveApp { * be closed by the caller. * * @param path a path relative to the currently active application - * (i.e. /vespa/config/apps/<id of currently active app>/). + * (i.e. /config/v2/tenants/x/applications/<id of currently active app>/). * @param fileNameSuffix the suffix of files to return, or null to return all * @param recursive if true, all files from all subdirectories of this will also be returned * @return the files in the given path, or an empty list (never null) if the directory does not exist or is empty. * The list gets owned by the caller and can be modified freely. */ - public List<NamedReader> getAllDataFromDirectory(String path, String fileNameSuffix, boolean recursive) { + List<NamedReader> getAllDataFromDirectory(String path, String fileNameSuffix, boolean recursive) { return getAllDataFromDirectory(path, "", fileNameSuffix, recursive); } @@ -73,14 +70,13 @@ public class ZKLiveApp { } /** - * Retrieves a node relative to the node of the live application, - * e.g. /vespa/config/apps/$lt;app_id>/<path>/<node> + * Retrieves a node relative to the node of the live application * * @param path a path relative to the currently active application * @param node a path relative to the path above * @return a Reader that can be used to get the data */ - public Reader getDataReader(String path, String node) { + Reader getDataReader(String path, String node) { String data = getData(path, node); if (data == null) { throw new IllegalArgumentException("No node for " + getFullPath(path) + "/" + node + " exists"); @@ -113,7 +109,7 @@ public class ZKLiveApp { } } - public void putData(String path, String data) { + void putData(String path, String data) { try { zk.putData(getFullPath(path), data); } catch (RuntimeException e) { @@ -164,7 +160,7 @@ public class ZKLiveApp { * * @param path path to delete */ - public void deleteRecurse(String path) { + void deleteRecurse(String path) { zk.deleteRecurse(getFullPath(path)); } @@ -193,7 +189,7 @@ public class ZKLiveApp { } } - public Reader getDataReader(String path) { + Reader getDataReader(String path) { final String data = getData(path); if (data == null) { throw new IllegalArgumentException("No node for " + getFullPath(path) + " exists"); |