Search in sources :

Example 1 with DeployLogger

use of com.yahoo.config.application.api.DeployLogger in project vespa by vespa-engine.

the class ApplicationRepository method prepare.

public PrepareResult prepare(Tenant tenant, long sessionId, PrepareParams prepareParams, Instant now) {
    validateThatLocalSessionIsNotActive(tenant, sessionId);
    LocalSession session = getLocalSession(tenant, sessionId);
    ApplicationId applicationId = prepareParams.getApplicationId();
    Optional<ApplicationSet> currentActiveApplicationSet = getCurrentActiveApplicationSet(tenant, applicationId);
    Slime deployLog = createDeployLog();
    DeployLogger logger = new DeployHandlerLogger(deployLog.get().setArray("log"), prepareParams.isVerbose(), applicationId);
    ConfigChangeActions actions = session.prepare(logger, prepareParams, currentActiveApplicationSet, tenant.getPath(), now);
    logConfigChangeActions(actions, logger);
    log.log(LogLevel.INFO, Tenants.logPre(applicationId) + "Session " + sessionId + " prepared successfully. ");
    return new PrepareResult(sessionId, actions, deployLog);
}
Also used : PrepareResult(com.yahoo.vespa.config.server.http.v2.PrepareResult) LocalSession(com.yahoo.vespa.config.server.session.LocalSession) ConfigChangeActions(com.yahoo.vespa.config.server.configchange.ConfigChangeActions) DeployHandlerLogger(com.yahoo.vespa.config.server.deploy.DeployHandlerLogger) DeployLogger(com.yahoo.config.application.api.DeployLogger) SilentDeployLogger(com.yahoo.vespa.config.server.session.SilentDeployLogger) ApplicationId(com.yahoo.config.provision.ApplicationId) ApplicationSet(com.yahoo.vespa.config.server.application.ApplicationSet) Slime(com.yahoo.slime.Slime)

Example 2 with DeployLogger

use of com.yahoo.config.application.api.DeployLogger in project vespa by vespa-engine.

the class ApplicationApiHandler method handlePOST.

@Override
protected HttpResponse handlePOST(HttpRequest request) {
    Tenant tenant = getExistingTenant(request);
    TenantName tenantName = tenant.getName();
    TimeoutBudget timeoutBudget = SessionHandler.getTimeoutBudget(request, zookeeperBarrierTimeout);
    PrepareParams prepareParams = PrepareParams.fromHttpRequest(request, tenantName, zookeeperBarrierTimeout);
    Slime deployLog = createDeployLog();
    DeployLogger logger = SessionCreateHandler.createLogger(request, deployLog, tenantName);
    String name = SessionCreateHandler.getNameProperty(request, logger);
    SessionCreateHandler.validateDataAndHeader(request);
    PrepareResult result = applicationRepository.createSessionAndPrepareAndActivate(tenant, request.getData(), request.getHeader(contentTypeHeader), timeoutBudget, name, prepareParams, shouldIgnoreLockFailure(request), shouldIgnoreSessionStaleFailure(request), Instant.now());
    return new SessionPrepareAndActivateResponse(result, tenantName, request, prepareParams.getApplicationId(), zone);
}
Also used : Tenant(com.yahoo.vespa.config.server.tenant.Tenant) TenantName(com.yahoo.config.provision.TenantName) TimeoutBudget(com.yahoo.vespa.config.server.TimeoutBudget) DeployLogger(com.yahoo.config.application.api.DeployLogger) Slime(com.yahoo.slime.Slime) PrepareParams(com.yahoo.vespa.config.server.session.PrepareParams)

Example 3 with DeployLogger

use of com.yahoo.config.application.api.DeployLogger in project vespa by vespa-engine.

the class SessionCreateHandler method handlePOST.

@Override
protected HttpResponse handlePOST(HttpRequest request) {
    Slime deployLog = createDeployLog();
    final TenantName tenantName = Utils.getTenantNameFromSessionRequest(request);
    Utils.checkThatTenantExists(tenants, tenantName);
    Tenant tenant = tenants.getTenant(tenantName);
    TimeoutBudget timeoutBudget = SessionHandler.getTimeoutBudget(request, zookeeperBarrierTimeout);
    DeployLogger logger = createLogger(request, deployLog, tenantName);
    long sessionId;
    if (request.hasProperty("from")) {
        ApplicationId applicationId = getFromApplicationId(request);
        sessionId = applicationRepository.createSessionFromExisting(tenant, logger, timeoutBudget, applicationId);
    } else {
        validateDataAndHeader(request);
        String name = getNameProperty(request, logger);
        sessionId = applicationRepository.createSession(tenant, timeoutBudget, request.getData(), request.getHeader(ApplicationApiHandler.contentTypeHeader), name);
    }
    return createResponse(request, tenantName, deployLog, sessionId);
}
Also used : Tenant(com.yahoo.vespa.config.server.tenant.Tenant) TenantName(com.yahoo.config.provision.TenantName) TimeoutBudget(com.yahoo.vespa.config.server.TimeoutBudget) DeployLogger(com.yahoo.config.application.api.DeployLogger) Slime(com.yahoo.slime.Slime) ApplicationId(com.yahoo.config.provision.ApplicationId)

Example 4 with DeployLogger

use of com.yahoo.config.application.api.DeployLogger in project vespa by vespa-engine.

the class SessionPreparerTest method require_no_warning_for_overlapping_host_for_same_appid.

@Test
public void require_no_warning_for_overlapping_host_for_same_appid() throws IOException {
    SessionContext ctx = getContext(getApplicationPackage(testApp));
    ((HostRegistry<ApplicationId>) ctx.getHostValidator()).update(applicationId("default"), Collections.singletonList("mytesthost"));
    final StringBuilder logged = new StringBuilder();
    DeployLogger logger = (level, message) -> {
        System.out.println(level + ": " + message);
        if (level.equals(LogLevel.WARNING) && message.contains("The host mytesthost is already in use"))
            logged.append("ok");
    };
    preparer.prepare(ctx, logger, new PrepareParams.Builder().build(), Optional.empty(), tenantPath, Instant.now());
    assertEquals(logged.toString(), "");
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) java.util(java.util) InstanceName(com.yahoo.config.provision.InstanceName) ApplicationName(com.yahoo.config.provision.ApplicationName) ApplicationId(com.yahoo.config.provision.ApplicationId) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) Slime(com.yahoo.slime.Slime) ConfigCurator(com.yahoo.vespa.config.server.zookeeper.ConfigCurator) IOUtils(com.yahoo.io.IOUtils) InvalidApplicationException(com.yahoo.vespa.config.server.http.InvalidApplicationException) DeployLogger(com.yahoo.config.application.api.DeployLogger) TenantName(com.yahoo.config.provision.TenantName) TestModelFactory(com.yahoo.vespa.config.server.model.TestModelFactory) Path(com.yahoo.path.Path) Rotations(com.yahoo.vespa.config.server.tenant.Rotations) LogLevel(com.yahoo.log.LogLevel) HostRegistry(com.yahoo.vespa.config.server.host.HostRegistry) Before(org.junit.Before) Rotation(com.yahoo.config.provision.Rotation) ConfigChangeAction(com.yahoo.config.model.api.ConfigChangeAction) ImmutableSet(com.google.common.collect.ImmutableSet) ModelContext(com.yahoo.config.model.api.ModelContext) MemoryTenantApplications(com.yahoo.vespa.config.server.application.MemoryTenantApplications) Test(org.junit.Test) IOException(java.io.IOException) Instant(java.time.Instant) com.yahoo.config.model.application.provider(com.yahoo.config.model.application.provider) File(java.io.File) RestartActions(com.yahoo.vespa.config.server.configchange.RestartActions) Rule(org.junit.Rule) PermanentApplicationPackage(com.yahoo.vespa.config.server.application.PermanentApplicationPackage) ModelFactoryRegistry(com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry) Matchers.contains(org.hamcrest.Matchers.contains) HostProvisionerProvider(com.yahoo.vespa.config.server.provision.HostProvisionerProvider) SAXException(org.xml.sax.SAXException) ModelCreateResult(com.yahoo.config.model.api.ModelCreateResult) Version(com.yahoo.config.provision.Version) com.yahoo.vespa.config.server(com.yahoo.vespa.config.server) DeployHandlerLogger(com.yahoo.vespa.config.server.deploy.DeployHandlerLogger) Assert(org.junit.Assert) TemporaryFolder(org.junit.rules.TemporaryFolder) ServiceInfo(com.yahoo.config.model.api.ServiceInfo) MockRestartAction(com.yahoo.vespa.config.server.configchange.MockRestartAction) HostRegistry(com.yahoo.vespa.config.server.host.HostRegistry) DeployLogger(com.yahoo.config.application.api.DeployLogger) Test(org.junit.Test)

Example 5 with DeployLogger

use of com.yahoo.config.application.api.DeployLogger in project vespa by vespa-engine.

the class DeployHandlerLoggerTest method testLogging.

private void testLogging(boolean verbose, String expectedPattern) throws IOException {
    Slime slime = new Slime();
    Cursor array = slime.setArray();
    DeployLogger logger = new DeployHandlerLogger(array, verbose, new ApplicationId.Builder().tenant("testtenant").applicationName("testapp").build());
    logMessages(logger);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    new JsonFormat(true).encode(baos, slime);
    assertTrue(Pattern.matches(expectedPattern, baos.toString()));
}
Also used : JsonFormat(com.yahoo.slime.JsonFormat) DeployHandlerLogger(com.yahoo.vespa.config.server.deploy.DeployHandlerLogger) DeployLogger(com.yahoo.config.application.api.DeployLogger) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Slime(com.yahoo.slime.Slime) Cursor(com.yahoo.slime.Cursor)

Aggregations

DeployLogger (com.yahoo.config.application.api.DeployLogger)8 Slime (com.yahoo.slime.Slime)5 ApplicationId (com.yahoo.config.provision.ApplicationId)3 TenantName (com.yahoo.config.provision.TenantName)3 DeployHandlerLogger (com.yahoo.vespa.config.server.deploy.DeployHandlerLogger)3 ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)2 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)2 TimeoutBudget (com.yahoo.vespa.config.server.TimeoutBudget)2 Tenant (com.yahoo.vespa.config.server.tenant.Tenant)2 Test (org.junit.Test)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 ConfigChangeAction (com.yahoo.config.model.api.ConfigChangeAction)1 ModelContext (com.yahoo.config.model.api.ModelContext)1 ModelCreateResult (com.yahoo.config.model.api.ModelCreateResult)1 ServiceInfo (com.yahoo.config.model.api.ServiceInfo)1 com.yahoo.config.model.application.provider (com.yahoo.config.model.application.provider)1 FilesApplicationPackage (com.yahoo.config.model.application.provider.FilesApplicationPackage)1 DeployState (com.yahoo.config.model.deploy.DeployState)1 AbstractConfigProducer (com.yahoo.config.model.producer.AbstractConfigProducer)1 MockApplicationPackage (com.yahoo.config.model.test.MockApplicationPackage)1