Search in sources :

Example 11 with ApplicationPackage

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

the class VespaModelTestCase method testDeployLogger.

@Test
public void testDeployLogger() throws IOException, SAXException {
    final String services = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "<services  version=\"1.0\">" + "<config name=\"unknsownfoo\">" + "<logserver><host>foo</host></logserver>" + "</config>" + "<admin  version=\"2.0\">" + "  <adminserver hostalias=\"node0\" />" + "</admin>" + "</services>";
    MyLogger logger = new MyLogger();
    final DeployState.Builder builder = new DeployState.Builder();
    builder.modelHostProvisioner(new HostsXmlProvisioner(new StringReader(simpleHosts)));
    ApplicationPackage app = new MockApplicationPackage.Builder().withHosts(simpleHosts).withServices(services).build();
    DeployState deployState = builder.deployLogger(logger).applicationPackage(app).build(true);
    VespaModel model = new VespaModel(new NullConfigModelRegistry(), deployState);
    Validation.validate(model, true, deployState);
    assertFalse(logger.msgs.isEmpty());
}
Also used : HostsXmlProvisioner(com.yahoo.config.model.provision.HostsXmlProvisioner) NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) DeployState(com.yahoo.config.model.deploy.DeployState) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) VespaModel(com.yahoo.vespa.model.VespaModel) StringReader(java.io.StringReader) FilesApplicationPackage(com.yahoo.config.model.application.provider.FilesApplicationPackage) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) Test(org.junit.Test)

Example 12 with ApplicationPackage

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

the class VespaModelTester method createModel.

/**
 * Creates a model using the hosts already added to this
 *
 * @param services the services xml string
 * @param failOnOutOfCapacity whether we should get an exception when not enough hosts of the requested flavor
 *        is available or if we should just silently receive a smaller allocation
 * @return the resulting model
 */
public VespaModel createModel(String services, boolean failOnOutOfCapacity, int startIndexForClusters, String... retiredHostNames) {
    VespaModelCreatorWithMockPkg modelCreatorWithMockPkg = new VespaModelCreatorWithMockPkg(null, services, ApplicationPackageUtils.generateSearchDefinition("type1"));
    ApplicationPackage appPkg = modelCreatorWithMockPkg.appPkg;
    HostProvisioner provisioner = hosted ? new InMemoryProvisioner(hostsByFlavor, failOnOutOfCapacity, startIndexForClusters, retiredHostNames) : new SingleNodeProvisioner();
    DeployProperties properties = new DeployProperties.Builder().hostedVespa(hosted).applicationId(applicationId).build();
    DeployState deployState = new DeployState.Builder().applicationPackage(appPkg).modelHostProvisioner(provisioner).properties(properties).build(true);
    return modelCreatorWithMockPkg.create(false, deployState, configModelRegistry);
}
Also used : SingleNodeProvisioner(com.yahoo.config.model.provision.SingleNodeProvisioner) VespaModelCreatorWithMockPkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg) DeployState(com.yahoo.config.model.deploy.DeployState) InMemoryProvisioner(com.yahoo.config.model.provision.InMemoryProvisioner) DeployProperties(com.yahoo.config.model.deploy.DeployProperties) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) HostProvisioner(com.yahoo.config.model.api.HostProvisioner)

Example 13 with ApplicationPackage

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

the class SessionFactoryImpl method create.

private LocalSession create(File applicationFile, String applicationName, long currentlyActiveSession, TimeoutBudget timeoutBudget) {
    long sessionId = sessionCounter.nextSessionId();
    Path sessionIdPath = sessionsPath.append(String.valueOf(sessionId));
    log.log(LogLevel.DEBUG, Tenants.logPre(tenant) + "Next session id is " + sessionId + " , sessionIdPath=" + sessionIdPath.getAbsolute());
    try {
        ensureZKPathDoesNotExist(sessionIdPath);
        SessionZooKeeperClient sessionZooKeeperClient = new SessionZooKeeperClient(curator, configCurator, sessionIdPath, defRepo, serverId, nodeFlavors);
        File userApplicationDir = tenantFileSystemDirs.getUserApplicationDir(sessionId);
        IOUtils.copyDirectory(applicationFile, userApplicationDir);
        ApplicationPackage applicationPackage = createApplication(applicationFile, userApplicationDir, applicationName, sessionId, currentlyActiveSession);
        applicationPackage.writeMetaData();
        return createSessionFromApplication(applicationPackage, sessionId, sessionZooKeeperClient, timeoutBudget, clock);
    } catch (Exception e) {
        throw new RuntimeException("Error creating session " + sessionIdPath, e);
    }
}
Also used : Path(com.yahoo.path.Path) File(java.io.File) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage)

Example 14 with ApplicationPackage

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

the class ApplicationHandlerTest method addApplication.

private static Tenants addApplication(ApplicationId applicationId, long sessionId) throws Exception {
    // This method is a good illustration of the spaghetti wiring resulting from no design
    // TODO: When this setup looks sane we have refactored sufficiently that there is a design
    TenantName tenantName = applicationId.tenant();
    Path tenantPath = Tenants.getTenantPath(tenantName);
    Path sessionPath = tenantPath.append(Tenant.SESSIONS).append(String.valueOf(sessionId));
    MockCurator curator = new MockCurator();
    GlobalComponentRegistry componentRegistry = new TestComponentRegistry.Builder().curator(curator).modelFactoryRegistry(new ModelFactoryRegistry(Collections.singletonList(new VespaModelFactory(new NullConfigModelRegistry())))).build();
    // Creates the application path element in zk
    Tenants tenants = new Tenants(componentRegistry);
    tenants.addTenant(tenantName);
    Tenant tenant = tenants.getTenant(tenantName);
    tenant.getApplicationRepo().createPutApplicationTransaction(applicationId, sessionId).commit();
    ApplicationPackage app = FilesApplicationPackage.fromFile(testApp);
    SessionZooKeeperClient sessionClient = new SessionZooKeeperClient(curator, sessionPath);
    SessionContext context = new SessionContext(app, sessionClient, new File("/serverDb"), tenant.getApplicationRepo(), null, new SuperModelGenerationCounter(curator));
    tenant.getLocalSessionRepo().addSession(new LocalSession(tenantName, sessionId, null, context));
    // TODO: Instead, use ApplicationRepository to deploy the application
    sessionClient.writeApplicationId(applicationId);
    tenant.getRemoteSessionRepo().addSession(new RemoteSession(tenantName, sessionId, componentRegistry, sessionClient, Clock.systemUTC()));
    return tenants;
}
Also used : Path(com.yahoo.path.Path) TenantName(com.yahoo.config.provision.TenantName) ModelFactoryRegistry(com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry) LocalSession(com.yahoo.vespa.config.server.session.LocalSession) Tenants(com.yahoo.vespa.config.server.tenant.Tenants) GlobalComponentRegistry(com.yahoo.vespa.config.server.GlobalComponentRegistry) FilesApplicationPackage(com.yahoo.config.model.application.provider.FilesApplicationPackage) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) VespaModelFactory(com.yahoo.vespa.model.VespaModelFactory) NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) Tenant(com.yahoo.vespa.config.server.tenant.Tenant) TestComponentRegistry(com.yahoo.vespa.config.server.TestComponentRegistry) RemoteSession(com.yahoo.vespa.config.server.session.RemoteSession) SessionContext(com.yahoo.vespa.config.server.session.SessionContext) SuperModelGenerationCounter(com.yahoo.vespa.config.server.SuperModelGenerationCounter) File(java.io.File) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) SessionZooKeeperClient(com.yahoo.vespa.config.server.session.SessionZooKeeperClient)

Example 15 with ApplicationPackage

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

the class ApplicationHandlerTest method addMockApplication.

static void addMockApplication(Tenant tenant, ApplicationId applicationId, long sessionId, Clock clock) {
    tenant.getApplicationRepo().createPutApplicationTransaction(applicationId, sessionId).commit();
    ApplicationPackage app = FilesApplicationPackage.fromFile(testApp);
    tenant.getLocalSessionRepo().addSession(new SessionHandlerTest.MockSession(sessionId, app, applicationId));
    TestComponentRegistry componentRegistry = new TestComponentRegistry.Builder().modelFactoryRegistry(new ModelFactoryRegistry(Collections.singletonList(new VespaModelFactory(new NullConfigModelRegistry())))).build();
    tenant.getRemoteSessionRepo().addSession(new RemoteSession(tenant.getName(), sessionId, componentRegistry, new MockSessionZKClient(app), clock));
}
Also used : VespaModelFactory(com.yahoo.vespa.model.VespaModelFactory) MockSessionZKClient(com.yahoo.vespa.config.server.session.MockSessionZKClient) NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) SessionHandlerTest(com.yahoo.vespa.config.server.http.SessionHandlerTest) TestComponentRegistry(com.yahoo.vespa.config.server.TestComponentRegistry) ModelFactoryRegistry(com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry) RemoteSession(com.yahoo.vespa.config.server.session.RemoteSession) FilesApplicationPackage(com.yahoo.config.model.application.provider.FilesApplicationPackage) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage)

Aggregations

ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)39 MockApplicationPackage (com.yahoo.config.model.test.MockApplicationPackage)25 Test (org.junit.Test)21 VespaModel (com.yahoo.vespa.model.VespaModel)14 FilesApplicationPackage (com.yahoo.config.model.application.provider.FilesApplicationPackage)13 DeployState (com.yahoo.config.model.deploy.DeployState)12 File (java.io.File)11 NullConfigModelRegistry (com.yahoo.config.model.NullConfigModelRegistry)10 DeployProperties (com.yahoo.config.model.deploy.DeployProperties)8 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)7 InMemoryProvisioner (com.yahoo.config.model.provision.InMemoryProvisioner)6 Matchers.containsString (org.hamcrest.Matchers.containsString)5 VespaModelCreatorWithMockPkg (com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg)4 TestDriver (com.yahoo.config.model.test.TestDriver)3 Path (com.yahoo.path.Path)3 DeployLogger (com.yahoo.config.application.api.DeployLogger)2 MockRoot (com.yahoo.config.model.test.MockRoot)2 Zone (com.yahoo.config.provision.Zone)2 ConfigDefinition (com.yahoo.vespa.config.ConfigDefinition)2 ConfigDefinitionKey (com.yahoo.vespa.config.ConfigDefinitionKey)2