Search in sources :

Example 6 with ApplicationInstance

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

Example 7 with ApplicationInstance

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

the class ApplicationApiImplTest method verifyUpConditionWith.

private void verifyUpConditionWith(HostStatus hostStatus, ServiceStatus serviceStatus, boolean expectUp) {
    HostName hostName1 = modelUtils.createNode("host1", hostStatus);
    ApplicationInstance applicationInstance = modelUtils.createApplicationInstance(Arrays.asList(modelUtils.createServiceCluster("cluster-1", VespaModelUtil.STORAGENODE_SERVICE_TYPE, Arrays.asList(modelUtils.createServiceInstance("config-id-1", hostName1, serviceStatus)))));
    ApplicationApiImpl applicationApi = modelUtils.createApplicationApiImpl(applicationInstance, hostName1);
    List<HostName> upStorageNodes = expectUp ? Arrays.asList(hostName1) : new ArrayList<>();
    List<HostName> actualStorageNodes = applicationApi.getUpStorageNodesInGroupInClusterOrder().stream().map(storageNode -> storageNode.hostName()).collect(Collectors.toList());
    assertEquals(upStorageNodes, actualStorageNodes);
}
Also used : ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) Arrays(java.util.Arrays) List(java.util.List) HostName(com.yahoo.vespa.applicationmodel.HostName) HostStatus(com.yahoo.vespa.orchestrator.status.HostStatus) Test(org.junit.Test) ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ServiceStatus(com.yahoo.vespa.applicationmodel.ServiceStatus) Collectors(java.util.stream.Collectors) Assert.assertEquals(org.junit.Assert.assertEquals) ArrayList(java.util.ArrayList) ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) HostName(com.yahoo.vespa.applicationmodel.HostName)

Example 8 with ApplicationInstance

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

the class OrchestratorImplTest method testGetHost.

@Test
public void testGetHost() throws Exception {
    ClusterControllerClientFactory clusterControllerClientFactory = mock(ClusterControllerClientFactory.class);
    StatusService statusService = mock(StatusService.class);
    InstanceLookupService lookupService = mock(InstanceLookupService.class);
    orchestrator = new OrchestratorImpl(clusterControllerClientFactory, statusService, new OrchestratorConfig(new OrchestratorConfig.Builder()), lookupService);
    HostName hostName = new HostName("host.yahoo.com");
    TenantId tenantId = new TenantId("tenant");
    ApplicationInstanceId applicationInstanceId = new ApplicationInstanceId("applicationInstanceId");
    ApplicationInstanceReference reference = new ApplicationInstanceReference(tenantId, applicationInstanceId);
    ApplicationInstance applicationInstance = new ApplicationInstance(tenantId, applicationInstanceId, Stream.of(new ServiceCluster(new ClusterId("clusterId"), new ServiceType("serviceType"), Stream.of(new ServiceInstance(new ConfigId("configId1"), hostName, ServiceStatus.UP), new ServiceInstance(new ConfigId("configId2"), hostName, ServiceStatus.NOT_CHECKED)).collect(Collectors.toSet()))).collect(Collectors.toSet()));
    when(lookupService.findInstanceByHost(hostName)).thenReturn(Optional.of(applicationInstance));
    ReadOnlyStatusRegistry readOnlyStatusRegistry = mock(ReadOnlyStatusRegistry.class);
    when(statusService.forApplicationInstance(reference)).thenReturn(readOnlyStatusRegistry);
    when(readOnlyStatusRegistry.getHostStatus(hostName)).thenReturn(HostStatus.ALLOWED_TO_BE_DOWN);
    Host host = orchestrator.getHost(hostName);
    assertEquals(reference, host.getApplicationInstanceReference());
    assertEquals(hostName, host.getHostName());
    assertEquals(HostStatus.ALLOWED_TO_BE_DOWN, host.getHostStatus());
    assertEquals(2, host.getServiceInstances().size());
}
Also used : OrchestratorConfig(com.yahoo.vespa.orchestrator.config.OrchestratorConfig) ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) ClusterId(com.yahoo.vespa.applicationmodel.ClusterId) ServiceInstance(com.yahoo.vespa.applicationmodel.ServiceInstance) StatusService(com.yahoo.vespa.orchestrator.status.StatusService) InMemoryStatusService(com.yahoo.vespa.orchestrator.status.InMemoryStatusService) ApplicationInstanceId(com.yahoo.vespa.applicationmodel.ApplicationInstanceId) TenantId(com.yahoo.vespa.applicationmodel.TenantId) ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) ApplicationInstanceReference(com.yahoo.vespa.applicationmodel.ApplicationInstanceReference) ConfigId(com.yahoo.vespa.applicationmodel.ConfigId) ReadOnlyStatusRegistry(com.yahoo.vespa.orchestrator.status.ReadOnlyStatusRegistry) ClusterControllerClientFactory(com.yahoo.vespa.orchestrator.controller.ClusterControllerClientFactory) HostName(com.yahoo.vespa.applicationmodel.HostName) Test(org.junit.Test)

Example 9 with ApplicationInstance

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

the class OrchestratorImpl method resume.

@Override
public void resume(HostName hostName) throws HostStateChangeDeniedException, HostNameNotFoundException {
    /*
        * When making a state transition to this state, we have to consider that if the host has been in
        * ALLOWED_TO_BE_DOWN state, services on the host may recently have been stopped (and, presumably, started).
        * Service monitoring may not have had enough time to detect that services were stopped,
        * and may therefore mistakenly report services as up, even if they still haven't initialized and
        * are not yet ready for serving. Erroneously reporting both host and services as up causes a race
        * where services on other hosts may be stopped prematurely. A delay here ensures that service
        * monitoring will have had time to catch up. Since we don't want do the delay with the lock held,
        * and the host status service's locking functionality does not support something like condition
        * variables or Object.wait(), we break out here, releasing the lock before delaying.
        */
    sleep(serviceMonitorConvergenceLatencySeconds, TimeUnit.SECONDS);
    ApplicationInstance appInstance = getApplicationInstance(hostName);
    try (MutableStatusRegistry statusRegistry = statusService.lockApplicationInstance_forCurrentThreadOnly(appInstance.reference())) {
        final HostStatus currentHostState = statusRegistry.getHostStatus(hostName);
        if (HostStatus.NO_REMARKS == currentHostState) {
            return;
        }
        ApplicationInstanceStatus appStatus = statusService.forApplicationInstance(appInstance.reference()).getApplicationInstanceStatus();
        if (appStatus == ApplicationInstanceStatus.NO_REMARKS) {
            policy.releaseSuspensionGrant(appInstance, hostName, statusRegistry);
        }
    }
}
Also used : ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) MutableStatusRegistry(com.yahoo.vespa.orchestrator.status.MutableStatusRegistry) ApplicationInstanceStatus(com.yahoo.vespa.orchestrator.status.ApplicationInstanceStatus) HostStatus(com.yahoo.vespa.orchestrator.status.HostStatus)

Example 10 with ApplicationInstance

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

the class ApplicationApiImpl method getServiceClustersInGroup.

private static Set<ServiceCluster> getServiceClustersInGroup(NodeGroup nodeGroup) {
    ApplicationInstance applicationInstance = nodeGroup.getApplication();
    Set<ServiceCluster> serviceClustersInGroup = new HashSet<>();
    for (ServiceCluster cluster : applicationInstance.serviceClusters()) {
        for (ServiceInstance instance : cluster.serviceInstances()) {
            if (nodeGroup.contains(instance.hostName())) {
                serviceClustersInGroup.add(cluster);
                break;
            }
        }
    }
    return serviceClustersInGroup;
}
Also used : OrchestratorUtil.getHostsUsedByApplicationInstance(com.yahoo.vespa.orchestrator.OrchestratorUtil.getHostsUsedByApplicationInstance) ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) ServiceInstance(com.yahoo.vespa.applicationmodel.ServiceInstance) HashSet(java.util.HashSet)

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