use of com.yahoo.config.model.application.provider.MockFileRegistry in project vespa by vespa-engine.
the class FileDistributorTestCase method fileDistributor.
@Test
public void fileDistributor() {
MockHosts hosts = new MockHosts();
FileDistributor fileDistributor = new FileDistributor(new MockFileRegistry(), null);
String file1 = "component/path1";
String file2 = "component/path2";
FileReference ref1 = fileDistributor.sendFileToHosts(file1, Arrays.asList(hosts.host1, hosts.host2));
FileReference ref2 = fileDistributor.sendFileToHosts(file2, Arrays.asList(hosts.host3));
assertEquals(new HashSet<>(Arrays.asList(hosts.host1, hosts.host2, hosts.host3)), fileDistributor.getTargetHosts());
assertTrue(ref1 != null);
assertTrue(ref2 != null);
MockFileDistribution dbHandler = new MockFileDistribution();
fileDistributor.sendDeployedFiles(dbHandler);
// One time for each host
assertEquals(3, dbHandler.filesToDownloadCalled);
}
use of com.yahoo.config.model.application.provider.MockFileRegistry in project vespa by vespa-engine.
the class ContentClusterUtils method createCluster.
public static ContentCluster createCluster(String clusterXml, MockRoot root) {
Document doc = XML.getDocument(clusterXml);
Admin admin = new Admin(root, new DefaultMonitoring("vespa", 60), new Metrics(), Collections.emptyMap(), false, new FileDistributionConfigProducer(root, new MockFileRegistry(), null));
ConfigModelContext context = ConfigModelContext.create(null, root.getDeployState(), null, root, null);
return new ContentCluster.Builder(admin).build(Collections.emptyList(), context, doc.getDocumentElement());
}
use of com.yahoo.config.model.application.provider.MockFileRegistry in project vespa by vespa-engine.
the class ActivatedModelsBuilder method buildModelVersion.
@Override
protected Application buildModelVersion(ModelFactory modelFactory, ApplicationPackage applicationPackage, ApplicationId applicationId, com.yahoo.component.Version wantedNodeVespaVersion, // Ignored since we have this in the app package for activated models
Optional<AllocatedHosts> ignored, Instant now) {
log.log(LogLevel.DEBUG, String.format("Loading model version %s for session %s application %s", modelFactory.getVersion(), appGeneration, applicationId));
ServerCache cache = zkClient.loadServerCache();
ModelContext modelContext = new ModelContextImpl(applicationPackage, Optional.empty(), permanentApplicationPackage.get().applicationPackage(), logger, configDefinitionRepo, getForVersionOrLatest(applicationPackage.getFileRegistryMap(), modelFactory.getVersion()).orElse(new MockFileRegistry()), createStaticProvisioner(applicationPackage.getAllocatedHosts()), createModelContextProperties(applicationId), Optional.empty(), new com.yahoo.component.Version(modelFactory.getVersion().toString()), wantedNodeVespaVersion);
MetricUpdater applicationMetricUpdater = metrics.getOrCreateMetricUpdater(Metrics.createDimensions(applicationId));
return new Application(modelFactory.createModel(modelContext), cache, appGeneration, modelFactory.getVersion(), applicationMetricUpdater, applicationId);
}
use of com.yahoo.config.model.application.provider.MockFileRegistry 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;
}
use of com.yahoo.config.model.application.provider.MockFileRegistry 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()));
}
Aggregations