Search in sources :

Example 1 with SessionZooKeeperClient

use of com.yahoo.vespa.config.server.session.SessionZooKeeperClient 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 SessionZooKeeperClient

use of com.yahoo.vespa.config.server.session.SessionZooKeeperClient in project vespa by vespa-engine.

the class TenantRequestHandlerTest method reloadConfig.

private ApplicationSet reloadConfig(long id, String application, Clock clock) {
    SessionZooKeeperClient zkc = new SessionZooKeeperClient(curator, configCurator, Tenants.getSessionsPath(tenant).append(String.valueOf(id)), new TestConfigDefinitionRepo(), "", Optional.empty());
    zkc.writeApplicationId(new ApplicationId.Builder().tenant(tenant).applicationName(application).build());
    RemoteSession session = new RemoteSession(tenant, id, componentRegistry, zkc, clock);
    return session.ensureApplicationLoaded();
}
Also used : TestConfigDefinitionRepo(com.yahoo.vespa.config.server.TestConfigDefinitionRepo) RemoteSession(com.yahoo.vespa.config.server.session.RemoteSession) SessionZooKeeperClient(com.yahoo.vespa.config.server.session.SessionZooKeeperClient)

Example 3 with SessionZooKeeperClient

use of com.yahoo.vespa.config.server.session.SessionZooKeeperClient in project vespa by vespa-engine.

the class SessionActiveHandlerTest method createRemoteSession.

private RemoteSession createRemoteSession(long sessionId, Session.Status status, SessionZooKeeperClient zkClient, Clock clock) throws IOException {
    zkClient.writeStatus(status);
    ZooKeeperClient zkC = new ZooKeeperClient(configCurator, new BaseDeployLogger(), false, Tenants.getSessionsPath(tenant).append(String.valueOf(sessionId)));
    zkC.write(Collections.singletonMap(modelFactory.getVersion(), new MockFileRegistry()));
    zkC.write(AllocatedHosts.withHosts(Collections.emptySet()));
    RemoteSession session = new RemoteSession(TenantName.from("default"), sessionId, componentRegistry, zkClient, clock);
    remoteSessionRepo.addSession(session);
    return session;
}
Also used : ZooKeeperClient(com.yahoo.vespa.config.server.deploy.ZooKeeperClient) SessionZooKeeperClient(com.yahoo.vespa.config.server.session.SessionZooKeeperClient) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) RemoteSession(com.yahoo.vespa.config.server.session.RemoteSession) MockFileRegistry(com.yahoo.config.model.application.provider.MockFileRegistry)

Example 4 with SessionZooKeeperClient

use of com.yahoo.vespa.config.server.session.SessionZooKeeperClient in project vespa by vespa-engine.

the class TenantRequestHandlerTest method feedAndReloadApp.

private void feedAndReloadApp(File appDir, long sessionId, ApplicationId appId) throws IOException {
    feedApp(appDir, sessionId, appId);
    SessionZooKeeperClient zkc = new SessionZooKeeperClient(curator, Tenants.getSessionsPath(tenant).append(String.valueOf(sessionId)));
    zkc.writeApplicationId(appId);
    RemoteSession session = new RemoteSession(tenant, sessionId, componentRegistry, zkc, Clock.systemUTC());
    server.reloadConfig(session.ensureApplicationLoaded());
}
Also used : RemoteSession(com.yahoo.vespa.config.server.session.RemoteSession) SessionZooKeeperClient(com.yahoo.vespa.config.server.session.SessionZooKeeperClient)

Example 5 with SessionZooKeeperClient

use of com.yahoo.vespa.config.server.session.SessionZooKeeperClient in project vespa by vespa-engine.

the class TenantRequestHandlerTest method feedApp.

private void feedApp(File appDir, long sessionId, ApplicationId appId) throws IOException {
    SessionZooKeeperClient zkc = new SessionZooKeeperClient(curator, configCurator, Tenants.getSessionsPath(tenant).append(String.valueOf(sessionId)), new TestConfigDefinitionRepo(), "", Optional.empty());
    zkc.writeApplicationId(appId);
    File app = tempFolder.newFolder();
    IOUtils.copyDirectory(appDir, app);
    ZooKeeperDeployer deployer = zkc.createDeployer(new BaseDeployLogger());
    deployer.deploy(FilesApplicationPackage.fromFile(appDir), Collections.singletonMap(vespaVersion, new MockFileRegistry()), AllocatedHosts.withHosts(Collections.emptySet()));
}
Also used : BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) ZooKeeperDeployer(com.yahoo.vespa.config.server.deploy.ZooKeeperDeployer) TestConfigDefinitionRepo(com.yahoo.vespa.config.server.TestConfigDefinitionRepo) File(java.io.File) MockFileRegistry(com.yahoo.config.model.application.provider.MockFileRegistry) SessionZooKeeperClient(com.yahoo.vespa.config.server.session.SessionZooKeeperClient)

Aggregations

SessionZooKeeperClient (com.yahoo.vespa.config.server.session.SessionZooKeeperClient)6 RemoteSession (com.yahoo.vespa.config.server.session.RemoteSession)5 TestConfigDefinitionRepo (com.yahoo.vespa.config.server.TestConfigDefinitionRepo)3 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)2 MockFileRegistry (com.yahoo.config.model.application.provider.MockFileRegistry)2 File (java.io.File)2 SimpletypesConfig (com.yahoo.config.SimpletypesConfig)1 ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)1 NullConfigModelRegistry (com.yahoo.config.model.NullConfigModelRegistry)1 FilesApplicationPackage (com.yahoo.config.model.application.provider.FilesApplicationPackage)1 ApplicationId (com.yahoo.config.provision.ApplicationId)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 TestComponentRegistry (com.yahoo.vespa.config.server.TestComponentRegistry)1 ZooKeeperClient (com.yahoo.vespa.config.server.deploy.ZooKeeperClient)1 ZooKeeperDeployer (com.yahoo.vespa.config.server.deploy.ZooKeeperDeployer)1 ModelFactoryRegistry (com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry)1 LocalSession (com.yahoo.vespa.config.server.session.LocalSession)1