Search in sources :

Example 1 with MockFileRegistry

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);
}
Also used : MockHosts(com.yahoo.config.model.test.MockHosts) FileReference(com.yahoo.config.FileReference) MockFileRegistry(com.yahoo.config.model.application.provider.MockFileRegistry) Test(org.junit.Test)

Example 2 with MockFileRegistry

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());
}
Also used : FileDistributionConfigProducer(com.yahoo.vespa.model.filedistribution.FileDistributionConfigProducer) Metrics(com.yahoo.vespa.model.admin.monitoring.builder.Metrics) DefaultMonitoring(com.yahoo.vespa.model.admin.monitoring.DefaultMonitoring) Document(org.w3c.dom.Document) Admin(com.yahoo.vespa.model.admin.Admin) MockFileRegistry(com.yahoo.config.model.application.provider.MockFileRegistry) ConfigModelContext(com.yahoo.config.model.ConfigModelContext) ContentCluster(com.yahoo.vespa.model.content.cluster.ContentCluster)

Example 3 with MockFileRegistry

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);
}
Also used : ServerCache(com.yahoo.vespa.config.server.ServerCache) ModelContext(com.yahoo.config.model.api.ModelContext) MetricUpdater(com.yahoo.vespa.config.server.monitoring.MetricUpdater) ModelContextImpl(com.yahoo.vespa.config.server.deploy.ModelContextImpl) MockFileRegistry(com.yahoo.config.model.application.provider.MockFileRegistry) Application(com.yahoo.vespa.config.server.application.Application)

Example 4 with MockFileRegistry

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;
}
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 5 with MockFileRegistry

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

MockFileRegistry (com.yahoo.config.model.application.provider.MockFileRegistry)6 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)3 ModelContext (com.yahoo.config.model.api.ModelContext)2 ModelContextImpl (com.yahoo.vespa.config.server.deploy.ModelContextImpl)2 SessionZooKeeperClient (com.yahoo.vespa.config.server.session.SessionZooKeeperClient)2 Test (org.junit.Test)2 Version (com.yahoo.component.Version)1 FileReference (com.yahoo.config.FileReference)1 ConfigModelContext (com.yahoo.config.model.ConfigModelContext)1 MockApplicationPackage (com.yahoo.config.model.test.MockApplicationPackage)1 MockHosts (com.yahoo.config.model.test.MockHosts)1 Rotation (com.yahoo.config.provision.Rotation)1 Zone (com.yahoo.config.provision.Zone)1 ServerCache (com.yahoo.vespa.config.server.ServerCache)1 TestConfigDefinitionRepo (com.yahoo.vespa.config.server.TestConfigDefinitionRepo)1 Application (com.yahoo.vespa.config.server.application.Application)1 ZooKeeperClient (com.yahoo.vespa.config.server.deploy.ZooKeeperClient)1 ZooKeeperDeployer (com.yahoo.vespa.config.server.deploy.ZooKeeperDeployer)1 MetricUpdater (com.yahoo.vespa.config.server.monitoring.MetricUpdater)1 RemoteSession (com.yahoo.vespa.config.server.session.RemoteSession)1