diff options
Diffstat (limited to 'configserver')
28 files changed, 165 insertions, 98 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java index 102a36e833f..64bc9868034 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java @@ -177,6 +177,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye /** * Creates a new deployment from the active application, if available. + * This is used for system internal redeployments, not on application package changes. * * @param application the active application to be redeployed * @return a new deployment from the local active, or empty if a local active application @@ -189,6 +190,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye /** * Creates a new deployment from the active application, if available. + * This is used for system internal redeployments, not on application package changes. * * @param application the active application to be redeployed * @param timeout the timeout to use for each individual deployment operation @@ -203,7 +205,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye LocalSession activeSession = getActiveSession(tenant, application); if (activeSession == null) return Optional.empty(); TimeoutBudget timeoutBudget = new TimeoutBudget(clock, timeout); - LocalSession newSession = tenant.getSessionFactory().createSessionFromExisting(activeSession, logger, timeoutBudget); + LocalSession newSession = tenant.getSessionFactory().createSessionFromExisting(activeSession, logger, false, timeoutBudget); tenant.getLocalSessionRepo().addSession(newSession); // Keep manually deployed tenant applications on the latest version, don't change version otherwise @@ -345,12 +347,15 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye throw new IllegalStateException("Session not prepared: " + sessionId); } - public long createSessionFromExisting(ApplicationId applicationId, DeployLogger logger, TimeoutBudget timeoutBudget) { + public long createSessionFromExisting(ApplicationId applicationId, + DeployLogger logger, + boolean internalRedeploy, + TimeoutBudget timeoutBudget) { Tenant tenant = tenantRepository.getTenant(applicationId.tenant()); LocalSessionRepo localSessionRepo = tenant.getLocalSessionRepo(); SessionFactory sessionFactory = tenant.getSessionFactory(); LocalSession fromSession = getExistingSession(tenant, applicationId); - LocalSession session = sessionFactory.createSessionFromExisting(fromSession, logger, timeoutBudget); + LocalSession session = sessionFactory.createSessionFromExisting(fromSession, logger, internalRedeploy, timeoutBudget); localSessionRepo.addSession(session); return session.getSessionId(); } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/GetConfigContext.java b/configserver/src/main/java/com/yahoo/vespa/config/server/GetConfigContext.java index ea14b9194e8..6c9b7216e59 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/GetConfigContext.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/GetConfigContext.java @@ -9,8 +9,7 @@ import com.yahoo.vespa.config.server.tenant.TenantRepository; /** * Contains the context for serving getconfig requests so that this information does not have to be looked up multiple times. * - * @author lulf - * @since 5.8 + * @author Ulf Lilleengen */ public class GetConfigContext { 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 8e865f96db3..f723ca2fe91 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 @@ -51,7 +51,7 @@ public class SuperModelController { ConfigKey<?> configKey = request.getConfigKey(); InnerCNode targetDef = getConfigDefinition(request.getConfigKey(), request.getDefContent()); ConfigPayload payload = model.getConfig(configKey); - return responseFactory.createResponse(payload, targetDef, generation); + return responseFactory.createResponse(payload, targetDef, generation, false); } private InnerCNode getConfigDefinition(ConfigKey<?> configKey, DefContent defContent) { diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/Application.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/Application.java index a73fc95eb05..64123420622 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/Application.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/Application.java @@ -32,23 +32,26 @@ import java.util.Set; * a Vespa application, i.e. generation, model and zookeeper data, as well as methods for resolving config * and other queries against the model. * - * @author Harald Musum + * @author hmusum */ public class Application implements ModelResult { private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(Application.class.getName()); private final long appGeneration; // The generation of the set of configs belonging to an application + private final boolean internalRedeploy; private final Version vespaVersion; private final Model model; private final ServerCache cache; private final MetricUpdater metricUpdater; private final ApplicationId app; - public Application(Model model, ServerCache cache, long appGeneration, Version vespaVersion, MetricUpdater metricUpdater, ApplicationId app) { + public Application(Model model, ServerCache cache, long appGeneration, boolean internalRedeploy, + Version vespaVersion, MetricUpdater metricUpdater, ApplicationId app) { Objects.requireNonNull(model, "The model cannot be null"); this.model = model; this.cache = cache; this.appGeneration = appGeneration; + this.internalRedeploy = internalRedeploy; this.vespaVersion = vespaVersion; this.metricUpdater = metricUpdater; this.app = app; @@ -106,7 +109,7 @@ public class Application implements ModelResult { debug("Resolving config " + cacheKey); } - if (!req.noCache()) { + if ( ! req.noCache()) { ConfigResponse config = cache.get(cacheKey); if (config != null) { if (logDebug()) { @@ -131,9 +134,9 @@ public class Application implements ModelResult { throw new ConfigurationRuntimeException("Unable to resolve config " + configKey); } - ConfigResponse configResponse = responseFactory.createResponse(payload, def.getCNode(), appGeneration); + ConfigResponse configResponse = responseFactory.createResponse(payload, def.getCNode(), appGeneration, internalRedeploy); metricUpdater.incrementProcTime(System.currentTimeMillis() - start); - if (!req.noCache()) { + if ( ! req.noCache()) { cache.put(cacheKey, configResponse, configResponse.getConfigMd5()); metricUpdater.setCacheConfigElems(cache.configElems()); metricUpdater.setCacheChecksumElems(cache.checkSumElems()); diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandler.java index 74c85829ef2..26ef79ebe02 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandler.java @@ -58,7 +58,7 @@ public class SessionCreateHandler extends SessionHandler { long sessionId; if (request.hasProperty("from")) { ApplicationId applicationId = getFromApplicationId(request); - sessionId = applicationRepository.createSessionFromExisting(applicationId, logger, timeoutBudget); + sessionId = applicationRepository.createSessionFromExisting(applicationId, logger, false, timeoutBudget); } else { validateDataAndHeader(request); String name = getNameProperty(request, logger); diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java index 9d583d27341..d83548dcc3d 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java @@ -88,7 +88,9 @@ public class ActivatedModelsBuilder extends ModelsBuilder<Application> { new com.yahoo.component.Version(modelFactory.getVersion().toString()), wantedNodeVespaVersion); MetricUpdater applicationMetricUpdater = metrics.getOrCreateMetricUpdater(Metrics.createDimensions(applicationId)); - return new Application(modelFactory.createModel(modelContext), cache, appGeneration, modelFactory.getVersion(), + return new Application(modelFactory.createModel(modelContext), cache, appGeneration, + applicationPackage.getMetaData().isInternalRedeploy(), + modelFactory.getVersion(), applicationMetricUpdater, applicationId); } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/ConfigResponseFactory.java b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/ConfigResponseFactory.java index 07e07fa2595..247ae388639 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/ConfigResponseFactory.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/ConfigResponseFactory.java @@ -9,17 +9,19 @@ import com.yahoo.vespa.config.protocol.ConfigResponse; * Represents a component that creates config responses from a payload. Different implementations * can do transformations of the payload such as compression. * - * @author lulf - * @since 5.19 + * @author Ulf Lilleengen */ public interface ConfigResponseFactory { /** * Create a {@link ConfigResponse} for a given payload and generation. + * * @param payload The {@link com.yahoo.vespa.config.ConfigPayload} to put in the response. * @param defFile The {@link com.yahoo.config.codegen.InnerCNode} def file for this config. * @param generation The payload generation. @return A {@link ConfigResponse} that can be sent to the client. + * @param internalRedeployment whether this config generation was produced by an internal redeployment, + * not a change to the application package */ - ConfigResponse createResponse(ConfigPayload payload, InnerCNode defFile, long generation); + ConfigResponse createResponse(ConfigPayload payload, InnerCNode defFile, long generation, boolean internalRedeployment); } 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 b37d013cc6b..d93537d539a 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 @@ -22,7 +22,6 @@ import java.util.logging.Logger; /** * @author hmusum -* @since 5.1 */ class GetConfigProcessor implements Runnable { @@ -30,8 +29,9 @@ class GetConfigProcessor implements Runnable { private static final String localHostName = HostName.getLocalhost(); private final JRTServerConfigRequest request; + /* True only when this request has expired its server timeout and we need to respond to the client */ - private boolean forceResponse = false; + private final boolean forceResponse; private final RpcServer rpcServer; private String logPre = ""; @@ -64,7 +64,7 @@ class GetConfigProcessor implements Runnable { // TODO: Increment statistics (Metrics) failed counters when requests fail public void run() { //Request has already been detached - if (!request.validateParameters()) { + if ( ! request.validateParameters()) { // Error code is set in verifyParameters if parameters are not OK. log.log(LogLevel.WARNING, "Parameters for request " + request + " did not validate: " + request.errorCode() + " : " + request.errorMessage()); respond(request); @@ -121,7 +121,7 @@ class GetConfigProcessor implements Runnable { // config == null is not an error, but indicates that the config will be returned later. if ((config != null) && (!config.hasEqualConfig(request) || config.hasNewerGeneration(request) || forceResponse)) { // debugLog(trace, "config response before encoding:" + config.toString()); - request.addOkResponse(request.payloadFromResponse(config), config.getGeneration(), config.getConfigMd5()); + request.addOkResponse(request.payloadFromResponse(config), config.getGeneration(), config.isInternalRedeploy(), config.getConfigMd5()); if (logDebug(trace)) { debugLog(trace, "return response: " + request.getShortDescription()); } @@ -147,7 +147,7 @@ class GetConfigProcessor implements Runnable { ConfigPayload emptyPayload = ConfigPayload.empty(); String configMd5 = ConfigUtils.getMd5(emptyPayload); ConfigResponse config = SlimeConfigResponse.fromConfigPayload(emptyPayload, null, 0, configMd5); - request.addOkResponse(request.payloadFromResponse(config), config.getGeneration(), config.getConfigMd5()); + request.addOkResponse(request.payloadFromResponse(config), config.getGeneration(), false, config.getConfigMd5()); respond(request); } @@ -161,4 +161,5 @@ class GetConfigProcessor implements Runnable { trace.trace(RpcServer.TRACELEVEL_DEBUG, logPre + message); } } + } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/LZ4ConfigResponseFactory.java b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/LZ4ConfigResponseFactory.java index 609f1d5f79f..ff15eb7bfa7 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/LZ4ConfigResponseFactory.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/LZ4ConfigResponseFactory.java @@ -14,19 +14,22 @@ import com.yahoo.vespa.config.util.ConfigUtils; /** * Compressor that compresses config payloads to lz4. * - * @author lulf - * @since 5.19 + * @author Ulf Lilleengen */ public class LZ4ConfigResponseFactory implements ConfigResponseFactory { private static LZ4PayloadCompressor compressor = new LZ4PayloadCompressor(); @Override - public ConfigResponse createResponse(ConfigPayload payload, InnerCNode defFile, long generation) { + public ConfigResponse createResponse(ConfigPayload payload, + InnerCNode defFile, + long generation, + boolean internalRedeployment) { Utf8Array rawPayload = payload.toUtf8Array(true); String configMd5 = ConfigUtils.getMd5(rawPayload); CompressionInfo info = CompressionInfo.create(CompressionType.LZ4, rawPayload.getByteLength()); Utf8Array compressed = new Utf8Array(compressor.compress(rawPayload.getBytes())); - return new SlimeConfigResponse(compressed, defFile, generation, configMd5, info); + return new SlimeConfigResponse(compressed, defFile, generation, internalRedeployment, configMd5, info); } + } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/UncompressedConfigResponseFactory.java b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/UncompressedConfigResponseFactory.java index ac3cfa2fda1..995e981e0f3 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/UncompressedConfigResponseFactory.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/UncompressedConfigResponseFactory.java @@ -13,17 +13,19 @@ import com.yahoo.vespa.config.util.ConfigUtils; /** * Simply returns an uncompressed payload. * - * @author lulf - * @since 5.19 + * @author Ulf Lilleengen */ public class UncompressedConfigResponseFactory implements ConfigResponseFactory { @Override - public ConfigResponse createResponse(ConfigPayload payload, InnerCNode defFile, long generation) { + public ConfigResponse createResponse(ConfigPayload payload, + InnerCNode defFile, + long generation, + boolean internalRedeployment) { Utf8Array rawPayload = payload.toUtf8Array(true); String configMd5 = ConfigUtils.getMd5(rawPayload); CompressionInfo info = CompressionInfo.create(CompressionType.UNCOMPRESSED, rawPayload.getByteLength()); - return new SlimeConfigResponse(rawPayload, defFile, generation, configMd5, info); + return new SlimeConfigResponse(rawPayload, defFile, generation, internalRedeployment, configMd5, info); } } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/Session.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/Session.java index 653df81f296..3978a1f25f8 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/Session.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/Session.java @@ -9,8 +9,7 @@ import com.yahoo.vespa.config.server.tenant.TenantRepository; * class represents the common stuff between sessions working on the local file * system ({@link LocalSession}s) and sessions working on zookeeper {@link RemoteSession}s. * - * @author lulf - * @since 5.1 + * @author Ulf Lilleengen */ public abstract class Session { diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactory.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactory.java index bd9da36a2ba..a3dea83d50c 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactory.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactory.java @@ -10,7 +10,7 @@ import java.io.File; /** * A session factory responsible for creating deploy sessions. * - * @author lulf + * @author Ulf Lilleengen */ public interface SessionFactory { @@ -31,9 +31,11 @@ public interface SessionFactory { * * @param existingSession The session to use as base * @param logger a deploy logger where the deploy log will be written. + * @param internalRedeploy if this session is for a system internal redeploy not an application package change * @param timeoutBudget Timeout for creating session and waiting for other servers. * @return a new session */ - LocalSession createSessionFromExisting(LocalSession existingSession, DeployLogger logger, TimeoutBudget timeoutBudget); + LocalSession createSessionFromExisting(LocalSession existingSession, DeployLogger logger, + boolean internalRedeploy, TimeoutBudget timeoutBudget); } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactoryImpl.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactoryImpl.java index 7285ff905ff..10590a26690 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactoryImpl.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactoryImpl.java @@ -74,9 +74,12 @@ public class SessionFactoryImpl implements SessionFactory, LocalSessionLoader { this.clock = globalComponentRegistry.getClock(); } + /** Create a session for a true application package change */ @Override - public LocalSession createSession(File applicationFile, ApplicationId applicationId, TimeoutBudget timeoutBudget) { - return create(applicationFile, applicationId, nonExistingActiveSession, timeoutBudget); + public LocalSession createSession(File applicationFile, + ApplicationId applicationId, + TimeoutBudget timeoutBudget) { + return create(applicationFile, applicationId, nonExistingActiveSession, false, timeoutBudget); } private void ensureZKPathDoesNotExist(Path sessionPath) { @@ -89,13 +92,14 @@ public class SessionFactoryImpl implements SessionFactory, LocalSessionLoader { File configApplicationDir, String applicationName, long sessionId, - long currentlyActiveSession) { + long currentlyActiveSession, + boolean internalRedeploy) { long deployTimestamp = System.currentTimeMillis(); String user = System.getenv("USER"); if (user == null) { user = "unknown"; } - DeployData deployData = new DeployData(user, userDir.getAbsolutePath(), applicationName, deployTimestamp, sessionId, currentlyActiveSession); + DeployData deployData = new DeployData(user, userDir.getAbsolutePath(), applicationName, deployTimestamp, internalRedeploy, sessionId, currentlyActiveSession); return FilesApplicationPackage.fromFileWithDeployData(configApplicationDir, deployData); } @@ -119,19 +123,21 @@ public class SessionFactoryImpl implements SessionFactory, LocalSessionLoader { @Override public LocalSession createSessionFromExisting(LocalSession existingSession, DeployLogger logger, + boolean internalRedeploy, TimeoutBudget timeoutBudget) { File existingApp = getSessionAppDir(existingSession.getSessionId()); ApplicationId existingApplicationId = existingSession.getApplicationId(); long liveApp = getLiveApp(existingApplicationId); logger.log(LogLevel.DEBUG, "Create from existing application id " + existingApplicationId + ", live app for it is " + liveApp); - LocalSession session = create(existingApp, existingApplicationId, liveApp, timeoutBudget); + LocalSession session = create(existingApp, existingApplicationId, liveApp, internalRedeploy, timeoutBudget); session.setApplicationId(existingApplicationId); session.setVespaVersion(existingSession.getVespaVersion()); return session; } - private LocalSession create(File applicationFile, ApplicationId applicationId, long currentlyActiveSession, TimeoutBudget timeoutBudget) { + private LocalSession create(File applicationFile, ApplicationId applicationId, long currentlyActiveSession, + boolean internalRedeploy, TimeoutBudget timeoutBudget) { long sessionId = sessionCounter.nextSessionId(); Path sessionIdPath = sessionsPath.append(String.valueOf(sessionId)); log.log(LogLevel.DEBUG, TenantRepository.logPre(tenant) + "Next session id is " + sessionId + " , sessionIdPath=" + sessionIdPath.getAbsolute()); @@ -145,8 +151,12 @@ public class SessionFactoryImpl implements SessionFactory, LocalSessionLoader { nodeFlavors); File userApplicationDir = tenantFileSystemDirs.getUserApplicationDir(sessionId); IOUtils.copyDirectory(applicationFile, userApplicationDir); - ApplicationPackage applicationPackage = createApplication(applicationFile, userApplicationDir, - applicationId.application().value(), sessionId, currentlyActiveSession); + ApplicationPackage applicationPackage = createApplication(applicationFile, + userApplicationDir, + applicationId.application().value(), + sessionId, + currentlyActiveSession, + internalRedeploy); applicationPackage.writeMetaData(); return createSessionFromApplication(applicationPackage, sessionId, sessionZooKeeperClient, timeoutBudget, clock); } catch (Exception e) { 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 bc07ac7d79c..2b72db63d55 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 @@ -122,12 +122,11 @@ public class SuperModelRequestHandlerTest { } private static class TestApplication extends Application { - private long version = 0; public TestApplication(VespaModel vespaModel, ServerCache cache, long appGeneration, ApplicationId app, long version) { - super(vespaModel, cache, appGeneration, Version.fromIntValues(1, 2, 3), MetricUpdater.createTestUpdater(), app); - this.version = version; + super(vespaModel, cache, appGeneration, false, Version.fromIntValues(1, 2, 3), MetricUpdater.createTestUpdater(), app); } + } public static NodeFlavors emptyNodeFlavors() { diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationConvergenceCheckerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationConvergenceCheckerTest.java index 1d692e8f78f..3c3edae7914 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationConvergenceCheckerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationConvergenceCheckerTest.java @@ -28,7 +28,7 @@ import static org.junit.Assert.assertThat; import static com.yahoo.vespa.config.server.application.ApplicationConvergenceChecker.ServiceResponse; /** - * @author lulf + * @author Ulf Lilleengen */ public class ApplicationConvergenceCheckerTest { @@ -43,7 +43,12 @@ public class ApplicationConvergenceCheckerTest { @Before public void setup() { Model mockModel = MockModel.createContainer("localhost", 1337); - application = new Application(mockModel, new ServerCache(), 3, Version.fromIntValues(0, 0, 0), MetricUpdater.createTestUpdater(), appId); + application = new Application(mockModel, + new ServerCache(), + 3, + false, + Version.fromIntValues(0, 0, 0), + MetricUpdater.createTestUpdater(), appId); } @Test diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationMapperTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationMapperTest.java index a83f2676a4d..233c0e99ed8 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationMapperTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationMapperTest.java @@ -31,9 +31,9 @@ public class ApplicationMapperTest { vespaVersions.add(Version.fromString("1.2.3")); vespaVersions.add(Version.fromString("1.2.4")); vespaVersions.add(Version.fromString("1.2.5")); - applications.add(new Application(new ModelStub(), null, 0, vespaVersions.get(0), MetricUpdater.createTestUpdater(), ApplicationId.defaultId())); - applications.add(new Application(new ModelStub(), null, 0, vespaVersions.get(1), MetricUpdater.createTestUpdater(), ApplicationId.defaultId())); - applications.add(new Application(new ModelStub(), null, 0, vespaVersions.get(2), MetricUpdater.createTestUpdater(), ApplicationId.defaultId())); + applications.add(new Application(new ModelStub(), null, 0, false, vespaVersions.get(0), MetricUpdater.createTestUpdater(), ApplicationId.defaultId())); + applications.add(new Application(new ModelStub(), null, 0, false, vespaVersions.get(1), MetricUpdater.createTestUpdater(), ApplicationId.defaultId())); + applications.add(new Application(new ModelStub(), null, 0, false, vespaVersions.get(2), MetricUpdater.createTestUpdater(), ApplicationId.defaultId())); } @Test diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationSetTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationSetTest.java index 98bedb76599..94bb81021dc 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationSetTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationSetTest.java @@ -29,9 +29,9 @@ public class ApplicationSetTest { vespaVersions.add(Version.fromString("1.2.3")); vespaVersions.add(Version.fromString("1.2.4")); vespaVersions.add(Version.fromString("1.2.5")); - applications.add(new Application(new ModelStub(), null, 0, vespaVersions.get(0), MetricUpdater.createTestUpdater(), ApplicationId.defaultId())); - applications.add(new Application(new ModelStub(), null, 0, vespaVersions.get(1), MetricUpdater.createTestUpdater(), ApplicationId.defaultId())); - applications.add(new Application(new ModelStub(), null, 0, vespaVersions.get(2), MetricUpdater.createTestUpdater(), ApplicationId.defaultId())); + applications.add(new Application(new ModelStub(), null, 0, false, vespaVersions.get(0), MetricUpdater.createTestUpdater(), ApplicationId.defaultId())); + applications.add(new Application(new ModelStub(), null, 0, false, vespaVersions.get(1), MetricUpdater.createTestUpdater(), ApplicationId.defaultId())); + applications.add(new Application(new ModelStub(), null, 0, false, vespaVersions.get(2), MetricUpdater.createTestUpdater(), ApplicationId.defaultId())); } @Test diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationTest.java index 02cf6303ba8..90a27c39736 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationTest.java @@ -42,8 +42,7 @@ import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; /** - * @author lulf - * @since 5.1.14 + * @author Ulf Lilleengen */ public class ApplicationTest { @@ -53,7 +52,7 @@ public class ApplicationTest { ApplicationName.from("foobar"), InstanceName.defaultName()); ServerCache cache = new ServerCache(); Version vespaVersion = Version.fromIntValues(1, 2, 3); - Application app = new Application(new ModelStub(), cache, 1337, vespaVersion, MetricUpdater.createTestUpdater(), appId); + Application app = new Application(new ModelStub(), cache, 1337L, false, vespaVersion, MetricUpdater.createTestUpdater(), appId); assertThat(app.getApplicationGeneration(), is(1337l)); assertNotNull(app.getModel()); assertThat(app.getCache(), is(cache)); @@ -71,24 +70,24 @@ public class ApplicationTest { File testApp = new File("src/test/apps/app"); ServerCache cache = createCacheAndAddContent(); VespaModel model = new VespaModel(FilesApplicationPackage.fromFile(testApp)); - final ApplicationId applicationId = new ApplicationId.Builder().tenant("foo").applicationName("foo").build(); - handler = new Application(model, cache, 1, Version.fromIntValues(1, 2, 3), + ApplicationId applicationId = new ApplicationId.Builder().tenant("foo").applicationName("foo").build(); + handler = new Application(model, cache, 1L, false, Version.fromIntValues(1, 2, 3), new MetricUpdater(Metrics.createTestMetrics(), Metrics.createDimensions(applicationId)), applicationId); } private static ServerCache createCacheAndAddContent() { ServerCache cache = new ServerCache(); - final ConfigDefinitionKey key = new ConfigDefinitionKey(SimpletypesConfig.CONFIG_DEF_NAME, SimpletypesConfig.CONFIG_DEF_NAMESPACE); + ConfigDefinitionKey key = new ConfigDefinitionKey(SimpletypesConfig.CONFIG_DEF_NAME, SimpletypesConfig.CONFIG_DEF_NAMESPACE); com.yahoo.vespa.config.buildergen.ConfigDefinition def = getDef(key, SimpletypesConfig.CONFIG_DEF_SCHEMA); // TODO Why do we have to use empty def md5 here? cache.addDef(key, def); - final ConfigDefinitionKey key2 = new ConfigDefinitionKey(SlobroksConfig.CONFIG_DEF_NAME, SlobroksConfig.CONFIG_DEF_NAMESPACE); + ConfigDefinitionKey key2 = new ConfigDefinitionKey(SlobroksConfig.CONFIG_DEF_NAME, SlobroksConfig.CONFIG_DEF_NAMESPACE); com.yahoo.vespa.config.buildergen.ConfigDefinition def2 = getDef(key2, SlobroksConfig.CONFIG_DEF_SCHEMA); cache.addDef(key2, def2); - final ConfigDefinitionKey key3 = new ConfigDefinitionKey(LogdConfig.CONFIG_DEF_NAME, LogdConfig.CONFIG_DEF_NAMESPACE); + ConfigDefinitionKey key3 = new ConfigDefinitionKey(LogdConfig.CONFIG_DEF_NAME, LogdConfig.CONFIG_DEF_NAMESPACE); com.yahoo.vespa.config.buildergen.ConfigDefinition def3 = getDef(key3, LogdConfig.CONFIG_DEF_SCHEMA); cache.addDef(key3, def3); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/FileDistributionStatusTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/FileDistributionStatusTest.java index 76204d5c5f2..c2ddec7e795 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/FileDistributionStatusTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/FileDistributionStatusTest.java @@ -161,7 +161,13 @@ public class FileDistributionStatusTest { private Application createApplication(List<String> hostnames) { Model mockModel = MockModel.createConfigProxies(hostnames, 1337); - return new Application(mockModel, new ServerCache(), 3, Version.fromIntValues(0, 0, 0), MetricUpdater.createTestUpdater(), appId); + return new Application(mockModel, + new ServerCache(), + 3, + false, + Version.fromIntValues(0, 0, 0), + MetricUpdater.createTestUpdater(), + appId); } HttpResponse getStatus(FileDistributionStatus fileDistributionStatus, Application application) { 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 bf7f7038c1a..8074dd35267 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 @@ -43,7 +43,14 @@ public class ZooKeeperClientTest extends TestWithCurator { public void setupZK() throws IOException { this.zk = ConfigCurator.create(curator); ZooKeeperClient zkc = new ZooKeeperClient(zk, new BaseDeployLogger(), true, Path.fromString(appPath)); - ApplicationPackage app = FilesApplicationPackage.fromFileWithDeployData(new File("src/test/apps/zkfeed"), new DeployData("foo", "/bar/baz", "appName", 1345l, 3l, 2l)); + ApplicationPackage app = FilesApplicationPackage.fromFileWithDeployData(new File("src/test/apps/zkfeed"), + new DeployData("foo", + "/bar/baz", + "appName", + 1345L, + false, + 3L, + 2L)); Map<Version, FileRegistry> fileRegistries = createFileRegistries(); app.writeMetaData(); zkc.setupZooKeeper(); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionHandlerTest.java index 930ae98c9e9..eb5dc7a2abf 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionHandlerTest.java @@ -191,7 +191,8 @@ public class SessionHandlerTest { public String applicationName; @Override - public LocalSession createSession(File applicationDirectory, ApplicationId applicationId, TimeoutBudget timeoutBudget) { + public LocalSession createSession(File applicationDirectory, ApplicationId applicationId, + TimeoutBudget timeoutBudget) { createCalled = true; this.applicationName = applicationId.application().value(); if (doThrow) { @@ -208,7 +209,8 @@ public class SessionHandlerTest { } @Override - public LocalSession createSessionFromExisting(LocalSession existingSession, DeployLogger logger, TimeoutBudget timeoutBudget) { + public LocalSession createSessionFromExisting(LocalSession existingSession, DeployLogger logger, + boolean internalRedeploy, TimeoutBudget timeoutBudget) { if (doThrow) { throw new RuntimeException("foo"); } 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 e14e59b9fe7..2a05688c435 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 @@ -280,7 +280,13 @@ public class SessionActiveHandlerTest extends SessionHandlerTest { ActivateRequest(long sessionId, long previousSessionId, Session.Status initialStatus, String subPath, Clock clock) { this.sessionId = sessionId; this.initialStatus = initialStatus; - this.deployData = new DeployData("foo", "bar", appName, 0l, sessionId, previousSessionId); + this.deployData = new DeployData("foo", + "bar", + appName, + 0l, + false, + sessionId, + previousSessionId); this.subPath = subPath; this.clock = clock; } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/ConfigResponseFactoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/ConfigResponseFactoryTest.java index 9193c2409c7..7c1d5fa8dbc 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/ConfigResponseFactoryTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/ConfigResponseFactoryTest.java @@ -13,38 +13,38 @@ import org.junit.Test; import java.io.StringReader; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; /** - * @author lulf - * @since 5.19 + * @author Ulf Lilleengen */ public class ConfigResponseFactoryTest { - private InnerCNode def; + private InnerCNode def; @Before public void setup() { - DefParser dParser = new DefParser(SimpletypesConfig.getDefName(), new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n"))); + DefParser dParser = new DefParser(SimpletypesConfig.getDefName(), + new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n"))); def = dParser.getTree(); } @Test public void testUncompressedFacory() { UncompressedConfigResponseFactory responseFactory = new UncompressedConfigResponseFactory(); - ConfigResponse response = responseFactory.createResponse(ConfigPayload.empty(), def, 3); - assertThat(response.getCompressionInfo().getCompressionType(), is(CompressionType.UNCOMPRESSED)); - assertThat(response.getGeneration(), is(3l)); - assertThat(response.getPayload().getByteLength(), is(2)); + ConfigResponse response = responseFactory.createResponse(ConfigPayload.empty(), def, 3, false); + assertEquals(CompressionType.UNCOMPRESSED, response.getCompressionInfo().getCompressionType()); + assertEquals(3L,response.getGeneration()); + assertEquals(2, response.getPayload().getByteLength()); } @Test public void testLZ4CompressedFacory() { LZ4ConfigResponseFactory responseFactory = new LZ4ConfigResponseFactory(); - ConfigResponse response = responseFactory.createResponse(ConfigPayload.empty(), def, 3); - assertThat(response.getCompressionInfo().getCompressionType(), is(CompressionType.LZ4)); - assertThat(response.getGeneration(), is(3l)); - assertThat(response.getPayload().getByteLength(), is(3)); + ConfigResponse response = responseFactory.createResponse(ConfigPayload.empty(), def, 3, false); + assertEquals(CompressionType.LZ4, response.getCompressionInfo().getCompressionType()); + assertEquals(3L, response.getGeneration()); + assertEquals(3, response.getPayload().getByteLength()); } + } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessorTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessorTest.java index 578224833a1..50c39b74fa2 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessorTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessorTest.java @@ -104,6 +104,9 @@ public class GetConfigProcessorTest { } @Override + public boolean isInternalRedeploy() { return false; } + + @Override public String getConfigMd5() { return "mymd5"; } 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 ef742ae3d38..6bb566963c0 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 @@ -73,7 +73,13 @@ public class RpcServerTest extends TestWithRpc { private void testEnabled() throws IOException, SAXException { generationCounter.increment(); - Application app = new Application(new VespaModel(MockApplicationPackage.createEmpty()), new ServerCache(), 2l, Version.fromIntValues(1, 2, 3), MetricUpdater.createTestUpdater(), ApplicationId.defaultId()); + Application app = new Application(new VespaModel(MockApplicationPackage.createEmpty()), + new ServerCache(), + 2L, + false, + Version.fromIntValues(1, 2, 3), + MetricUpdater.createTestUpdater(), + ApplicationId.defaultId()); ApplicationSet appSet = ApplicationSet.fromSingle(app); rpcServer.configActivated(TenantName.defaultName(), appSet); ConfigKey<?> key = new ConfigKey<>(LbServicesConfig.class, "*"); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionFactoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionFactoryTest.java index 531a2e3745b..0ca487cfb67 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionFactoryTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionFactoryTest.java @@ -31,8 +31,7 @@ import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; /** - * @author lulf - * @since 5.1 + * @author Ulf Lilleengen */ public class SessionFactoryTest extends TestWithTenant { private SessionFactory factory; @@ -64,10 +63,13 @@ public class SessionFactoryTest extends TestWithTenant { public void require_that_session_can_be_created_from_existing() throws IOException { LocalSession session = getLocalSession(); assertNotNull(session); - assertThat(session.getSessionId(), is(2l)); - LocalSession session2 = factory.createSessionFromExisting(session, new BaseDeployLogger(), TimeoutBudgetTest.day()); + assertThat(session.getSessionId(), is(2L)); + LocalSession session2 = factory.createSessionFromExisting(session, + new BaseDeployLogger(), + false, + TimeoutBudgetTest.day()); assertNotNull(session2); - assertThat(session2.getSessionId(), is(3l)); + assertThat(session2.getSessionId(), is(3L)); } @Test(expected = RuntimeException.class) diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java index 9a4b0b05186..f47ed69ad14 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java @@ -65,8 +65,13 @@ public class TenantRepositoryTest extends TestWithCurator { @Test public void testListenersAdded() throws IOException, SAXException { tenantRepository.getTenant(tenant1).getReloadHandler().reloadConfig(ApplicationSet.fromSingle( - new Application(new VespaModel(MockApplicationPackage.createEmpty()), new ServerCache(), 4l, - Version.fromIntValues(1, 2, 3), MetricUpdater.createTestUpdater(), ApplicationId.defaultId()))); + new Application(new VespaModel(MockApplicationPackage.createEmpty()), + new ServerCache(), + 4L, + false, + Version.fromIntValues(1, 2, 3), + MetricUpdater.createTestUpdater(), + ApplicationId.defaultId()))); assertThat(listener.reloaded.get(), is(1)); } 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 ef320f0f084..27ae0945b4a 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 @@ -54,8 +54,7 @@ import static org.hamcrest.core.Is.is; import static org.junit.Assert.*; /** - * @author lulf - * @since 5.1 + * @author Ulf Lilleengen */ public class TenantRequestHandlerTest extends TestWithCurator { @@ -263,7 +262,8 @@ public class TenantRequestHandlerTest extends TestWithCurator { public void testHasApplication() throws IOException, SAXException { assertdefaultAppNotFound(); server.reloadConfig(reloadConfig(1l, Clock.systemUTC())); - assertTrue(server.hasApplication(new ApplicationId.Builder().applicationName(ApplicationName.defaultName()).tenant(tenant).build(), Optional.of(vespaVersion))); + assertTrue(server.hasApplication(new ApplicationId.Builder().applicationName(ApplicationName.defaultName()).tenant(tenant).build(), + Optional.of(vespaVersion))); } private void assertdefaultAppNotFound() { @@ -286,18 +286,17 @@ public class TenantRequestHandlerTest extends TestWithCurator { @Test public void testListConfigs() throws IOException, SAXException { assertdefaultAppNotFound(); - /*assertTrue(server.allConfigIds(ApplicationId.defaultId()).isEmpty()); - assertTrue(server.allConfigsProduced(ApplicationId.defaultId()).isEmpty()); - assertTrue(server.listConfigs(ApplicationId.defaultId(), false).isEmpty()); - assertTrue(server.listConfigs(ApplicationId.defaultId(), true).isEmpty());*/ VespaModel model = new VespaModel(FilesApplicationPackage.fromFile(new File("src/test/apps/app"))); - server.reloadConfig(ApplicationSet.fromSingle(new Application(model, new ServerCache(), 1, vespaVersion, MetricUpdater.createTestUpdater(), ApplicationId.defaultId()))); + server.reloadConfig(ApplicationSet.fromSingle(new Application(model, + new ServerCache(), + 1, + false, + vespaVersion, + MetricUpdater.createTestUpdater(), + ApplicationId.defaultId()))); Set<ConfigKey<?>> configNames = server.listConfigs(ApplicationId.defaultId(), Optional.of(vespaVersion), false); assertTrue(configNames.contains(new ConfigKey<>("sentinel", "hosts", "cloud.config"))); - //for (ConfigKey<?> ck : configNames) { - // assertTrue(!"".equals(ck.getConfigId())); - //} configNames = server.listConfigs(ApplicationId.defaultId(), Optional.of(vespaVersion), true); System.out.println(configNames); |