Search in sources :

Example 1 with ModelContextImpl

use of com.yahoo.vespa.config.server.deploy.ModelContextImpl 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 2 with ModelContextImpl

use of com.yahoo.vespa.config.server.deploy.ModelContextImpl in project vespa by vespa-engine.

the class PreparedModelsBuilder method buildModelVersion.

@Override
protected PreparedModelResult buildModelVersion(ModelFactory modelFactory, ApplicationPackage applicationPackage, ApplicationId applicationId, com.yahoo.component.Version wantedNodeVespaVersion, Optional<AllocatedHosts> allocatedHosts, Instant now) {
    Version modelVersion = modelFactory.getVersion();
    log.log(LogLevel.DEBUG, "Building model " + modelVersion + " for " + applicationId);
    FileDistributionProvider fileDistributionProvider = fileDistributionFactory.createProvider(context.getServerDBSessionDir());
    // Use empty on non-hosted systems, use already allocated hosts if available, create connection to a host provisioner otherwise
    Optional<HostProvisioner> hostProvisioner = createHostProvisioner(allocatedHosts);
    Optional<Model> previousModel = currentActiveApplicationSet.map(set -> set.getForVersionOrLatest(Optional.of(modelVersion), now).getModel());
    ModelContext modelContext = new ModelContextImpl(applicationPackage, previousModel, permanentApplicationPackage.applicationPackage(), logger, configDefinitionRepo, fileDistributionProvider.getFileRegistry(), hostProvisioner, properties, getAppDir(applicationPackage), new com.yahoo.component.Version(modelVersion.toString()), wantedNodeVespaVersion);
    log.log(LogLevel.DEBUG, "Create and validate model " + modelVersion + " for " + applicationId);
    ModelCreateResult result = modelFactory.createAndValidateModel(modelContext, params.ignoreValidationErrors());
    validateModelHosts(context.getHostValidator(), applicationId, result.getModel());
    log.log(LogLevel.DEBUG, "Done building model " + modelVersion + " for " + applicationId);
    return new PreparedModelsBuilder.PreparedModelResult(modelVersion, result.getModel(), fileDistributionProvider, result.getConfigChangeActions());
}
Also used : ModelCreateResult(com.yahoo.config.model.api.ModelCreateResult) ModelContextImpl(com.yahoo.vespa.config.server.deploy.ModelContextImpl) ModelContext(com.yahoo.config.model.api.ModelContext) Version(com.yahoo.config.provision.Version) Model(com.yahoo.config.model.api.Model) FileDistributionProvider(com.yahoo.vespa.config.server.filedistribution.FileDistributionProvider) HostProvisioner(com.yahoo.config.model.api.HostProvisioner)

Example 3 with ModelContextImpl

use of com.yahoo.vespa.config.server.deploy.ModelContextImpl in project vespa by vespa-engine.

the class ModelContextImplTest method testModelContextTest.

@Test
public void testModelContextTest() {
    final Rotation rotation = new Rotation("this.is.a.mock.rotation");
    final Set<Rotation> rotations = Collections.singleton(rotation);
    ModelContext context = new ModelContextImpl(MockApplicationPackage.createEmpty(), Optional.empty(), Optional.empty(), new BaseDeployLogger(), new StaticConfigDefinitionRepo(), new MockFileRegistry(), Optional.empty(), new ModelContextImpl.Properties(ApplicationId.defaultId(), true, Collections.emptyList(), null, false, Zone.defaultZone(), rotations), Optional.empty(), new Version(6), new Version(6));
    assertTrue(context.applicationPackage() instanceof MockApplicationPackage);
    assertFalse(context.hostProvisioner().isPresent());
    assertFalse(context.permanentApplicationPackage().isPresent());
    assertFalse(context.previousModel().isPresent());
    assertTrue(context.getFileRegistry() instanceof MockFileRegistry);
    assertTrue(context.configDefinitionRepo() instanceof StaticConfigDefinitionRepo);
    assertThat(context.properties().applicationId(), is(ApplicationId.defaultId()));
    assertTrue(context.properties().configServerSpecs().isEmpty());
    assertTrue(context.properties().multitenant());
    assertTrue(context.properties().zone() instanceof Zone);
    assertFalse(context.properties().hostedVespa());
    assertThat(context.properties().rotations(), equalTo(rotations));
}
Also used : ModelContext(com.yahoo.config.model.api.ModelContext) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) Version(com.yahoo.component.Version) Zone(com.yahoo.config.provision.Zone) ModelContextImpl(com.yahoo.vespa.config.server.deploy.ModelContextImpl) Rotation(com.yahoo.config.provision.Rotation) MockFileRegistry(com.yahoo.config.model.application.provider.MockFileRegistry) Test(org.junit.Test)

Aggregations

ModelContext (com.yahoo.config.model.api.ModelContext)3 ModelContextImpl (com.yahoo.vespa.config.server.deploy.ModelContextImpl)3 MockFileRegistry (com.yahoo.config.model.application.provider.MockFileRegistry)2 Version (com.yahoo.component.Version)1 HostProvisioner (com.yahoo.config.model.api.HostProvisioner)1 Model (com.yahoo.config.model.api.Model)1 ModelCreateResult (com.yahoo.config.model.api.ModelCreateResult)1 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)1 MockApplicationPackage (com.yahoo.config.model.test.MockApplicationPackage)1 Rotation (com.yahoo.config.provision.Rotation)1 Version (com.yahoo.config.provision.Version)1 Zone (com.yahoo.config.provision.Zone)1 ServerCache (com.yahoo.vespa.config.server.ServerCache)1 Application (com.yahoo.vespa.config.server.application.Application)1 FileDistributionProvider (com.yahoo.vespa.config.server.filedistribution.FileDistributionProvider)1 MetricUpdater (com.yahoo.vespa.config.server.monitoring.MetricUpdater)1 Test (org.junit.Test)1