summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorHarald Musum <musum@oath.com>2017-09-17 18:53:32 +0200
committerHarald Musum <musum@oath.com>2017-09-17 18:53:32 +0200
commit781196384cf30a5bc10dc5749853aa67775b98d7 (patch)
tree43d392e9f8b987ec1099b572698e148a40dbf687 /configserver
parente19d9f4ef86f8abb135a224429e85bdc9814a815 (diff)
parent98a9ddc6bbed5e61130eeb1e1100ed9b42d09553 (diff)
Merge branch 'master' into hmusum/only-create-hosted-vespa-tenant-on-hosted
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ActivationConflictException.java15
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationListener.java24
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ReloadListener.java19
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelController.java2
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelListener.java23
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelManager.java108
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelProvider.java12
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelRequestHandler.java82
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java17
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpConfigRequest.java4
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpErrorResponse.java5
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpHandler.java3
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/model/SuperModel.java3
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelsBuilder.java10
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessor.java2
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java2
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/PrepareParams.java3
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClient.java2
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandler.java3
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ConfigCurator.java3
-rw-r--r--configserver/src/main/resources/configserver-app/services.xml1
-rw-r--r--configserver/src/test/apps/serverdb/serverdefs/attributes.def1
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelRequestHandlerTest.java15
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/a.def1
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/b.def1
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/c.def1
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/compositeinclude.def1
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/d.def1
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/e.def1
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/recursiveinclude.def1
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/spooler.def1
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java23
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/model/LbServicesProducerTest.java2
-rwxr-xr-xconfigserver/src/test/java/com/yahoo/vespa/config/server/model/RoutingProducerTest.java2
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java2
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/rpc/TestWithRpc.java16
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandlerTest.java2
-rw-r--r--configserver/src/test/resources/configdefinitions/app.def1
-rw-r--r--configserver/src/test/resources/configdefinitions/datastructures.def1
-rw-r--r--configserver/src/test/resources/configdefinitions/function-test.def1
-rw-r--r--configserver/src/test/resources/configdefinitions/md5test.def2
-rw-r--r--configserver/src/test/resources/configdefinitions/simpletypes.def1
-rw-r--r--configserver/src/test/resources/configdefinitions/unicode.def1
43 files changed, 273 insertions, 148 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ActivationConflictException.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ActivationConflictException.java
new file mode 100644
index 00000000000..48023293cc4
--- /dev/null
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ActivationConflictException.java
@@ -0,0 +1,15 @@
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.config.server;
+
+/**
+ * Exception used when activation cannot be done because activation is for
+ * an older session than the one that is active now or because current active
+ * session has changed since the session to be activated was created
+ *
+ * @author hmusum
+ */
+public class ActivationConflictException extends RuntimeException {
+ public ActivationConflictException(String s) {
+ super(s);
+ }
+}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationListener.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationListener.java
new file mode 100644
index 00000000000..bea25183eef
--- /dev/null
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationListener.java
@@ -0,0 +1,24 @@
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+package com.yahoo.vespa.config.server;
+
+import com.yahoo.config.provision.ApplicationId;
+import com.yahoo.config.provision.TenantName;
+import com.yahoo.vespa.config.server.application.ApplicationSet;
+
+public interface ApplicationListener {
+ /**
+ * Configs has been activated for an application: Either an application
+ * has been deployed for the first time, or it has been externally or internally redeployed.
+ *
+ * Must be thread-safe.
+ */
+ void configActivated(TenantName tenant, ApplicationSet application);
+
+ /**
+ * Application has been removed.
+ *
+ * Must be thread-safe.
+ */
+ void applicationRemoved(ApplicationId applicationId);
+}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ReloadListener.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ReloadListener.java
index 228ae0adfae..e392472480b 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/ReloadListener.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ReloadListener.java
@@ -15,16 +15,7 @@ import java.util.Collection;
* @author lulf
* @since 5.1
*/
-public interface ReloadListener {
-
- /**
- * Signal the listener that config has been reloaded.
- *
- * @param tenant Name of tenant for which config was reloaded.
- * @param application the {@link com.yahoo.vespa.config.server.application.Application} that will be reloaded
- */
- public void configReloaded(TenantName tenant, ApplicationSet application);
-
+public interface ReloadListener extends ApplicationListener {
/**
* Signal the listener that hosts used by by a particular tenant.
*
@@ -35,18 +26,10 @@ public interface ReloadListener {
/**
* Verify that given hosts are available for use by tenant.
- * TODO: Does not belong here...
*
* @param tenant tenant that wants to allocate hosts.
* @param newHosts a {@link java.util.Collection} of hosts that tenant wants to allocate.
* @throws java.lang.IllegalArgumentException if one or more of the hosts are in use by another tenant.
*/
void verifyHostsAreAvailable(TenantName tenant, Collection<String> newHosts);
-
- /**
- * Notifies listener that application with id {@link ApplicationId} has been removed.
- *
- * @param applicationId The {@link ApplicationId} of the removed application.
- */
- void applicationRemoved(ApplicationId applicationId);
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelController.java b/configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelController.java
index 23c9bab450b..1532c05a56b 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelController.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelController.java
@@ -68,7 +68,7 @@ public class SuperModelController {
}
}
- SuperModel getSuperModel() {
+ public SuperModel getSuperModel() {
return model;
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelListener.java b/configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelListener.java
new file mode 100644
index 00000000000..81d706cf2e9
--- /dev/null
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelListener.java
@@ -0,0 +1,23 @@
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+package com.yahoo.vespa.config.server;
+
+import com.yahoo.config.provision.ApplicationId;
+import com.yahoo.vespa.config.server.application.Application;
+import com.yahoo.vespa.config.server.model.SuperModel;
+
+/**
+ * Interface for those wanting to be notified about changes to the SuperModel.
+ */
+public interface SuperModelListener {
+ /**
+ * Application has been activated: Either deployed the first time,
+ * internally redeployed, or externally triggered redeploy.
+ */
+ void applicationActivated(SuperModel superModel, Application application);
+
+ /**
+ * Application has been removed.
+ */
+ void applicationRemoved(SuperModel superModel, ApplicationId applicationId);
+}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelManager.java b/configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelManager.java
new file mode 100644
index 00000000000..c3fd417f434
--- /dev/null
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelManager.java
@@ -0,0 +1,108 @@
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+package com.yahoo.vespa.config.server;
+
+import com.google.inject.Inject;
+import com.yahoo.cloud.config.ConfigserverConfig;
+import com.yahoo.config.provision.ApplicationId;
+import com.yahoo.config.provision.NodeFlavors;
+import com.yahoo.config.provision.TenantName;
+import com.yahoo.config.provision.Zone;
+import com.yahoo.vespa.config.GenerationCounter;
+import com.yahoo.vespa.config.server.application.Application;
+import com.yahoo.vespa.config.server.application.ApplicationSet;
+import com.yahoo.vespa.config.server.model.SuperModel;
+
+import java.time.Instant;
+import java.util.*;
+
+/**
+ * Provides a SuperModel - a model of all application instances, and makes it stays
+ * up to date as applications are added, redeployed, and removed.
+ */
+public class SuperModelManager implements SuperModelProvider, ApplicationListener {
+ private final Zone zone;
+ private SuperModel superModel; // Guarded by 'this' monitor
+ private final List<SuperModelListener> listeners = new ArrayList<>(); // Guarded by 'this' monitor
+
+ // Generation of the super model
+ private long generation;
+ private final long masterGeneration; // ConfigserverConfig's generation
+ private final GenerationCounter generationCounter;
+
+ @Inject
+ public SuperModelManager(ConfigserverConfig configserverConfig,
+ NodeFlavors nodeFlavors,
+ GenerationCounter generationCounter) {
+ this.zone = new Zone(configserverConfig, nodeFlavors);
+ this.generationCounter = generationCounter;
+ this.masterGeneration = configserverConfig.masterGeneration();
+ makeNewSuperModel(new HashMap<>());
+ }
+
+ @Override
+ public synchronized SuperModel getSuperModel() {
+ return superModel;
+ }
+
+ @Override
+ public synchronized long getGeneration() {
+ return generation;
+ }
+
+ @Override
+ public synchronized void registerListener(SuperModelListener listener) {
+ listeners.add(listener);
+ }
+
+ @Override
+ public synchronized void configActivated(TenantName tenant, ApplicationSet applicationSet) {
+ Map<TenantName, Map<ApplicationId, Application>> newModels = createModelCopy();
+ if (!newModels.containsKey(tenant)) {
+ // New application has been activated
+ newModels.put(tenant, new LinkedHashMap<>());
+ } else {
+ // Application has been redeployed
+ }
+
+ // TODO: Should supermodel care about multiple versions?
+ Application application = applicationSet.getForVersionOrLatest(Optional.empty(), Instant.now());
+ newModels.get(tenant).put(applicationSet.getId(), application);
+
+ makeNewSuperModel(newModels);
+ listeners.stream().forEach(listener -> listener.applicationActivated(superModel, application));
+ }
+
+ @Override
+ public synchronized void applicationRemoved(ApplicationId applicationId) {
+ Map<TenantName, Map<ApplicationId, Application>> newModels = createModelCopy();
+ if (newModels.containsKey(applicationId.tenant())) {
+ newModels.get(applicationId.tenant()).remove(applicationId);
+ if (newModels.get(applicationId.tenant()).isEmpty()) {
+ newModels.remove(applicationId.tenant());
+ }
+ }
+
+ makeNewSuperModel(newModels);
+ listeners.stream().forEach(listener -> listener.applicationRemoved(superModel, applicationId));
+ }
+
+ private void makeNewSuperModel(Map<TenantName, Map<ApplicationId, Application>> newModels) {
+ generation = masterGeneration + generationCounter.get();
+ superModel = new SuperModel(newModels, zone);
+ }
+
+ private Map<TenantName, Map<ApplicationId, Application>> createModelCopy() {
+ Map<TenantName, Map<ApplicationId, Application>> currentModels = superModel.applicationModels();
+ Map<TenantName, Map<ApplicationId, Application>> newModels = new LinkedHashMap<>();
+ for (Map.Entry<TenantName, Map<ApplicationId, Application>> entry : currentModels.entrySet()) {
+ Map<ApplicationId, Application> appMap = new LinkedHashMap<>();
+ newModels.put(entry.getKey(), appMap);
+ for (Map.Entry<ApplicationId, Application> appEntry : entry.getValue().entrySet()) {
+ appMap.put(appEntry.getKey(), appEntry.getValue());
+ }
+ }
+
+ return newModels;
+ }
+}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelProvider.java b/configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelProvider.java
new file mode 100644
index 00000000000..81eb823c026
--- /dev/null
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelProvider.java
@@ -0,0 +1,12 @@
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+package com.yahoo.vespa.config.server;
+
+import com.yahoo.vespa.config.server.model.SuperModel;
+
+interface SuperModelProvider {
+ SuperModel getSuperModel();
+ long getGeneration();
+
+ void registerListener(SuperModelListener listener);
+}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelRequestHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelRequestHandler.java
index 105bd9a5b2a..95f16a7c1e7 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelRequestHandler.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelRequestHandler.java
@@ -7,30 +7,26 @@ import com.yahoo.config.ConfigInstance;
import com.yahoo.config.model.api.ConfigDefinitionRepo;
import com.yahoo.config.provision.NodeFlavors;
import com.yahoo.config.provision.Version;
-import com.yahoo.config.provision.Zone;
import com.yahoo.log.LogLevel;
import com.yahoo.vespa.config.ConfigKey;
+import com.yahoo.vespa.config.GenerationCounter;
import com.yahoo.vespa.config.GetConfigRequest;
import com.yahoo.vespa.config.protocol.ConfigResponse;
import com.yahoo.vespa.config.server.application.Application;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.TenantName;
-import com.yahoo.vespa.config.GenerationCounter;
import com.yahoo.vespa.config.server.application.ApplicationSet;
-import com.yahoo.vespa.config.server.model.SuperModel;
import com.yahoo.vespa.config.server.rpc.ConfigResponseFactory;
import com.yahoo.vespa.config.server.rpc.ConfigResponseFactoryFactory;
import java.io.IOException;
-import java.time.Instant;
-import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
/**
- * Handles request for supermodel config
+ * Handles request for supermodel config.
*
* @author lulf
* @since 5.9
@@ -39,91 +35,59 @@ public class SuperModelRequestHandler implements RequestHandler {
private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(SuperModelRequestHandler.class.getName());
private volatile SuperModelController handler;
- private final GenerationCounter generationCounter;
- private final Zone zone;
- private final long masterGeneration;
private final ConfigDefinitionRepo configDefinitionRepo;
private final ConfigResponseFactory responseFactory;
+ private final SuperModelManager superModelManager;
private volatile boolean enabled = false;
/**
* Creates a supermodel controller
*/
@Inject
- public SuperModelRequestHandler(GenerationCounter generationCounter, ConfigDefinitionRepo configDefinitionRepo,
- ConfigserverConfig configserverConfig, NodeFlavors nodeFlavors) {
- this.generationCounter = generationCounter;
+ public SuperModelRequestHandler(ConfigDefinitionRepo configDefinitionRepo,
+ ConfigserverConfig configserverConfig,
+ SuperModelManager superModelManager) {
this.configDefinitionRepo = configDefinitionRepo;
- this.masterGeneration = configserverConfig.masterGeneration();
this.responseFactory = ConfigResponseFactoryFactory.createFactory(configserverConfig);
- this.zone = new Zone(configserverConfig, nodeFlavors);
- this.handler = createNewHandler(Collections.emptyMap());
+ this.superModelManager = superModelManager;
+ updateHandler();
}
/**
* Signals that config has been reloaded for an {@link com.yahoo.vespa.config.server.application.Application}
* belonging to a tenant.
*
- * TODO: This is a bit too complex I think.
- *
* @param tenant Name of tenant owning the application.
* @param applicationSet The reloaded set of {@link com.yahoo.vespa.config.server.application.Application}.
*/
public synchronized void reloadConfig(TenantName tenant, ApplicationSet applicationSet) {
- Map<TenantName, Map<ApplicationId, Application>> newModels = createModelCopy();
- if (!newModels.containsKey(tenant)) {
- newModels.put(tenant, new LinkedHashMap<>());
- }
- // TODO: Should supermodel care about multiple versions?
- newModels.get(tenant).put(applicationSet.getId(), applicationSet.getForVersionOrLatest(Optional.empty(), Instant.now()));
- handler = createNewHandler(newModels);
+ superModelManager.configActivated(tenant, applicationSet);
+ updateHandler();
}
public synchronized void removeApplication(ApplicationId applicationId) {
- Map<TenantName, Map<ApplicationId, Application>> newModels = createModelCopy();
- if (newModels.containsKey(applicationId.tenant())) {
- newModels.get(applicationId.tenant()).remove(applicationId);
- if (newModels.get(applicationId.tenant()).isEmpty()) {
- newModels.remove(applicationId.tenant());
- }
- }
- handler = createNewHandler(newModels);
- }
-
- private SuperModelController createNewHandler(Map<TenantName, Map<ApplicationId, Application>> newModels) {
- long generation = generationCounter.get() + masterGeneration;
- SuperModel model = new SuperModel(newModels, zone);
- return new SuperModelController(model, configDefinitionRepo, generation, responseFactory);
- }
-
- private Map<TenantName, Map<ApplicationId, Application>> getCurrentModels() {
- if (handler != null) {
- return handler.getSuperModel().applicationModels();
- } else {
- return new LinkedHashMap<>();
- }
+ superModelManager.applicationRemoved(applicationId);
+ updateHandler();
}
- private Map<TenantName, Map<ApplicationId, Application>> createModelCopy() {
- Map<TenantName, Map<ApplicationId, Application>> currentModels = getCurrentModels();
- Map<TenantName, Map<ApplicationId, Application>> newModels = new LinkedHashMap<>();
- for (Map.Entry<TenantName, Map<ApplicationId, Application>> entry : currentModels.entrySet()) {
- Map<ApplicationId, Application> appMap = new LinkedHashMap<>();
- newModels.put(entry.getKey(), appMap);
- for (Map.Entry<ApplicationId, Application> appEntry : entry.getValue().entrySet()) {
- appMap.put(appEntry.getKey(), appEntry.getValue());
- }
- }
- return newModels;
+ private void updateHandler() {
+ handler = new SuperModelController(
+ superModelManager.getSuperModel(),
+ configDefinitionRepo,
+ superModelManager.getGeneration(),
+ responseFactory);
}
public SuperModelController getHandler() { return handler; }
@Override
public ConfigResponse resolveConfig(ApplicationId appId, GetConfigRequest req, Optional<Version> vespaVersion) {
- log.log(LogLevel.DEBUG, "SuperModelRequestHandler resolving " + req + " for app id '" + appId + "'");
+ log.log(LogLevel.DEBUG, () -> "SuperModelRequestHandler resolving " + req + " for app id '" + appId + "'");
if (handler != null) {
- return handler.resolveConfig(req);
+ ConfigResponse configResponse = handler.resolveConfig(req);
+ log.log(LogLevel.DEBUG, () -> "SuperModelRequestHandler returning response for config " + req +
+ " with generation " + configResponse.getGeneration());
+ return configResponse;
}
return null;
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java
index 51995eb98cf..e38be55290f 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java
@@ -9,6 +9,7 @@ import com.yahoo.log.LogLevel;
import com.yahoo.path.Path;
import com.yahoo.transaction.NestedTransaction;
import com.yahoo.transaction.Transaction;
+import com.yahoo.vespa.config.server.ActivationConflictException;
import com.yahoo.vespa.config.server.tenant.ActivateLock;
import com.yahoo.vespa.config.server.ApplicationRepository;
import com.yahoo.vespa.config.server.TimeoutBudget;
@@ -29,7 +30,7 @@ import java.util.logging.Logger;
* Deployments are created by a {@link ApplicationRepository}.
* Instances of this are not multithread safe.
*
- * @author lulf
+ * @author Ulf Lilleengen
* @author bratseth
*/
public class Deployment implements com.yahoo.config.provision.Deployment {
@@ -128,7 +129,7 @@ public class Deployment implements com.yahoo.config.provision.Deployment {
log.log(LogLevel.DEBUG, "Trying to acquire lock " + activateLock + " for session " + sessionId);
boolean acquired = activateLock.acquire(timeoutBudget, ignoreLockFailure);
if ( ! acquired) {
- log.log(LogLevel.DEBUG, "Acquiring " + activateLock + " for session " + sessionId + " returned false");
+ throw new InternalServerException("Did not get activate lock for session " + sessionId + " within " + timeout);
}
log.log(LogLevel.DEBUG, "Lock acquired " + activateLock + " for session " + sessionId);
@@ -202,25 +203,25 @@ public class Deployment implements com.yahoo.config.provision.Deployment {
", current active session=" + currentActiveSessionSessionId);
if (currentActiveSession.isNewerThan(activeSessionAtCreate) &&
currentActiveSessionSessionId != sessionId) {
- String errMsg = currentActiveSession.logPre()+"Cannot activate session " +
+ String errMsg = currentActiveSession.logPre() + "Cannot activate session " +
sessionId + " because the currently active session (" +
currentActiveSessionSessionId + ") has changed since session " + sessionId +
" was created (was " + activeSessionAtCreate + " at creation time)";
if (ignoreStaleSessionFailure) {
log.warning(errMsg + " (Continuing because of force.)");
} else {
- throw new IllegalStateException(errMsg);
+ throw new ActivationConflictException(errMsg);
}
}
}
- // As of now, config generation is based on session id, and config generation must be an monotonically
+ // As of now, config generation is based on session id, and config generation must be a monotonically
// increasing number
private void checkIfActiveIsNewerThanSessionToBeActivated(long sessionId, long currentActiveSessionId) {
if (sessionId < currentActiveSessionId) {
- throw new IllegalArgumentException("It is not possible to activate session " + sessionId +
- ", because it is older than current active session (" +
- currentActiveSessionId + ")");
+ throw new ActivationConflictException("It is not possible to activate session " + sessionId +
+ ", because it is older than current active session (" +
+ currentActiveSessionId + ")");
}
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpConfigRequest.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpConfigRequest.java
index 3fc7f43e4af..6ba788aced3 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpConfigRequest.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpConfigRequest.java
@@ -27,10 +27,10 @@ import com.yahoo.vespa.config.util.ConfigUtils;
/**
* A request to get config, bound to tenant and app id. Used by both v1 and v2 of the config REST API.
*
- * @author lulf
- * @since 5.1
+ * @author Ulf Lilleengen
*/
public class HttpConfigRequest implements GetConfigRequest, TenantRequest {
+
private static final String HTTP_PROPERTY_NOCACHE = "noCache";
private final ConfigKey<?> key;
private final ApplicationId appId;
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpErrorResponse.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpErrorResponse.java
index 7e0c57f2e5f..81806a0afe7 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpErrorResponse.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpErrorResponse.java
@@ -35,6 +35,7 @@ public class HttpErrorResponse extends HttpResponse {
public enum errorCodes {
APPLICATION_LOCK_FAILURE,
BAD_REQUEST,
+ ACTIVATION_CONFLICT,
INTERNAL_SERVER_ERROR,
INVALID_APPLICATION_PACKAGE,
METHOD_NOT_ALLOWED,
@@ -64,6 +65,10 @@ public class HttpErrorResponse extends HttpResponse {
return new HttpErrorResponse(BAD_REQUEST, errorCodes.BAD_REQUEST.name(), msg);
}
+ public static HttpErrorResponse conflictWhenActivating(String msg) {
+ return new HttpErrorResponse(CONFLICT, errorCodes.ACTIVATION_CONFLICT.name(), msg);
+ }
+
public static HttpErrorResponse methodNotAllowed(String msg) {
return new HttpErrorResponse(METHOD_NOT_ALLOWED, errorCodes.METHOD_NOT_ALLOWED.name(), msg);
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpHandler.java
index 53bfbf5135f..c13d1b3fcfa 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpHandler.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpHandler.java
@@ -8,6 +8,7 @@ import com.yahoo.container.jdisc.LoggingRequestHandler;
import com.yahoo.container.logging.AccessLog;
import com.yahoo.log.LogLevel;
import com.yahoo.config.provision.OutOfCapacityException;
+import com.yahoo.vespa.config.server.ActivationConflictException;
import com.yahoo.yolean.Exceptions;
import java.io.PrintWriter;
@@ -47,6 +48,8 @@ public class HttpHandler extends LoggingRequestHandler {
}
} catch (NotFoundException | com.yahoo.vespa.config.server.NotFoundException e) {
return HttpErrorResponse.notFoundError(getMessage(e, request));
+ } catch (ActivationConflictException e) {
+ return HttpErrorResponse.conflictWhenActivating(getMessage(e, request));
} catch (BadRequestException | IllegalArgumentException | IllegalStateException e) {
return HttpErrorResponse.badRequest(getMessage(e, request));
} catch (OutOfCapacityException e) {
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/model/SuperModel.java b/configserver/src/main/java/com/yahoo/vespa/config/server/model/SuperModel.java
index 1d7bcd8d001..eb41373aab8 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/model/SuperModel.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/model/SuperModel.java
@@ -13,6 +13,7 @@ import com.yahoo.vespa.config.ConfigPayload;
import com.yahoo.vespa.config.server.application.Application;
import java.util.Collections;
+import java.util.LinkedHashMap;
import java.util.Map;
/**
@@ -26,7 +27,7 @@ public class SuperModel implements LbServicesConfig.Producer, RoutingConfig.Prod
private final Map<TenantName, Map<ApplicationId, Application>> models;
private final LbServicesProducer lbProd;
private final RoutingProducer zoneProd;
-
+
public SuperModel(Map<TenantName, Map<ApplicationId, Application>> models, Zone zone) {
this.models = models;
this.lbProd = new LbServicesProducer(Collections.unmodifiableMap(models), zone);
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelsBuilder.java b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelsBuilder.java
index 6a4ab40d843..6bd21e9cfb6 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelsBuilder.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelsBuilder.java
@@ -112,11 +112,11 @@ public abstract class ModelsBuilder<MODELRESULT extends ModelResult> {
Version latest = findLatest(versions);
// load latest application version
MODELRESULT latestModelVersion = buildModelVersion(modelFactoryRegistry.getFactory(latest),
- applicationPackage,
- applicationId,
- wantedNodeVespaVersion,
- allocatedHosts.asOptional(),
- now);
+ applicationPackage,
+ applicationId,
+ wantedNodeVespaVersion,
+ allocatedHosts.asOptional(),
+ now);
allocatedHosts.set(latestModelVersion.getModel().allocatedHosts()); // Update with additional clusters allocated
if (latestModelVersion.getModel().skipOldConfigModels(now))
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessor.java b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessor.java
index 37f8aa4ea40..5a1352de17d 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessor.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessor.java
@@ -112,7 +112,7 @@ class GetConfigProcessor implements Runnable {
} catch (UnknownConfigIdException e) {
handleError(request, ErrorCode.ILLEGAL_CONFIGID, "Illegal config id " + request.getConfigKey().getConfigId());
return;
- } catch (Exception e) {
+ } catch (Throwable e) {
log.log(Level.SEVERE, "Unexpected error handling config request", e);
handleError(request, ErrorCode.INTERNAL_ERROR, "Internal error " + e.getMessage());
return;
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java
index 1a2433ec77e..4fe78a30344 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java
@@ -187,7 +187,7 @@ public class RpcServer implements Runnable, ReloadListener, TenantListener {
* This method should be called when config is reloaded in the server.
*/
@Override
- public void configReloaded(TenantName tenant, ApplicationSet applicationSet) {
+ public void configActivated(TenantName tenant, ApplicationSet applicationSet) {
ApplicationId applicationId = applicationSet.getId();
configReloaded(delayedConfigResponses.drainQueue(applicationId), Tenants.logPre(applicationId));
reloadSuperModel(tenant, applicationSet);
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/PrepareParams.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/PrepareParams.java
index d70ed584c3d..cbcfb865acf 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/PrepareParams.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/PrepareParams.java
@@ -18,8 +18,7 @@ import java.util.Set;
/**
* Parameters for prepare. Immutable.
*
- * @author lulf
- * @since 5.1.24
+ * @author Ulf Lilleengen
*/
public final class PrepareParams {
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClient.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClient.java
index 09fc83e225d..8f056898374 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClient.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClient.java
@@ -172,7 +172,7 @@ public class SessionZooKeeperClient {
}
public Version readVespaVersion() {
- if ( ! configCurator.exists(versionPath())) return Vtag.currentVersion;
+ if ( ! configCurator.exists(versionPath())) return Vtag.currentVersion; // TODO: This should not be possible any more - verify and remove
return new Version(configCurator.getData(versionPath()));
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandler.java
index 20d1e88440f..93c26d532bb 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandler.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandler.java
@@ -2,7 +2,6 @@
package com.yahoo.vespa.config.server.tenant;
import java.time.Clock;
-import java.time.Instant;
import java.util.*;
import com.yahoo.config.provision.Version;
@@ -81,7 +80,7 @@ public class TenantRequestHandler implements RequestHandler, ReloadHandler, Host
private void notifyReloadListeners(ApplicationSet applicationSet) {
for (ReloadListener reloadListener : reloadListeners) {
reloadListener.hostsUpdated(tenant, hostRegistry.getAllHosts());
- reloadListener.configReloaded(tenant, applicationSet);
+ reloadListener.configActivated(tenant, applicationSet);
}
}
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 c09fe5ae4bb..c7a79556397 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
@@ -35,9 +35,8 @@ import java.util.concurrent.atomic.AtomicInteger;
* 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
*
- * @author vegardh
+ * @author Vegard Havdal
* @author bratseth
- * @since 5.0
*/
public class ConfigCurator {
diff --git a/configserver/src/main/resources/configserver-app/services.xml b/configserver/src/main/resources/configserver-app/services.xml
index 730f9cb3136..9330dae2e41 100644
--- a/configserver/src/main/resources/configserver-app/services.xml
+++ b/configserver/src/main/resources/configserver-app/services.xml
@@ -15,6 +15,7 @@
<component id="com.yahoo.vespa.config.server.session.FileDistributionFactory" bundle="configserver" />
<component id="com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry" bundle="configserver" />
<component id="com.yahoo.vespa.config.server.SuperModelGenerationCounter" bundle="configserver" />
+ <component id="com.yahoo.vespa.config.server.SuperModelManager" bundle="configserver" />
<component id="com.yahoo.vespa.config.server.session.SessionPreparer" bundle="configserver" />
<component id="com.yahoo.vespa.config.server.SuperModelRequestHandler" bundle="configserver" />
<component id="com.yahoo.vespa.config.server.StaticConfigDefinitionRepo" bundle="configserver" />
diff --git a/configserver/src/test/apps/serverdb/serverdefs/attributes.def b/configserver/src/test/apps/serverdb/serverdefs/attributes.def
index 7943091ae6e..89671b57046 100644
--- a/configserver/src/test/apps/serverdb/serverdefs/attributes.def
+++ b/configserver/src/test/apps/serverdb/serverdefs/attributes.def
@@ -1,5 +1,4 @@
# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-version=2
namespace=config
attribute[].name string
attribute[].datatype string
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelRequestHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelRequestHandlerTest.java
index dd19cfc29bb..4c746eba64e 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelRequestHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelRequestHandlerTest.java
@@ -34,6 +34,7 @@ import static org.junit.Assert.*;
public class SuperModelRequestHandlerTest {
private static final File testApp = new File("src/test/resources/deploy/app");
+ private SuperModelManager manager;
private SuperModelGenerationCounter counter;
private SuperModelRequestHandler controller;
@@ -43,10 +44,9 @@ public class SuperModelRequestHandlerTest {
@Before
public void setup() throws IOException {
counter = new SuperModelGenerationCounter(new MockCurator());
- controller = new SuperModelRequestHandler(counter,
- new TestConfigDefinitionRepo(),
- new ConfigserverConfig(new ConfigserverConfig.Builder()),
- emptyNodeFlavors());
+ ConfigserverConfig configserverConfig = new ConfigserverConfig(new ConfigserverConfig.Builder());
+ manager = new SuperModelManager(configserverConfig, emptyNodeFlavors(), counter);
+ controller = new SuperModelRequestHandler(new TestConfigDefinitionRepo(), configserverConfig, manager);
}
@Test
@@ -95,10 +95,9 @@ public class SuperModelRequestHandlerTest {
public void test_super_model_master_generation() throws IOException, SAXException {
TenantName tenantA = TenantName.from("a");
long masterGen = 10;
- controller = new SuperModelRequestHandler(counter,
- new TestConfigDefinitionRepo(),
- new ConfigserverConfig(new ConfigserverConfig.Builder().masterGeneration(masterGen)),
- emptyNodeFlavors());
+ ConfigserverConfig configserverConfig = new ConfigserverConfig(new ConfigserverConfig.Builder().masterGeneration(masterGen));
+ manager = new SuperModelManager(configserverConfig, emptyNodeFlavors(), counter);
+ controller = new SuperModelRequestHandler(new TestConfigDefinitionRepo(), configserverConfig, manager);
long gen = counter.increment();
controller.reloadConfig(tenantA, createApp(tenantA, "foo", 3L, 1));
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/a.def b/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/a.def
index d9791909f69..bf99c65ec14 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/a.def
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/a.def
@@ -1,5 +1,4 @@
# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-version=1
storage[].feeder[] string
search[].feeder[] string
storage[].id reference
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/b.def b/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/b.def
index 81d9f1d30bd..42e58eb4f9e 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/b.def
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/b.def
@@ -1,4 +1,3 @@
# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-version=1
gaff int default=0
usercfgwithid int
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/c.def b/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/c.def
index fb0fb64172e..3621e2eeb9a 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/c.def
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/c.def
@@ -1,4 +1,3 @@
# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-version=1
foo string
gaz int
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/compositeinclude.def b/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/compositeinclude.def
index 39d16c616e8..195acc54718 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/compositeinclude.def
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/compositeinclude.def
@@ -1,5 +1,4 @@
# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-version=1
classes[].id int
classes[].name string
classes[].fields[].name string
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/d.def b/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/d.def
index 4b65de94e36..eb19c8a95ba 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/d.def
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/d.def
@@ -1,4 +1,3 @@
# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-version=1
thestring string default="g"
theint int default=6
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/e.def b/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/e.def
index dd5ffa7ed16..20d311db6e0 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/e.def
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/e.def
@@ -1,4 +1,3 @@
# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-version=1
# this one will be implicit, no cfg
fo int default=-45
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/recursiveinclude.def b/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/recursiveinclude.def
index 0d5a81f0a63..aca6789c179 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/recursiveinclude.def
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/recursiveinclude.def
@@ -1,5 +1,4 @@
# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-version=4
rec int
ursive string
national int
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/spooler.def b/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/spooler.def
index 675d2601873..2721af7e278 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/spooler.def
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/configdefs/spooler.def
@@ -1,5 +1,4 @@
# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-version=2
# Which directory to find spool files in.
directory string default="/home/vespa/var/spool/vespa"
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 7fca78b087b..8644948706b 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
@@ -67,8 +67,12 @@ import java.time.Clock;
import java.util.Collections;
import java.util.Optional;
-import static com.yahoo.jdisc.Response.Status.*;
+import static com.yahoo.jdisc.Response.Status.BAD_REQUEST;
+import static com.yahoo.jdisc.Response.Status.CONFLICT;
+import static com.yahoo.jdisc.Response.Status.INTERNAL_SERVER_ERROR;
import static com.yahoo.jdisc.Response.Status.METHOD_NOT_ALLOWED;
+import static com.yahoo.jdisc.Response.Status.NOT_FOUND;
+import static com.yahoo.jdisc.Response.Status.OK;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
@@ -154,7 +158,7 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
ActivateRequest activateRequest = new ActivateRequest(sessionId, 1, "", Clock.systemUTC()).invoke();
HttpResponse actResponse = activateRequest.getActResponse();
String message = getRenderedString(actResponse);
- assertThat(message, actResponse.getStatus(), Is.is(BAD_REQUEST));
+ assertThat(message, actResponse.getStatus(), Is.is(CONFLICT));
assertThat(message,
containsString("Cannot activate session 3 because the currently active session (2) has changed since session 3 was created (was 1 at creation time)"));
}
@@ -178,8 +182,8 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
Clock clock = Clock.systemUTC();
activateAndAssertOK(90l, 0l, clock);
activateAndAssertError(92l, 89l, clock,
- HttpErrorResponse.errorCodes.BAD_REQUEST,
- "tenant:"+tenant+" app:default:default Cannot activate session 92 because the currently active session (90) has changed since session 92 was created (was 89 at creation time)");
+ Response.Status.CONFLICT, HttpErrorResponse.errorCodes.ACTIVATION_CONFLICT,
+ "tenant:" + tenant + " app:default:default Cannot activate session 92 because the currently active session (90) has changed since session 92 was created (was 89 at creation time)");
}
@Test
@@ -209,7 +213,7 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
public void require_that_handler_gives_error_when_provisioner_activated_fails() throws Exception {
hostProvisioner = new FailingMockProvisioner();
hostProvisioner.activated = false;
- activateAndAssertError(1, 0, Clock.systemUTC(), HttpErrorResponse.errorCodes.BAD_REQUEST, "Cannot activate application");
+ activateAndAssertError(1, 0, Clock.systemUTC(), BAD_REQUEST, HttpErrorResponse.errorCodes.BAD_REQUEST, "Cannot activate application");
assertFalse(hostProvisioner.activated);
}
@@ -249,12 +253,13 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
return activateRequest;
}
- private ActivateRequest activateAndAssertErrorPut(long sessionId, long previousSessionId, Clock clock, HttpErrorResponse.errorCodes errorCode, String expectedError) throws Exception {
+ private ActivateRequest activateAndAssertErrorPut(long sessionId, long previousSessionId, Clock clock,
+ int statusCode, HttpErrorResponse.errorCodes errorCode, String expectedError) throws Exception {
ActivateRequest activateRequest = new ActivateRequest(sessionId, previousSessionId, "", clock);
activateRequest.invoke();
HttpResponse actResponse = activateRequest.getActResponse();
RemoteSession session = activateRequest.getSession();
- assertThat(actResponse.getStatus(), Is.is(BAD_REQUEST));
+ assertThat(actResponse.getStatus(), Is.is(statusCode));
String message = getRenderedString(actResponse);
assertThat(message, Is.is("{\"error-code\":\"" + errorCode.name() + "\",\"message\":\"" + expectedError + "\"}"));
assertThat(session.getStatus(), Is.is(Session.Status.PREPARE));
@@ -353,9 +358,9 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
assertThat(hostProvisioner.lastHosts.size(), is(1));
}
- private void activateAndAssertError(long sessionId, long previousSessionId, Clock clock, HttpErrorResponse.errorCodes errorCode, String expectedError) throws Exception {
+ private void activateAndAssertError(long sessionId, long previousSessionId, Clock clock, int statusCode, HttpErrorResponse.errorCodes errorCode, String expectedError) throws Exception {
hostProvisioner.activated = false;
- activateAndAssertErrorPut(sessionId, previousSessionId, clock, errorCode, expectedError);
+ activateAndAssertErrorPut(sessionId, previousSessionId, clock, statusCode, errorCode, expectedError);
assertFalse(hostProvisioner.activated);
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/model/LbServicesProducerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/model/LbServicesProducerTest.java
index 108d54ae546..4d7f33e6ef9 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/model/LbServicesProducerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/model/LbServicesProducerTest.java
@@ -190,7 +190,7 @@ public class LbServicesProducerTest {
" </prod>" +
"</deployment>";
- return new MockApplicationPackage.Builder().withHosts(hosts).withServices(services).withDeploymentInfo(deploymentInfo).build();
+ return new MockApplicationPackage.Builder().withHosts(hosts).withServices(services).withDeploymentSpec(deploymentInfo).build();
}
private Model createVespaModel(ApplicationPackage applicationPackage, DeployState.Builder deployStateBuilder) throws IOException, SAXException {
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/model/RoutingProducerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/model/RoutingProducerTest.java
index f4fee50170f..f50dc7828b0 100755
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/model/RoutingProducerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/model/RoutingProducerTest.java
@@ -100,7 +100,7 @@ public class RoutingProducerTest {
return new MockApplicationPackage.Builder()
.withHosts(hosts)
.withServices(services)
- .withDeploymentInfo(deploymentInfo)
+ .withDeploymentSpec(deploymentInfo)
.build();
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java
index d66ddfade34..ef742ae3d38 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java
@@ -75,7 +75,7 @@ public class RpcServerTest extends TestWithRpc {
generationCounter.increment();
Application app = new Application(new VespaModel(MockApplicationPackage.createEmpty()), new ServerCache(), 2l, Version.fromIntValues(1, 2, 3), MetricUpdater.createTestUpdater(), ApplicationId.defaultId());
ApplicationSet appSet = ApplicationSet.fromSingle(app);
- rpcServer.configReloaded(TenantName.defaultName(), appSet);
+ rpcServer.configActivated(TenantName.defaultName(), appSet);
ConfigKey<?> key = new ConfigKey<>(LbServicesConfig.class, "*");
JRTClientConfigRequest clientReq = JRTClientConfigRequestV3.createFromRaw(new RawConfig(key, LbServicesConfig.CONFIG_DEF_MD5), 120_000, Trace.createDummy(), CompressionType.UNCOMPRESSED, Optional.empty());
assertTrue(clientReq.validateParameters());
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/TestWithRpc.java b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/TestWithRpc.java
index 52102e805b8..fa6adb64a8a 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/TestWithRpc.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/TestWithRpc.java
@@ -11,12 +11,9 @@ import com.yahoo.jrt.Transport;
import com.yahoo.net.HostName;
import com.yahoo.test.ManualClock;
import com.yahoo.vespa.config.GenerationCounter;
-import com.yahoo.vespa.config.server.SuperModelRequestHandler;
+import com.yahoo.vespa.config.server.*;
import com.yahoo.vespa.config.server.host.ConfigRequestHostLivenessTracker;
import com.yahoo.vespa.config.server.host.HostRegistries;
-import com.yahoo.vespa.config.server.MemoryGenerationCounter;
-import com.yahoo.vespa.config.server.PortRangeAllocator;
-import com.yahoo.vespa.config.server.TestConfigDefinitionRepo;
import com.yahoo.vespa.config.server.monitoring.Metrics;
import com.yahoo.vespa.config.server.tenant.MockTenantProvider;
import org.junit.After;
@@ -82,11 +79,14 @@ public class TestWithRpc {
}
protected void createAndStartRpcServer(boolean hostedVespa) {
+ ConfigserverConfig configserverConfig = new ConfigserverConfig(new ConfigserverConfig.Builder());
rpcServer = new RpcServer(new ConfigserverConfig(new ConfigserverConfig.Builder().rpcport(port).numthreads(1).maxgetconfigclients(1).hostedVespa(hostedVespa)),
- new SuperModelRequestHandler(generationCounter,
- new TestConfigDefinitionRepo(),
- new ConfigserverConfig(new ConfigserverConfig.Builder()),
- emptyNodeFlavors()),
+ new SuperModelRequestHandler(new TestConfigDefinitionRepo(),
+ configserverConfig,
+ new SuperModelManager(
+ configserverConfig,
+ emptyNodeFlavors(),
+ generationCounter)),
Metrics.createTestMetrics(), new HostRegistries(),
hostLivenessTracker);
rpcServer.onTenantCreate(TenantName.from("default"), tenantProvider);
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandlerTest.java
index 3b67597c43c..91cf6e79165 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandlerTest.java
@@ -242,7 +242,7 @@ public class TenantRequestHandlerTest extends TestWithCurator {
public AtomicInteger removed = new AtomicInteger(0);
public Map<String, Collection<String>> tenantHosts = new LinkedHashMap<>();
@Override
- public void configReloaded(TenantName tenant, ApplicationSet application) {
+ public void configActivated(TenantName tenant, ApplicationSet application) {
reloaded.incrementAndGet();
}
diff --git a/configserver/src/test/resources/configdefinitions/app.def b/configserver/src/test/resources/configdefinitions/app.def
index 02250339d81..7c7bb58b3a6 100644
--- a/configserver/src/test/resources/configdefinitions/app.def
+++ b/configserver/src/test/resources/configdefinitions/app.def
@@ -1,5 +1,4 @@
# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-version=1
namespace=config
message string default="Hello!"
diff --git a/configserver/src/test/resources/configdefinitions/datastructures.def b/configserver/src/test/resources/configdefinitions/datastructures.def
index 8d5582daeb4..79b3a8e77a0 100644
--- a/configserver/src/test/resources/configdefinitions/datastructures.def
+++ b/configserver/src/test/resources/configdefinitions/datastructures.def
@@ -1,5 +1,4 @@
# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-version=3
namespace=config
date[] string
diff --git a/configserver/src/test/resources/configdefinitions/function-test.def b/configserver/src/test/resources/configdefinitions/function-test.def
index da024b7fb02..b2a27c42285 100644
--- a/configserver/src/test/resources/configdefinitions/function-test.def
+++ b/configserver/src/test/resources/configdefinitions/function-test.def
@@ -18,7 +18,6 @@
# - Have an array within a struct, to verify that we correctly recurse.
# - Reuse type name further within to ensure that this works.
-version=4
namespace=config
# Some random bool without a default value. These comments exist to check
diff --git a/configserver/src/test/resources/configdefinitions/md5test.def b/configserver/src/test/resources/configdefinitions/md5test.def
index a9483f417ab..1c6eae0e587 100644
--- a/configserver/src/test/resources/configdefinitions/md5test.def
+++ b/configserver/src/test/resources/configdefinitions/md5test.def
@@ -1,9 +1,7 @@
# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-# version=4 , version in comment does not count.
# Added empty line to see if we can confuse
# the server's md5 calculation
-version=3
namespace=config
#even adding a variable name starting with 'version'
diff --git a/configserver/src/test/resources/configdefinitions/simpletypes.def b/configserver/src/test/resources/configdefinitions/simpletypes.def
index c5296e5a25e..569df41c97d 100644
--- a/configserver/src/test/resources/configdefinitions/simpletypes.def
+++ b/configserver/src/test/resources/configdefinitions/simpletypes.def
@@ -1,7 +1,6 @@
# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
# Config containing only simple leaf types with default values, that can be used
# for testing individual types in detail.
-version=1
namespace=config
boolval bool default=false
diff --git a/configserver/src/test/resources/configdefinitions/unicode.def b/configserver/src/test/resources/configdefinitions/unicode.def
index 389db0f502e..e3b93671e99 100644
--- a/configserver/src/test/resources/configdefinitions/unicode.def
+++ b/configserver/src/test/resources/configdefinitions/unicode.def
@@ -1,5 +1,4 @@
# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-version=2
namespace=config
unicodestring1 string