Search in sources :

Example 6 with ClusterId

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

the class VespaModelUtilTest method testGetContentClusterNameForSecondaryContentCluster.

@Test
public void testGetContentClusterNameForSecondaryContentCluster() {
    ClusterId contentClusterName = VespaModelUtil.getContentClusterName(application, secondaryDistributor0.hostName());
    assertThat(SECONDARY_CONTENT_CLUSTER_ID).isEqualTo(contentClusterName);
}
Also used : ClusterId(com.yahoo.vespa.applicationmodel.ClusterId) Test(org.junit.Test)

Example 7 with ClusterId

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

the class HostResourceTest method getHost_works.

@Test
public void getHost_works() throws Exception {
    Orchestrator orchestrator = mock(Orchestrator.class);
    HostResource hostResource = new HostResource(orchestrator, uriInfo);
    HostName hostName = new HostName("hostname");
    UriBuilder baseUriBuilder = mock(UriBuilder.class);
    when(uriInfo.getBaseUriBuilder()).thenReturn(baseUriBuilder);
    when(baseUriBuilder.path(any(String.class))).thenReturn(baseUriBuilder);
    when(baseUriBuilder.path(any(Class.class))).thenReturn(baseUriBuilder);
    URI uri = new URI("https://foo.com/bar");
    when(baseUriBuilder.build()).thenReturn(uri);
    ServiceInstance serviceInstance = new ServiceInstance(new ConfigId("configId"), hostName, ServiceStatus.UP);
    ServiceCluster serviceCluster = new ServiceCluster(new ClusterId("clusterId"), new ServiceType("serviceType"), Collections.singleton(serviceInstance));
    serviceInstance.setServiceCluster(serviceCluster);
    Host host = new Host(hostName, HostStatus.ALLOWED_TO_BE_DOWN, new ApplicationInstanceReference(new TenantId("tenantId"), new ApplicationInstanceId("applicationId")), Collections.singletonList(serviceInstance));
    when(orchestrator.getHost(hostName)).thenReturn(host);
    GetHostResponse response = hostResource.getHost(hostName.s());
    assertEquals("https://foo.com/bar", response.applicationUrl());
    assertEquals("hostname", response.hostname());
    assertEquals("ALLOWED_TO_BE_DOWN", response.state());
    assertEquals(1, response.services().size());
    assertEquals("clusterId", response.services().get(0).clusterId);
    assertEquals("configId", response.services().get(0).configId);
    assertEquals("UP", response.services().get(0).serviceStatus);
    assertEquals("serviceType", response.services().get(0).serviceType);
}
Also used : ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) ClusterId(com.yahoo.vespa.applicationmodel.ClusterId) ServiceInstance(com.yahoo.vespa.applicationmodel.ServiceInstance) Host(com.yahoo.vespa.orchestrator.Host) Orchestrator(com.yahoo.vespa.orchestrator.Orchestrator) URI(java.net.URI) ApplicationInstanceId(com.yahoo.vespa.applicationmodel.ApplicationInstanceId) TenantId(com.yahoo.vespa.applicationmodel.TenantId) GetHostResponse(com.yahoo.vespa.orchestrator.restapi.wire.GetHostResponse) ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) ApplicationInstanceReference(com.yahoo.vespa.applicationmodel.ApplicationInstanceReference) ConfigId(com.yahoo.vespa.applicationmodel.ConfigId) UriBuilder(javax.ws.rs.core.UriBuilder) HostName(com.yahoo.vespa.applicationmodel.HostName) Test(org.junit.Test)

Example 8 with ClusterId

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

the class InstanceResource method getServiceStatus.

@GET
@Path("/{instanceId}/serviceStatus")
@Produces(MediaType.APPLICATION_JSON)
public ServiceStatus getServiceStatus(@PathParam("instanceId") String instanceId, @QueryParam("clusterId") String clusterIdString, @QueryParam("serviceType") String serviceTypeString, @QueryParam("configId") String configIdString) {
    ApplicationInstanceReference reference = parseInstanceId(instanceId);
    ApplicationId applicationId = OrchestratorUtil.toApplicationId(reference);
    if (clusterIdString == null) {
        throwBadRequest("Missing clusterId query parameter");
    }
    if (serviceTypeString == null) {
        throwBadRequest("Missing serviceType query parameter");
    }
    if (configIdString == null) {
        throwBadRequest("Missing configId query parameter");
    }
    ClusterId clusterId = new ClusterId(clusterIdString);
    ServiceType serviceType = new ServiceType(serviceTypeString);
    ConfigId configId = new ConfigId(configIdString);
    return slobrokApi.getStatus(applicationId, clusterId, serviceType, configId);
}
Also used : ClusterId(com.yahoo.vespa.applicationmodel.ClusterId) ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) ApplicationInstanceReference(com.yahoo.vespa.applicationmodel.ApplicationInstanceReference) ConfigId(com.yahoo.vespa.applicationmodel.ConfigId) ApplicationId(com.yahoo.config.provision.ApplicationId) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 9 with ClusterId

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

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

the class OrchestratorImpl method setClusterStateInController.

private void setClusterStateInController(ApplicationInstance application, ClusterControllerNodeState state) throws ApplicationStateChangeDeniedException, ApplicationIdNotFoundException {
    // Get all content clusters for this application
    Set<ClusterId> contentClusterIds = application.serviceClusters().stream().filter(VespaModelUtil::isContent).map(ServiceCluster::clusterId).collect(Collectors.toSet());
    // For all content clusters set in maintenance
    log.log(LogLevel.INFO, String.format("Setting content clusters %s for application %s to %s", contentClusterIds, application.applicationInstanceId(), state));
    for (ClusterId clusterId : contentClusterIds) {
        List<HostName> clusterControllers = VespaModelUtil.getClusterControllerInstancesInOrder(application, clusterId);
        ClusterControllerClient client = clusterControllerClientFactory.createClient(clusterControllers, clusterId.s());
        try {
            ClusterControllerStateResponse response = client.setApplicationState(state);
            if (!response.wasModified) {
                String msg = String.format("Fail to set application %s, cluster name %s to cluster state %s due to: %s", application.applicationInstanceId(), clusterId, state, response.reason);
                throw new ApplicationStateChangeDeniedException(msg);
            }
        } catch (IOException e) {
            throw new ApplicationStateChangeDeniedException(e.getMessage());
        }
    }
}
Also used : ClusterId(com.yahoo.vespa.applicationmodel.ClusterId) ClusterControllerStateResponse(com.yahoo.vespa.orchestrator.controller.ClusterControllerStateResponse) ClusterControllerClient(com.yahoo.vespa.orchestrator.controller.ClusterControllerClient) VespaModelUtil(com.yahoo.vespa.orchestrator.model.VespaModelUtil) IOException(java.io.IOException) HostName(com.yahoo.vespa.applicationmodel.HostName)

Aggregations

ClusterId (com.yahoo.vespa.applicationmodel.ClusterId)14 ServiceType (com.yahoo.vespa.applicationmodel.ServiceType)7 Test (org.junit.Test)7 HostName (com.yahoo.vespa.applicationmodel.HostName)6 ApplicationInstanceReference (com.yahoo.vespa.applicationmodel.ApplicationInstanceReference)5 ConfigId (com.yahoo.vespa.applicationmodel.ConfigId)5 ApplicationInstance (com.yahoo.vespa.applicationmodel.ApplicationInstance)4 ApplicationInstanceId (com.yahoo.vespa.applicationmodel.ApplicationInstanceId)4 ServiceCluster (com.yahoo.vespa.applicationmodel.ServiceCluster)4 ServiceInstance (com.yahoo.vespa.applicationmodel.ServiceInstance)4 TenantId (com.yahoo.vespa.applicationmodel.TenantId)4 ApplicationId (com.yahoo.config.provision.ApplicationId)3 ServiceClusterKey (com.yahoo.vespa.applicationmodel.ServiceClusterKey)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 ApplicationInfo (com.yahoo.config.model.api.ApplicationInfo)1 HostInfo (com.yahoo.config.model.api.HostInfo)1 ServiceInfo (com.yahoo.config.model.api.ServiceInfo)1