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);
}
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);
}
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);
}
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(), "");
}
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()));
}
Aggregations