Search in sources :

Example 41 with HostName

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

the class ApplicationApiImplTest method testGetUpStorageNodesInGroupInClusterOrder.

@Test
public void testGetUpStorageNodesInGroupInClusterOrder() {
    HostName hostName1 = new HostName("host1");
    HostName hostName2 = new HostName("host2");
    HostName hostName3 = new HostName("host3");
    HostName hostName4 = new HostName("host4");
    HostName hostName5 = new HostName("host5");
    HostName hostName6 = new HostName("host6");
    HostName hostName7 = new HostName("host7");
    ApplicationInstance applicationInstance = modelUtils.createApplicationInstance(Arrays.asList(modelUtils.createServiceCluster("cluster-3", VespaModelUtil.STORAGENODE_SERVICE_TYPE, Arrays.asList(modelUtils.createServiceInstance("config-id-30", hostName1, ServiceStatus.UP), modelUtils.createServiceInstance("config-id-31", hostName2, ServiceStatus.UP))), modelUtils.createServiceCluster("cluster-1", VespaModelUtil.STORAGENODE_SERVICE_TYPE, Arrays.asList(modelUtils.createServiceInstance("config-id-10", hostName3, ServiceStatus.DOWN), modelUtils.createServiceInstance("config-id-11", hostName4, ServiceStatus.UP))), modelUtils.createServiceCluster("cluster-4", new ServiceType("service-type-4"), Arrays.asList(modelUtils.createServiceInstance("config-id-40", hostName1, ServiceStatus.UP), modelUtils.createServiceInstance("config-id-41", hostName2, ServiceStatus.UP), modelUtils.createServiceInstance("config-id-42", hostName3, ServiceStatus.UP), modelUtils.createServiceInstance("config-id-43", hostName5, ServiceStatus.UP))), modelUtils.createServiceCluster("cluster-2", VespaModelUtil.STORAGENODE_SERVICE_TYPE, Arrays.asList(modelUtils.createServiceInstance("config-id-20", hostName6, ServiceStatus.DOWN), modelUtils.createServiceInstance("config-id-21", hostName7, ServiceStatus.UP)))));
    verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName1), hostName1);
    verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName2), hostName2);
    // host3 is DOWN
    verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName3));
    verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName4), hostName4);
    // not a storage cluster
    verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName5));
    verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName1, hostName3), hostName1);
    // For the node group (host1, host4), they both have an up storage node (service instance)
    // with clusters (cluster-3, cluster-1) respectively, and so the order of the hosts are reversed
    // (host4, host1) when sorted by the clusters.
    verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName1, hostName4), hostName4, hostName1);
    verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName1, hostName4, hostName5), hostName4, hostName1);
    verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName1, hostName4, hostName5, hostName6), hostName4, hostName1);
    verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName1, hostName4, hostName5, hostName7), hostName4, hostName7, hostName1);
}
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 42 with HostName

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

the class ApplicationApiImplTest method testGetStorageNodesAllowedToBeDownInGroupInReverseClusterOrder.

@Test
public void testGetStorageNodesAllowedToBeDownInGroupInReverseClusterOrder() {
    HostName allowedToBeDownHost1 = modelUtils.createNode("host1", HostStatus.ALLOWED_TO_BE_DOWN);
    HostName noRemarksHost2 = modelUtils.createNode("host2", HostStatus.NO_REMARKS);
    HostName allowedToBeDownHost3 = modelUtils.createNode("host3", HostStatus.ALLOWED_TO_BE_DOWN);
    HostName allowedToBeDownHost4 = modelUtils.createNode("host4", HostStatus.ALLOWED_TO_BE_DOWN);
    HostName noRemarksHost5 = modelUtils.createNode("host5", HostStatus.ALLOWED_TO_BE_DOWN);
    HostName noRemarksHost6 = modelUtils.createNode("host6", HostStatus.NO_REMARKS);
    HostName allowedToBeDownHost7 = modelUtils.createNode("host7", HostStatus.ALLOWED_TO_BE_DOWN);
    ApplicationInstance applicationInstance = modelUtils.createApplicationInstance(Arrays.asList(modelUtils.createServiceCluster("cluster-4", VespaModelUtil.STORAGENODE_SERVICE_TYPE, Arrays.asList(modelUtils.createServiceInstance("config-id-40", allowedToBeDownHost1, ServiceStatus.UP), modelUtils.createServiceInstance("config-id-41", noRemarksHost2, ServiceStatus.DOWN))), modelUtils.createServiceCluster("cluster-1", new ServiceType("service-type-1"), Arrays.asList(modelUtils.createServiceInstance("config-id-10", allowedToBeDownHost1, ServiceStatus.UP), modelUtils.createServiceInstance("config-id-11", allowedToBeDownHost3, ServiceStatus.UP))), modelUtils.createServiceCluster("cluster-3", VespaModelUtil.STORAGENODE_SERVICE_TYPE, Arrays.asList(modelUtils.createServiceInstance("config-id-30", allowedToBeDownHost4, ServiceStatus.UP), modelUtils.createServiceInstance("config-id-31", noRemarksHost5, ServiceStatus.UP))), modelUtils.createServiceCluster("cluster-2", VespaModelUtil.STORAGENODE_SERVICE_TYPE, Arrays.asList(modelUtils.createServiceInstance("config-id-20", noRemarksHost6, ServiceStatus.UP), modelUtils.createServiceInstance("config-id-21", allowedToBeDownHost7, ServiceStatus.UP)))));
    verifyStorageNodesAllowedToBeDown(modelUtils.createApplicationApiImpl(applicationInstance, allowedToBeDownHost1), allowedToBeDownHost1);
    verifyStorageNodesAllowedToBeDown(modelUtils.createApplicationApiImpl(applicationInstance, noRemarksHost2));
    verifyStorageNodesAllowedToBeDown(modelUtils.createApplicationApiImpl(applicationInstance, allowedToBeDownHost3));
    verifyStorageNodesAllowedToBeDown(modelUtils.createApplicationApiImpl(applicationInstance, allowedToBeDownHost1, noRemarksHost6), allowedToBeDownHost1);
    // allowedToBeDownHost4 is in cluster-3, while allowedToBeDownHost1 is in cluster-4, so allowedToBeDownHost4 should be ordered
    // before allowedToBeDownHost1.
    verifyStorageNodesAllowedToBeDown(modelUtils.createApplicationApiImpl(applicationInstance, allowedToBeDownHost1, noRemarksHost6, allowedToBeDownHost4), allowedToBeDownHost4, allowedToBeDownHost1);
    verifyStorageNodesAllowedToBeDown(modelUtils.createApplicationApiImpl(applicationInstance, allowedToBeDownHost1, allowedToBeDownHost4, allowedToBeDownHost7), allowedToBeDownHost7, allowedToBeDownHost4, allowedToBeDownHost1);
    verifyStorageNodesAllowedToBeDown(modelUtils.createApplicationApiImpl(applicationInstance, allowedToBeDownHost4, allowedToBeDownHost1, allowedToBeDownHost7), allowedToBeDownHost7, allowedToBeDownHost4, allowedToBeDownHost1);
}
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 43 with HostName

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

the class HostedVespaPolicyTest method testAcquirePermissionToRemove.

@Test
public void testAcquirePermissionToRemove() throws OrchestrationException {
    final HostedVespaClusterPolicy clusterPolicy = mock(HostedVespaClusterPolicy.class);
    final HostedVespaPolicy policy = new HostedVespaPolicy(clusterPolicy, clientFactory);
    final ApplicationApi applicationApi = mock(ApplicationApi.class);
    when(applicationApi.applicationId()).thenReturn(ApplicationId.fromSerializedForm("tenant:app:default"));
    ClusterApi clusterApi1 = mock(ClusterApi.class);
    ClusterApi clusterApi2 = mock(ClusterApi.class);
    ClusterApi clusterApi3 = mock(ClusterApi.class);
    List<ClusterApi> clusterApis = Arrays.asList(clusterApi1, clusterApi2, clusterApi3);
    when(applicationApi.getClusters()).thenReturn(clusterApis);
    StorageNode storageNode1 = mock(StorageNode.class);
    HostName hostName1 = new HostName("storage-1");
    when(storageNode1.hostName()).thenReturn(hostName1);
    HostName hostName2 = new HostName("host-2");
    StorageNode storageNode3 = mock(StorageNode.class);
    HostName hostName3 = new HostName("storage-3");
    when(storageNode1.hostName()).thenReturn(hostName3);
    List<StorageNode> upStorageNodes = Arrays.asList(storageNode1, storageNode3);
    when(applicationApi.getStorageNodesInGroupInClusterOrder()).thenReturn(upStorageNodes);
    List<HostName> noRemarksHostNames = Arrays.asList(hostName1, hostName2, hostName3);
    when(applicationApi.getNodesInGroupWithStatus(HostStatus.NO_REMARKS)).thenReturn(noRemarksHostNames);
    InOrder order = inOrder(applicationApi, clusterPolicy, storageNode1, storageNode3);
    policy.acquirePermissionToRemove(applicationApi);
    order.verify(applicationApi).getClusters();
    order.verify(clusterPolicy).verifyGroupGoingDownPermanentlyIsFine(clusterApi1);
    order.verify(clusterPolicy).verifyGroupGoingDownPermanentlyIsFine(clusterApi2);
    order.verify(clusterPolicy).verifyGroupGoingDownPermanentlyIsFine(clusterApi3);
    order.verify(applicationApi).getStorageNodesInGroupInClusterOrder();
    order.verify(storageNode1).setNodeState(ClusterControllerNodeState.DOWN);
    order.verify(storageNode3).setNodeState(ClusterControllerNodeState.DOWN);
    order.verify(applicationApi).getNodesInGroupWithStatus(HostStatus.NO_REMARKS);
    order.verify(applicationApi).setHostState(hostName1, HostStatus.ALLOWED_TO_BE_DOWN);
    order.verify(applicationApi).setHostState(hostName2, HostStatus.ALLOWED_TO_BE_DOWN);
    order.verify(applicationApi).setHostState(hostName3, HostStatus.ALLOWED_TO_BE_DOWN);
    order.verifyNoMoreInteractions();
}
Also used : ClusterApi(com.yahoo.vespa.orchestrator.model.ClusterApi) InOrder(org.mockito.InOrder) ApplicationApi(com.yahoo.vespa.orchestrator.model.ApplicationApi) StorageNode(com.yahoo.vespa.orchestrator.model.StorageNode) HostName(com.yahoo.vespa.applicationmodel.HostName) Test(org.junit.Test)

Example 44 with HostName

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

the class InstanceResource method getInstance.

@GET
@Path("/{instanceId}")
@Produces(MediaType.APPLICATION_JSON)
public InstanceStatusResponse getInstance(@PathParam("instanceId") String instanceIdString) {
    ApplicationInstanceReference instanceId = parseInstanceId(instanceIdString);
    ApplicationInstance applicationInstance = instanceLookupService.findInstanceById(instanceId).orElseThrow(() -> new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build()));
    Set<HostName> hostsUsedByApplicationInstance = getHostsUsedByApplicationInstance(applicationInstance);
    Map<HostName, HostStatus> hostStatusMap = getHostStatusMap(hostsUsedByApplicationInstance, statusService.forApplicationInstance(instanceId));
    Map<HostName, String> hostStatusStringMap = OrchestratorUtil.mapValues(hostStatusMap, HostStatus::name);
    return InstanceStatusResponse.create(applicationInstance, hostStatusStringMap);
}
Also used : OrchestratorUtil.getHostsUsedByApplicationInstance(com.yahoo.vespa.orchestrator.OrchestratorUtil.getHostsUsedByApplicationInstance) ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) WebApplicationException(javax.ws.rs.WebApplicationException) ApplicationInstanceReference(com.yahoo.vespa.applicationmodel.ApplicationInstanceReference) HostStatus(com.yahoo.vespa.orchestrator.status.HostStatus) HostName(com.yahoo.vespa.applicationmodel.HostName) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 45 with HostName

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

the class HostResourceTest method patch_handles_exception_in_orchestrator.

@Test(expected = InternalServerErrorException.class)
public void patch_handles_exception_in_orchestrator() throws OrchestrationException {
    Orchestrator orchestrator = mock(Orchestrator.class);
    HostResource hostResource = new HostResource(orchestrator, uriInfo);
    String hostNameString = "hostname";
    PatchHostRequest request = new PatchHostRequest();
    request.state = "NO_REMARKS";
    doThrow(new OrchestrationException("error")).when(orchestrator).setNodeStatus(new HostName(hostNameString), HostStatus.NO_REMARKS);
    hostResource.patch(hostNameString, request);
}
Also used : OrchestrationException(com.yahoo.vespa.orchestrator.OrchestrationException) PatchHostRequest(com.yahoo.vespa.orchestrator.restapi.wire.PatchHostRequest) Orchestrator(com.yahoo.vespa.orchestrator.Orchestrator) 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