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