Search in sources :

Example 1 with VespaModelFactory

use of com.yahoo.vespa.model.VespaModelFactory 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 2 with VespaModelFactory

use of com.yahoo.vespa.model.VespaModelFactory 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)

Example 3 with VespaModelFactory

use of com.yahoo.vespa.model.VespaModelFactory in project vespa by vespa-engine.

the class InjectedGlobalComponentRegistryTest method setupRegistry.

@Before
public void setupRegistry() {
    curator = new MockCurator();
    ConfigCurator configCurator = ConfigCurator.create(curator);
    metrics = Metrics.createTestMetrics();
    modelFactoryRegistry = new ModelFactoryRegistry(Collections.singletonList(new VespaModelFactory(new NullConfigModelRegistry())));
    configserverConfig = new ConfigserverConfig(new ConfigserverConfig.Builder().configServerDBDir(Files.createTempDir().getAbsolutePath()).configDefinitionsDir(Files.createTempDir().getAbsolutePath()));
    serverDB = new ConfigServerDB(configserverConfig);
    sessionPreparer = new SessionTest.MockSessionPreparer();
    rpcServer = new RpcServer(configserverConfig, null, Metrics.createTestMetrics(), new HostRegistries(), new ConfigRequestHostLivenessTracker(), new FileServer(FileDistribution.getDefaultFileDBPath()));
    generationCounter = new SuperModelGenerationCounter(curator);
    defRepo = new StaticConfigDefinitionRepo();
    permanentApplicationPackage = new PermanentApplicationPackage(configserverConfig);
    hostRegistries = new HostRegistries();
    HostProvisionerProvider hostProvisionerProvider = HostProvisionerProvider.withProvisioner(new SessionHandlerTest.MockProvisioner());
    zone = Zone.defaultZone();
    globalComponentRegistry = new InjectedGlobalComponentRegistry(curator, configCurator, metrics, modelFactoryRegistry, serverDB, sessionPreparer, rpcServer, configserverConfig, generationCounter, defRepo, permanentApplicationPackage, hostRegistries, hostProvisionerProvider, zone);
}
Also used : ConfigserverConfig(com.yahoo.cloud.config.ConfigserverConfig) HostRegistries(com.yahoo.vespa.config.server.host.HostRegistries) HostProvisionerProvider(com.yahoo.vespa.config.server.provision.HostProvisionerProvider) ModelFactoryRegistry(com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry) ConfigRequestHostLivenessTracker(com.yahoo.vespa.config.server.host.ConfigRequestHostLivenessTracker) VespaModelFactory(com.yahoo.vespa.model.VespaModelFactory) NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) ConfigCurator(com.yahoo.vespa.config.server.zookeeper.ConfigCurator) SessionHandlerTest(com.yahoo.vespa.config.server.http.SessionHandlerTest) RpcServer(com.yahoo.vespa.config.server.rpc.RpcServer) PermanentApplicationPackage(com.yahoo.vespa.config.server.application.PermanentApplicationPackage) FileServer(com.yahoo.vespa.config.server.filedistribution.FileServer) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Before(org.junit.Before)

Example 4 with VespaModelFactory

use of com.yahoo.vespa.model.VespaModelFactory in project vespa by vespa-engine.

the class SessionActiveHandlerTest method setup.

@Before
public void setup() throws Exception {
    remoteSessionRepo = new RemoteSessionRepo(tenant);
    applicationRepo = new MemoryTenantApplications();
    curator = new MockCurator();
    configCurator = ConfigCurator.create(curator);
    localRepo = new LocalSessionRepo(Clock.systemUTC());
    pathPrefix = "/application/v2/tenant/" + tenant + "/session/";
    hostProvisioner = new MockProvisioner();
    modelFactory = new VespaModelFactory(new NullConfigModelRegistry());
    componentRegistry = new TestComponentRegistry.Builder().curator(curator).configCurator(configCurator).modelFactoryRegistry(new ModelFactoryRegistry(Collections.singletonList(modelFactory))).build();
}
Also used : VespaModelFactory(com.yahoo.vespa.model.VespaModelFactory) RemoteSessionRepo(com.yahoo.vespa.config.server.session.RemoteSessionRepo) NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) MemoryTenantApplications(com.yahoo.vespa.config.server.application.MemoryTenantApplications) LocalSessionRepo(com.yahoo.vespa.config.server.session.LocalSessionRepo) TestComponentRegistry(com.yahoo.vespa.config.server.TestComponentRegistry) ModelFactoryRegistry(com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Before(org.junit.Before)

Example 5 with VespaModelFactory

use of com.yahoo.vespa.model.VespaModelFactory in project vespa by vespa-engine.

the class RemoteSessionTest method require_that_applications_are_loaded.

@Test
public void require_that_applications_are_loaded() throws IOException, SAXException {
    RemoteSession session = createSession(3, Arrays.asList(new MockModelFactory(), new VespaModelFactory(new NullConfigModelRegistry())), Clock.systemUTC());
    session.loadPrepared();
    ApplicationSet applicationSet = session.ensureApplicationLoaded();
    assertNotNull(applicationSet);
    assertThat(applicationSet.getApplicationGeneration(), is(3l));
    assertThat(applicationSet.getForVersionOrLatest(Optional.empty(), Instant.now()).getId().application().value(), is("foo"));
    assertNotNull(applicationSet.getForVersionOrLatest(Optional.empty(), Instant.now()).getModel());
    session.deactivate();
    applicationSet = session.ensureApplicationLoaded();
    assertNotNull(applicationSet);
    assertThat(applicationSet.getApplicationGeneration(), is(3l));
    assertThat(applicationSet.getForVersionOrLatest(Optional.empty(), Instant.now()).getId().application().value(), is("foo"));
    assertNotNull(applicationSet.getForVersionOrLatest(Optional.empty(), Instant.now()).getModel());
}
Also used : VespaModelFactory(com.yahoo.vespa.model.VespaModelFactory) NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) ApplicationSet(com.yahoo.vespa.config.server.application.ApplicationSet) Test(org.junit.Test)

Aggregations

NullConfigModelRegistry (com.yahoo.config.model.NullConfigModelRegistry)5 VespaModelFactory (com.yahoo.vespa.model.VespaModelFactory)5 ModelFactoryRegistry (com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry)4 TestComponentRegistry (com.yahoo.vespa.config.server.TestComponentRegistry)3 MockCurator (com.yahoo.vespa.curator.mock.MockCurator)3 ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)2 FilesApplicationPackage (com.yahoo.config.model.application.provider.FilesApplicationPackage)2 SessionHandlerTest (com.yahoo.vespa.config.server.http.SessionHandlerTest)2 RemoteSession (com.yahoo.vespa.config.server.session.RemoteSession)2 Before (org.junit.Before)2 ConfigserverConfig (com.yahoo.cloud.config.ConfigserverConfig)1 TenantName (com.yahoo.config.provision.TenantName)1 Path (com.yahoo.path.Path)1 GlobalComponentRegistry (com.yahoo.vespa.config.server.GlobalComponentRegistry)1 SuperModelGenerationCounter (com.yahoo.vespa.config.server.SuperModelGenerationCounter)1 ApplicationSet (com.yahoo.vespa.config.server.application.ApplicationSet)1 MemoryTenantApplications (com.yahoo.vespa.config.server.application.MemoryTenantApplications)1 PermanentApplicationPackage (com.yahoo.vespa.config.server.application.PermanentApplicationPackage)1 FileServer (com.yahoo.vespa.config.server.filedistribution.FileServer)1 ConfigRequestHostLivenessTracker (com.yahoo.vespa.config.server.host.ConfigRequestHostLivenessTracker)1