Search in sources :

Example 1 with ApplicationInstance

use of com.yahoo.vespa.applicationmodel.ApplicationInstance in project vespa by vespa-engine.

the class ConfigServerApplicationTest method toApplicationInstance.

@Test
public void toApplicationInstance() throws Exception {
    ConfigServerApplication application = new ConfigServerApplication();
    ApplicationInstance applicationInstance = application.toApplicationInstance(configServerList);
    assertEquals(ConfigServerApplication.APPLICATION_INSTANCE_ID, applicationInstance.applicationInstanceId());
    assertEquals(ConfigServerApplication.TENANT_ID, applicationInstance.tenantId());
    assertEquals(ConfigServerApplication.TENANT_ID.toString() + ":" + ConfigServerApplication.APPLICATION_INSTANCE_ID, applicationInstance.reference().toString());
    assertEquals(ConfigServerApplication.CLUSTER_ID, applicationInstance.serviceClusters().iterator().next().clusterId());
    assertEquals(ServiceStatus.NOT_CHECKED, applicationInstance.serviceClusters().iterator().next().serviceInstances().iterator().next().serviceStatus());
    assertTrue(configServerList.contains(applicationInstance.serviceClusters().iterator().next().serviceInstances().iterator().next().hostName().toString()));
}
Also used : ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) Test(org.junit.Test)

Example 2 with ApplicationInstance

use of com.yahoo.vespa.applicationmodel.ApplicationInstance in project vespa by vespa-engine.

the class ModelGeneratorTest method toApplicationModel.

@Test
public void toApplicationModel() throws Exception {
    SuperModel superModel = ExampleModel.createExampleSuperModelWithOneRpcPort(HOSTNAME, PORT);
    ModelGenerator modelGenerator = new ModelGenerator();
    Zone zone = new Zone(Environment.from(ENVIRONMENT), RegionName.from(REGION));
    List<String> configServerHosts = Collections.emptyList();
    SlobrokMonitorManagerImpl slobrokMonitorManager = mock(SlobrokMonitorManagerImpl.class);
    when(slobrokMonitorManager.getStatus(any(), any(), any(), any())).thenReturn(ServiceStatus.UP);
    ServiceModel serviceModel = modelGenerator.toServiceModel(superModel, zone, configServerHosts, slobrokMonitorManager);
    Map<ApplicationInstanceReference, ApplicationInstance> applicationInstances = serviceModel.getAllApplicationInstances();
    assertEquals(1, applicationInstances.size());
    verifyOtherApplication(applicationInstances.values().iterator().next());
}
Also used : ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ServiceModel(com.yahoo.vespa.service.monitor.ServiceModel) SuperModel(com.yahoo.config.model.api.SuperModel) Zone(com.yahoo.config.provision.Zone) ApplicationInstanceReference(com.yahoo.vespa.applicationmodel.ApplicationInstanceReference) Test(org.junit.Test)

Example 3 with ApplicationInstance

use of com.yahoo.vespa.applicationmodel.ApplicationInstance in project vespa by vespa-engine.

the class ModelGeneratorTest method toApplicationModelWithConfigServerApplication.

@Test
public void toApplicationModelWithConfigServerApplication() throws Exception {
    SuperModel superModel = ExampleModel.createExampleSuperModelWithOneRpcPort(HOSTNAME, PORT);
    ModelGenerator modelGenerator = new ModelGenerator();
    Zone zone = new Zone(Environment.from(ENVIRONMENT), RegionName.from(REGION));
    List<String> configServerHosts = Stream.of("cfg1", "cfg2", "cfg3").collect(Collectors.toList());
    SlobrokMonitorManagerImpl slobrokMonitorManager = mock(SlobrokMonitorManagerImpl.class);
    when(slobrokMonitorManager.getStatus(any(), any(), any(), any())).thenReturn(ServiceStatus.UP);
    ServiceModel serviceModel = modelGenerator.toServiceModel(superModel, zone, configServerHosts, slobrokMonitorManager);
    Map<ApplicationInstanceReference, ApplicationInstance> applicationInstances = serviceModel.getAllApplicationInstances();
    assertEquals(2, applicationInstances.size());
    Iterator<Map.Entry<ApplicationInstanceReference, ApplicationInstance>> iterator = applicationInstances.entrySet().iterator();
    ApplicationInstance applicationInstance1 = iterator.next().getValue();
    ApplicationInstance applicationInstance2 = iterator.next().getValue();
    if (applicationInstance1.applicationInstanceId().equals(ConfigServerApplication.APPLICATION_INSTANCE_ID)) {
        verifyConfigServerApplication(applicationInstance1);
        verifyOtherApplication(applicationInstance2);
    } else {
        verifyConfigServerApplication(applicationInstance2);
        verifyOtherApplication(applicationInstance1);
    }
}
Also used : ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ServiceModel(com.yahoo.vespa.service.monitor.ServiceModel) SuperModel(com.yahoo.config.model.api.SuperModel) Zone(com.yahoo.config.provision.Zone) ApplicationInstanceReference(com.yahoo.vespa.applicationmodel.ApplicationInstanceReference) Test(org.junit.Test)

Example 4 with ApplicationInstance

use of com.yahoo.vespa.applicationmodel.ApplicationInstance in project vespa by vespa-engine.

the class ClusterControllerClientFactoryMock method setAllDummyNodesAsUp.

public void setAllDummyNodesAsUp() {
    for (ApplicationInstance app : DummyInstanceLookupService.getApplications()) {
        Set<HostName> hosts = DummyInstanceLookupService.getContentHosts(app.reference());
        for (HostName host : hosts) {
            ClusterId clusterName = VespaModelUtil.getContentClusterName(app, host);
            int storageNodeIndex = VespaModelUtil.getStorageNodeIndex(app, host);
            String globalMapKey = clusterName.s() + storageNodeIndex;
            nodes.put(globalMapKey, ClusterControllerNodeState.UP);
        }
    }
}
Also used : ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ClusterId(com.yahoo.vespa.applicationmodel.ClusterId) HostName(com.yahoo.vespa.applicationmodel.HostName)

Example 5 with ApplicationInstance

use of com.yahoo.vespa.applicationmodel.ApplicationInstance in project vespa by vespa-engine.

the class ApplicationApiImplTest method testGetNodesInGroupWithStatus.

@Test
public void testGetNodesInGroupWithStatus() {
    HostName hostName1 = modelUtils.createNode("host1", HostStatus.NO_REMARKS);
    HostName hostName2 = modelUtils.createNode("host2", HostStatus.NO_REMARKS);
    HostName hostName3 = modelUtils.createNode("host3", HostStatus.ALLOWED_TO_BE_DOWN);
    ApplicationInstance applicationInstance = modelUtils.createApplicationInstance(Arrays.asList(modelUtils.createServiceCluster("cluster-1", new ServiceType("service-type-1"), Arrays.asList(modelUtils.createServiceInstance("config-id-10", hostName1, ServiceStatus.UP), modelUtils.createServiceInstance("config-id-11", hostName2, ServiceStatus.UP))), modelUtils.createServiceCluster("cluster-2", new ServiceType("service-type-2"), Arrays.asList(modelUtils.createServiceInstance("config-id-20", hostName1, ServiceStatus.UP), modelUtils.createServiceInstance("config-id-21", hostName3, ServiceStatus.UP)))));
    verifyNodesInGroupWithoutRemarks(modelUtils.createApplicationApiImpl(applicationInstance, hostName1), Arrays.asList(hostName1), Arrays.asList());
    verifyNodesInGroupWithoutRemarks(modelUtils.createApplicationApiImpl(applicationInstance, hostName1, hostName2), Arrays.asList(hostName1, hostName2), Arrays.asList());
    verifyNodesInGroupWithoutRemarks(modelUtils.createApplicationApiImpl(applicationInstance, hostName1, hostName2, hostName3), Arrays.asList(hostName1, hostName2), Arrays.asList(hostName3));
    verifyNodesInGroupWithoutRemarks(modelUtils.createApplicationApiImpl(applicationInstance, hostName3), Arrays.asList(), Arrays.asList(hostName3));
}
Also used : ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) HostName(com.yahoo.vespa.applicationmodel.HostName) Test(org.junit.Test)

Aggregations

ApplicationInstance (com.yahoo.vespa.applicationmodel.ApplicationInstance)24 HostName (com.yahoo.vespa.applicationmodel.HostName)14 ApplicationInstanceReference (com.yahoo.vespa.applicationmodel.ApplicationInstanceReference)11 Test (org.junit.Test)10 ServiceType (com.yahoo.vespa.applicationmodel.ServiceType)9 ClusterId (com.yahoo.vespa.applicationmodel.ClusterId)6 ServiceCluster (com.yahoo.vespa.applicationmodel.ServiceCluster)6 ServiceInstance (com.yahoo.vespa.applicationmodel.ServiceInstance)6 ApplicationInstanceId (com.yahoo.vespa.applicationmodel.ApplicationInstanceId)5 TenantId (com.yahoo.vespa.applicationmodel.TenantId)5 HashMap (java.util.HashMap)5 ConfigId (com.yahoo.vespa.applicationmodel.ConfigId)4 NodeGroup (com.yahoo.vespa.orchestrator.model.NodeGroup)4 HostStatus (com.yahoo.vespa.orchestrator.status.HostStatus)4 MutableStatusRegistry (com.yahoo.vespa.orchestrator.status.MutableStatusRegistry)4 ServiceModel (com.yahoo.vespa.service.monitor.ServiceModel)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 SuperModel (com.yahoo.config.model.api.SuperModel)3 ApplicationId (com.yahoo.config.provision.ApplicationId)3