Search in sources :

Example 11 with ServiceInfo

use of com.yahoo.config.model.api.ServiceInfo in project vespa by vespa-engine.

the class SessionPrepareHandlerTest method require_that_config_change_actions_are_logged_if_existing.

@Test
public void require_that_config_change_actions_are_logged_if_existing() throws Exception {
    List<ServiceInfo> services = Collections.singletonList(new ServiceInfo("serviceName", "serviceType", null, ImmutableMap.of("clustername", "foo", "clustertype", "bar"), "configId", "hostName"));
    ConfigChangeActions actions = new ConfigChangeActions(Arrays.asList(new MockRestartAction("change", services), new MockRefeedAction("change-id", false, "other change", services, "test")));
    MockSession session = new MockSession(1, null, actions);
    localRepo.addSession(session);
    HttpResponse response = createHandler().handle(SessionHandlerTest.createTestRequest(pathPrefix, HttpRequest.Method.PUT, Cmd.PREPARED, 1L));
    assertResponseContains(response, "Change(s) between active and new application that require restart:\\nIn cluster 'foo' of type 'bar");
    assertResponseContains(response, "Change(s) between active and new application that may require re-feed:\\nchange-id: Consider removing data and re-feed document type 'test'");
}
Also used : ServiceInfo(com.yahoo.config.model.api.ServiceInfo) ConfigChangeActions(com.yahoo.vespa.config.server.configchange.ConfigChangeActions) HttpResponse(com.yahoo.container.jdisc.HttpResponse) MockRestartAction(com.yahoo.vespa.config.server.configchange.MockRestartAction) MockRefeedAction(com.yahoo.vespa.config.server.configchange.MockRefeedAction) Test(org.junit.Test)

Example 12 with ServiceInfo

use of com.yahoo.config.model.api.ServiceInfo in project vespa by vespa-engine.

the class SessionPreparerTest method require_that_config_change_actions_are_collected_from_all_models.

@Test
public void require_that_config_change_actions_are_collected_from_all_models() throws IOException {
    ServiceInfo service = new ServiceInfo("serviceName", "serviceType", null, new HashMap<>(), "configId", "hostName");
    ModelFactoryRegistry modelFactoryRegistry = new ModelFactoryRegistry(Arrays.asList(new ConfigChangeActionsModelFactory(Version.fromIntValues(1, 2, 3), new MockRestartAction("change", Arrays.asList(service))), new ConfigChangeActionsModelFactory(Version.fromIntValues(1, 2, 4), new MockRestartAction("other change", Arrays.asList(service)))));
    preparer = createPreparer(modelFactoryRegistry, HostProvisionerProvider.empty());
    List<RestartActions.Entry> actions = preparer.prepare(getContext(getApplicationPackage(testApp)), getLogger(), new PrepareParams.Builder().build(), Optional.empty(), tenantPath, Instant.now()).getRestartActions().getEntries();
    assertThat(actions.size(), is(1));
    assertThat(actions.get(0).getMessages(), equalTo(ImmutableSet.of("change", "other change")));
}
Also used : ServiceInfo(com.yahoo.config.model.api.ServiceInfo) ModelFactoryRegistry(com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry) MockRestartAction(com.yahoo.vespa.config.server.configchange.MockRestartAction) Test(org.junit.Test)

Example 13 with ServiceInfo

use of com.yahoo.config.model.api.ServiceInfo in project vespa by vespa-engine.

the class MockModel method createClusterController.

static MockModel createClusterController(String hostname, int statePort) {
    ServiceInfo container = createServiceInfo(hostname, // name
    "foo", // type
    "container-clustercontroller", ClusterSpec.Type.container, statePort, "state http external query");
    ServiceInfo serviceNoStatePort = createServiceInfo(hostname, "storagenode", "storagenode", ClusterSpec.Type.content, 1234, "rpc");
    HostInfo hostInfo = new HostInfo(hostname, Arrays.asList(container, serviceNoStatePort));
    return new MockModel(Collections.singleton(hostInfo));
}
Also used : ServiceInfo(com.yahoo.config.model.api.ServiceInfo) HostInfo(com.yahoo.config.model.api.HostInfo)

Example 14 with ServiceInfo

use of com.yahoo.config.model.api.ServiceInfo in project vespa by vespa-engine.

the class MockModel method createConfigProxies.

static MockModel createConfigProxies(List<String> hostnames, int rpcPort) {
    Set<HostInfo> hostInfos = new HashSet<>();
    hostnames.forEach(hostname -> {
        ServiceInfo configProxy = createServiceInfo(hostname, "configproxy", "configproxy", ClusterSpec.Type.admin, rpcPort, "rpc");
        hostInfos.add(new HostInfo(hostname, Collections.singletonList(configProxy)));
    });
    return new MockModel(hostInfos);
}
Also used : ServiceInfo(com.yahoo.config.model.api.ServiceInfo) HostInfo(com.yahoo.config.model.api.HostInfo) HashSet(java.util.HashSet)

Example 15 with ServiceInfo

use of com.yahoo.config.model.api.ServiceInfo 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;
}
Also used : ApplicationId(com.yahoo.config.provision.ApplicationId) HostInfo(com.yahoo.config.model.api.HostInfo) HashMap(java.util.HashMap) ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ClusterId(com.yahoo.vespa.applicationmodel.ClusterId) ServiceStatus(com.yahoo.vespa.applicationmodel.ServiceStatus) HashSet(java.util.HashSet) HostName(com.yahoo.vespa.applicationmodel.HostName) Map(java.util.Map) SuperModel(com.yahoo.config.model.api.SuperModel) ServiceStatusProvider(com.yahoo.vespa.service.monitor.ServiceStatusProvider) ApplicationInstanceReference(com.yahoo.vespa.applicationmodel.ApplicationInstanceReference) ApplicationInfo(com.yahoo.config.model.api.ApplicationInfo) ServiceInstance(com.yahoo.vespa.applicationmodel.ServiceInstance) ConfigId(com.yahoo.vespa.applicationmodel.ConfigId) ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) Set(java.util.Set) TenantId(com.yahoo.vespa.applicationmodel.TenantId) Collectors(java.util.stream.Collectors) ServiceModel(com.yahoo.vespa.service.monitor.ServiceModel) ServiceClusterKey(com.yahoo.vespa.applicationmodel.ServiceClusterKey) ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) List(java.util.List) ApplicationInstanceId(com.yahoo.vespa.applicationmodel.ApplicationInstanceId) Zone(com.yahoo.config.provision.Zone) ServiceInfo(com.yahoo.config.model.api.ServiceInfo) HashSet(java.util.HashSet) Set(java.util.Set) ServiceClusterKey(com.yahoo.vespa.applicationmodel.ServiceClusterKey) HashMap(java.util.HashMap) ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) ServiceInstance(com.yahoo.vespa.applicationmodel.ServiceInstance) ServiceInfo(com.yahoo.config.model.api.ServiceInfo) TenantId(com.yahoo.vespa.applicationmodel.TenantId) ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) HostInfo(com.yahoo.config.model.api.HostInfo) HostName(com.yahoo.vespa.applicationmodel.HostName)

Aggregations

ServiceInfo (com.yahoo.config.model.api.ServiceInfo)16 HostInfo (com.yahoo.config.model.api.HostInfo)9 Test (org.junit.Test)7 HashMap (java.util.HashMap)5 PortInfo (com.yahoo.config.model.api.PortInfo)4 ApplicationInfo (com.yahoo.config.model.api.ApplicationInfo)3 SuperModelProvider (com.yahoo.config.model.api.SuperModelProvider)3 ApplicationId (com.yahoo.config.provision.ApplicationId)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Map (java.util.Map)3 Model (com.yahoo.config.model.api.Model)2 SuperModel (com.yahoo.config.model.api.SuperModel)2 Zone (com.yahoo.config.provision.Zone)2 MockRestartAction (com.yahoo.vespa.config.server.configchange.MockRestartAction)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Assert.assertTrue (org.junit.Assert.assertTrue)2