Search in sources :

Example 6 with Path

use of com.yahoo.path.Path 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 7 with Path

use of com.yahoo.path.Path in project vespa by vespa-engine.

the class ZooKeeperClientTest method testFeedComponentsFileReferencesToZooKeeper.

// TODO: Evaluate if we want this or not
@Test
@Ignore
public void testFeedComponentsFileReferencesToZooKeeper() throws IOException {
    final String appDir = "src/test/apps/app_sdbundles";
    ConfigCurator zk = ConfigCurator.create(new MockCurator());
    BaseDeployLogger logger = new BaseDeployLogger();
    Path app = Path.fromString("/1");
    ZooKeeperClient zooKeeperClient = new ZooKeeperClient(zk, logger, true, app);
    zooKeeperClient.setupZooKeeper();
    String currentAppPath = app.getAbsolute();
    assertTrue(zk.exists(currentAppPath, ConfigCurator.USERAPP_ZK_SUBPATH.replaceFirst("/", "")));
    assertTrue(zk.exists(currentAppPath + ConfigCurator.USERAPP_ZK_SUBPATH, "components"));
    assertTrue(zk.exists(currentAppPath + ConfigCurator.USERAPP_ZK_SUBPATH + "/components", "testbundle.jar"));
    assertTrue(zk.exists(currentAppPath + ConfigCurator.USERAPP_ZK_SUBPATH + "/components", "testbundle2.jar"));
    String data = zk.getData(currentAppPath + ConfigCurator.USERAPP_ZK_SUBPATH + "/components", "testbundle2.jar");
    assertThat(data, is(new File(appDir + "/components/testbundle2.jar").getAbsolutePath()));
}
Also used : Path(com.yahoo.path.Path) ConfigCurator(com.yahoo.vespa.config.server.zookeeper.ConfigCurator) File(java.io.File) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 8 with Path

use of com.yahoo.path.Path in project vespa by vespa-engine.

the class RemoteSessionRepoTest method createSession.

private void createSession(long sessionId, boolean wait, TenantName tenantName) {
    Path sessionsPath = Tenants.getSessionsPath(tenantName);
    SessionZooKeeperClient zkc = new SessionZooKeeperClient(curator, sessionsPath.append(String.valueOf(sessionId)));
    zkc.createNewSession(System.currentTimeMillis(), TimeUnit.MILLISECONDS);
    if (wait) {
        Curator.CompletionWaiter waiter = zkc.getUploadWaiter();
        waiter.awaitCompletion(Duration.ofSeconds(120));
    }
}
Also used : Path(com.yahoo.path.Path) ConfigCurator(com.yahoo.vespa.config.server.zookeeper.ConfigCurator) Curator(com.yahoo.vespa.curator.Curator) TestWithCurator(com.yahoo.vespa.config.server.TestWithCurator)

Example 9 with Path

use of com.yahoo.path.Path in project vespa by vespa-engine.

the class RemoteSessionRepoTest method assertStatusChange.

private void assertStatusChange(long sessionId, Session.Status status) throws Exception {
    Path statePath = Tenants.getSessionsPath(tenantName).append("" + sessionId).append(ConfigCurator.SESSIONSTATE_ZK_SUBPATH);
    curator.create(statePath);
    curatorFramework.setData().forPath(statePath.getAbsolute(), Utf8.toBytes(status.toString()));
    System.out.println("Setting status " + status + " for " + sessionId);
    assertSessionStatus(sessionId, status);
}
Also used : Path(com.yahoo.path.Path)

Example 10 with Path

use of com.yahoo.path.Path in project vespa by vespa-engine.

the class CuratorCompletionWaiter method createAndInitialize.

public static Curator.CompletionWaiter createAndInitialize(Curator curator, Path parentPath, String waiterNode, int numMembers, String id) {
    Path waiterPath = parentPath.append(waiterNode);
    curator.delete(waiterPath);
    curator.createAtomically(parentPath, waiterPath);
    return new CuratorCompletionWaiter(numMembers, curator.framework(), waiterPath.getAbsolute(), id, Clock.systemUTC());
}
Also used : Path(com.yahoo.path.Path)

Aggregations

Path (com.yahoo.path.Path)32 Test (org.junit.Test)10 ApplicationFile (com.yahoo.config.application.api.ApplicationFile)4 ConfigCurator (com.yahoo.vespa.config.server.zookeeper.ConfigCurator)4 File (java.io.File)4 ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)3 Node (com.yahoo.vespa.curator.mock.MemoryFileSystem.Node)3 MockCurator (com.yahoo.vespa.curator.mock.MockCurator)3 KeeperException (org.apache.zookeeper.KeeperException)3 RankingConstant (com.yahoo.searchdefinition.RankingConstant)2 Curator (com.yahoo.vespa.curator.Curator)2 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 NamedReader (com.yahoo.io.reader.NamedReader)1 RankProfile (com.yahoo.searchdefinition.RankProfile)1 Tensor (com.yahoo.tensor.Tensor)1 TensorType (com.yahoo.tensor.TensorType)1 NestedTransaction (com.yahoo.transaction.NestedTransaction)1