use of com.yahoo.config.model.api.ApplicationInfo in project vespa by vespa-engine.
the class SuperModelControllerTest method setupHandler.
@Before
public void setupHandler() throws IOException, SAXException {
Map<TenantName, Map<ApplicationId, ApplicationInfo>> models = new LinkedHashMap<>();
models.put(TenantName.from("a"), new LinkedHashMap<>());
File testApp = new File("src/test/resources/deploy/app");
ApplicationId app = ApplicationId.from(TenantName.from("a"), ApplicationName.from("foo"), InstanceName.defaultName());
models.get(app.tenant()).put(app, new ApplicationInfo(app, 4l, new VespaModel(FilesApplicationPackage.fromFile(testApp))));
SuperModel superModel = new SuperModel(models);
handler = new SuperModelController(new SuperModelConfigProvider(superModel, Zone.defaultZone()), new TestConfigDefinitionRepo(), 2, new UncompressedConfigResponseFactory());
}
use of com.yahoo.config.model.api.ApplicationInfo in project vespa by vespa-engine.
the class ModelGenerator method toApplicationInstance.
ApplicationInstance toApplicationInstance(ApplicationInfo applicationInfo, Zone zone, ServiceStatusProvider serviceStatusProvider) {
Map<ServiceClusterKey, Set<ServiceInstance>> groupedServiceInstances = new HashMap<>();
for (HostInfo host : applicationInfo.getModel().getHosts()) {
HostName hostName = new HostName(host.getHostname());
for (ServiceInfo serviceInfo : host.getServices()) {
ServiceClusterKey serviceClusterKey = toServiceClusterKey(serviceInfo);
ServiceInstance serviceInstance = toServiceInstance(applicationInfo.getApplicationId(), serviceClusterKey.clusterId(), serviceInfo, hostName, serviceStatusProvider);
if (!groupedServiceInstances.containsKey(serviceClusterKey)) {
groupedServiceInstances.put(serviceClusterKey, new HashSet<>());
}
groupedServiceInstances.get(serviceClusterKey).add(serviceInstance);
}
}
Set<ServiceCluster> serviceClusters = groupedServiceInstances.entrySet().stream().map(entry -> new ServiceCluster(entry.getKey().clusterId(), entry.getKey().serviceType(), entry.getValue())).collect(Collectors.toSet());
ApplicationInstance applicationInstance = new ApplicationInstance(new TenantId(applicationInfo.getApplicationId().tenant().toString()), toApplicationInstanceId(applicationInfo, zone), serviceClusters);
// Fill back-references
for (ServiceCluster serviceCluster : applicationInstance.serviceClusters()) {
serviceCluster.setApplicationInstance(applicationInstance);
for (ServiceInstance serviceInstance : serviceCluster.serviceInstances()) {
serviceInstance.setServiceCluster(serviceCluster);
}
}
return applicationInstance;
}
use of com.yahoo.config.model.api.ApplicationInfo in project vespa by vespa-engine.
the class ModelGenerator method toServiceModel.
/**
* Create service model based primarily on super model.
*
* If the configServerhosts is non-empty, a config server application is added.
*/
ServiceModel toServiceModel(SuperModel superModel, Zone zone, List<String> configServerHosts, ServiceStatusProvider serviceStatusProvider) {
Map<ApplicationInstanceReference, ApplicationInstance> applicationInstances = new HashMap<>();
for (ApplicationInfo applicationInfo : superModel.getAllApplicationInfos()) {
ApplicationInstance applicationInstance = toApplicationInstance(applicationInfo, zone, serviceStatusProvider);
applicationInstances.put(applicationInstance.reference(), applicationInstance);
}
// The config server is part of the service model (but not super model)
if (!configServerHosts.isEmpty()) {
ConfigServerApplication configServerApplication = new ConfigServerApplication();
ApplicationInstance configServerApplicationInstance = configServerApplication.toApplicationInstance(configServerHosts);
applicationInstances.put(configServerApplicationInstance.reference(), configServerApplicationInstance);
}
return new ServiceModel(applicationInstances);
}
use of com.yahoo.config.model.api.ApplicationInfo in project vespa by vespa-engine.
the class ExampleModel method createExampleSuperModelWithOneRpcPort.
static SuperModel createExampleSuperModelWithOneRpcPort(String hostname, int rpcPort) {
List<String> hosts = Stream.of(hostname).collect(Collectors.toList());
ApplicationInfo applicationInfo = ExampleModel.createApplication(TENANT, APPLICATION_NAME).addServiceCluster(CLUSTER_ID, SERVICE_NAME, SERVICE_TYPE, hosts).addPort(rpcPort, "footag", SlobrokMonitor.SLOBROK_RPC_PORT_TAG).addPort(rpcPort + 1, "bartag").then().build();
Map<TenantName, Map<ApplicationId, ApplicationInfo>> applicationInfos = new HashMap<>();
applicationInfos.put(applicationInfo.getApplicationId().tenant(), new HashMap<>());
applicationInfos.get(applicationInfo.getApplicationId().tenant()).put(applicationInfo.getApplicationId(), applicationInfo);
return new SuperModel(applicationInfos);
}
Aggregations