Search in sources :

Example 6 with HostName

use of com.yahoo.vespa.applicationmodel.HostName 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 7 with HostName

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

the class ClusterApiImplTest method testStorageCluster.

@Test
public void testStorageCluster() {
    HostName hostName1 = new HostName("host1");
    HostName hostName2 = new HostName("host2");
    HostName hostName3 = new HostName("host3");
    ServiceCluster serviceCluster = modelUtils.createServiceCluster("cluster", VespaModelUtil.STORAGENODE_SERVICE_TYPE, Arrays.asList(modelUtils.createServiceInstance("storage-1", hostName1, ServiceStatus.UP), modelUtils.createServiceInstance("storage-2", hostName2, ServiceStatus.DOWN)));
    ClusterApiImpl clusterApi = new ClusterApiImpl(applicationApi, serviceCluster, new NodeGroup(modelUtils.createApplicationInstance(new ArrayList<>()), hostName1, hostName3), new HashMap<>(), modelUtils.getClusterControllerClientFactory());
    assertTrue(clusterApi.isStorageCluster());
    assertEquals(Optional.of(hostName1), clusterApi.storageNodeInGroup().map(storageNode -> storageNode.hostName()));
    assertEquals(Optional.of(hostName1), clusterApi.upStorageNodeInGroup().map(storageNode -> storageNode.hostName()));
}
Also used : Arrays(java.util.Arrays) ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) HashMap(java.util.HashMap) ServiceStatus(com.yahoo.vespa.applicationmodel.ServiceStatus) ArrayList(java.util.ArrayList) ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) HostName(com.yahoo.vespa.applicationmodel.HostName) Assert.assertFalse(org.junit.Assert.assertFalse) Optional(java.util.Optional) HostStatus(com.yahoo.vespa.orchestrator.status.HostStatus) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.mock(org.mockito.Mockito.mock) ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) HostName(com.yahoo.vespa.applicationmodel.HostName) Test(org.junit.Test)

Example 8 with HostName

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

the class ClusterApiImplTest method testServicesDownAndNotInGroup.

@Test
public void testServicesDownAndNotInGroup() {
    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);
    HostName hostName4 = modelUtils.createNode("host4", HostStatus.ALLOWED_TO_BE_DOWN);
    HostName hostName5 = modelUtils.createNode("host5", HostStatus.NO_REMARKS);
    ServiceCluster serviceCluster = modelUtils.createServiceCluster("cluster", new ServiceType("service-type"), Arrays.asList(modelUtils.createServiceInstance("service-1", hostName1, ServiceStatus.UP), modelUtils.createServiceInstance("service-2", hostName2, ServiceStatus.DOWN), modelUtils.createServiceInstance("service-3", hostName3, ServiceStatus.UP), modelUtils.createServiceInstance("service-4", hostName4, ServiceStatus.DOWN), modelUtils.createServiceInstance("service-5", hostName5, ServiceStatus.UP)));
    ClusterApiImpl clusterApi = new ClusterApiImpl(applicationApi, serviceCluster, new NodeGroup(modelUtils.createApplicationInstance(new ArrayList<>()), hostName5), modelUtils.getHostStatusMap(), modelUtils.getClusterControllerClientFactory());
    assertEquals("{ clusterId=cluster, serviceType=service-type }", clusterApi.clusterInfo());
    assertFalse(clusterApi.isStorageCluster());
    assertEquals("[ServiceInstance{configId=service-2, hostName=host2, serviceStatus=DOWN}, " + "ServiceInstance{configId=service-3, hostName=host3, serviceStatus=UP}, " + "ServiceInstance{configId=service-4, hostName=host4, serviceStatus=DOWN}]", clusterApi.servicesDownAndNotInGroupDescription());
    assertEquals("[host3, host4]", clusterApi.nodesAllowedToBeDownNotInGroupDescription());
    assertEquals(60, clusterApi.percentageOfServicesDown());
    assertEquals(80, clusterApi.percentageOfServicesDownIfGroupIsAllowedToBeDown());
}
Also used : ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) HostName(com.yahoo.vespa.applicationmodel.HostName) Test(org.junit.Test)

Example 9 with HostName

use of com.yahoo.vespa.applicationmodel.HostName 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)

Example 10 with HostName

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

the class ApplicationApiImplTest method testGetClustersThatAreOnAtLeastOneNodeInGroup.

@Test
public void testGetClustersThatAreOnAtLeastOneNodeInGroup() {
    HostName hostName1 = new HostName("host1");
    HostName hostName2 = new HostName("host2");
    HostName hostName3 = new HostName("host3");
    HostName hostName4 = new HostName("host4");
    ApplicationInstance applicationInstance = modelUtils.createApplicationInstance(Arrays.asList(modelUtils.createServiceCluster("cluster-3", new ServiceType("service-type-3"), Arrays.asList(modelUtils.createServiceInstance("config-id-1", hostName1, ServiceStatus.UP), modelUtils.createServiceInstance("config-id-2", hostName2, ServiceStatus.UP))), modelUtils.createServiceCluster("cluster-1", new ServiceType("service-type-1"), Arrays.asList(modelUtils.createServiceInstance("config-id-3", hostName1, ServiceStatus.UP), modelUtils.createServiceInstance("config-id-4", hostName3, ServiceStatus.UP))), modelUtils.createServiceCluster("cluster-2", new ServiceType("service-type-2"), Arrays.asList(modelUtils.createServiceInstance("config-id-5", hostName1, ServiceStatus.UP), modelUtils.createServiceInstance("config-id-6", hostName2, ServiceStatus.UP)))));
    verifyClustersInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName1), 1, 2, 3);
    verifyClustersInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName2), 2, 3);
    verifyClustersInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName3), 1);
    verifyClustersInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName4));
}
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

HostName (com.yahoo.vespa.applicationmodel.HostName)46 Test (org.junit.Test)20 ApplicationInstance (com.yahoo.vespa.applicationmodel.ApplicationInstance)14 ServiceType (com.yahoo.vespa.applicationmodel.ServiceType)13 ServiceCluster (com.yahoo.vespa.applicationmodel.ServiceCluster)9 ServiceInstance (com.yahoo.vespa.applicationmodel.ServiceInstance)9 ClusterId (com.yahoo.vespa.applicationmodel.ClusterId)8 HostStatus (com.yahoo.vespa.orchestrator.status.HostStatus)8 List (java.util.List)8 ApplicationId (com.yahoo.config.provision.ApplicationId)7 ApplicationInstanceReference (com.yahoo.vespa.applicationmodel.ApplicationInstanceReference)7 Orchestrator (com.yahoo.vespa.orchestrator.Orchestrator)7 Collectors (java.util.stream.Collectors)7 ApplicationInstanceId (com.yahoo.vespa.applicationmodel.ApplicationInstanceId)6 ConfigId (com.yahoo.vespa.applicationmodel.ConfigId)6 TenantId (com.yahoo.vespa.applicationmodel.TenantId)6 ServiceStatus (com.yahoo.vespa.applicationmodel.ServiceStatus)5 OrchestrationException (com.yahoo.vespa.orchestrator.OrchestrationException)5 StorageNode (com.yahoo.vespa.orchestrator.model.StorageNode)5 IOException (java.io.IOException)5