Search in sources :

Example 1 with ConfigId

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

the class ModelGenerator method toServiceInstance.

private ServiceInstance toServiceInstance(ApplicationId applicationId, ClusterId clusterId, ServiceInfo serviceInfo, HostName hostName, ServiceStatusProvider serviceStatusProvider) {
    ConfigId configId = new ConfigId(serviceInfo.getConfigId());
    ServiceStatus status = serviceStatusProvider.getStatus(applicationId, clusterId, toServiceType(serviceInfo), configId);
    return new ServiceInstance(configId, hostName, status);
}
Also used : ServiceStatus(com.yahoo.vespa.applicationmodel.ServiceStatus) ServiceInstance(com.yahoo.vespa.applicationmodel.ServiceInstance) ConfigId(com.yahoo.vespa.applicationmodel.ConfigId)

Example 2 with ConfigId

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

the class InstanceResourceTest method testGetServiceStatus.

@Test
public void testGetServiceStatus() {
    ServiceType serviceType = new ServiceType("serviceType");
    ConfigId configId = new ConfigId("configId");
    ServiceStatus serviceStatus = ServiceStatus.UP;
    when(slobrokApi.getStatus(APPLICATION_ID, CLUSTER_ID, serviceType, configId)).thenReturn(serviceStatus);
    ServiceStatus actualServiceStatus = resource.getServiceStatus(APPLICATION_INSTANCE_REFERENCE, CLUSTER_ID.s(), serviceType.s(), configId.s());
    verify(slobrokApi).getStatus(APPLICATION_ID, CLUSTER_ID, serviceType, configId);
    assertEquals(serviceStatus, actualServiceStatus);
}
Also used : ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) ServiceStatus(com.yahoo.vespa.applicationmodel.ServiceStatus) ConfigId(com.yahoo.vespa.applicationmodel.ConfigId) Test(org.junit.Test)

Example 3 with ConfigId

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

the class VespaModelUtilTest method testGetClusterControllerIndex.

@Test
public void testGetClusterControllerIndex() {
    ConfigId configId = new ConfigId("admin/cluster-controllers/2");
    assertThat(VespaModelUtil.getClusterControllerIndex(configId)).isEqualTo(2);
}
Also used : ConfigId(com.yahoo.vespa.applicationmodel.ConfigId) Test(org.junit.Test)

Example 4 with ConfigId

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

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

the class StorageNodeImpl method setNodeState.

@Override
public void setNodeState(ClusterControllerNodeState wantedNodeState) throws HostStateChangeDeniedException {
    // The "cluster name" used by the Cluster Controller IS the cluster ID.
    String clusterId = this.clusterId.s();
    List<HostName> clusterControllers = VespaModelUtil.getClusterControllerInstancesInOrder(applicationInstance, this.clusterId);
    ClusterControllerClient client = clusterControllerClientFactory.createClient(clusterControllers, clusterId);
    ConfigId configId = storageService.configId();
    int nodeIndex = VespaModelUtil.getStorageNodeIndex(configId);
    logger.log(LogLevel.DEBUG, () -> "Setting cluster controller state for " + "application " + applicationInstance.reference().asString() + ", host " + hostName() + ", cluster name " + clusterId + ", node index " + nodeIndex + ", node state " + wantedNodeState);
    ClusterControllerStateResponse response;
    try {
        response = client.setNodeState(nodeIndex, wantedNodeState);
    } catch (IOException e) {
        throw new HostStateChangeDeniedException(hostName(), HostedVespaPolicy.CLUSTER_CONTROLLER_AVAILABLE_CONSTRAINT, "Failed to communicate with cluster controllers " + clusterControllers + ": " + e, e);
    }
    if (!response.wasModified) {
        throw new HostStateChangeDeniedException(hostName(), HostedVespaPolicy.SET_NODE_STATE_CONSTRAINT, "Failed to set state to " + wantedNodeState + " in cluster controller: " + response.reason);
    }
}
Also used : HostStateChangeDeniedException(com.yahoo.vespa.orchestrator.policy.HostStateChangeDeniedException) ClusterControllerStateResponse(com.yahoo.vespa.orchestrator.controller.ClusterControllerStateResponse) ClusterControllerClient(com.yahoo.vespa.orchestrator.controller.ClusterControllerClient) ConfigId(com.yahoo.vespa.applicationmodel.ConfigId) IOException(java.io.IOException) HostName(com.yahoo.vespa.applicationmodel.HostName)

Aggregations

ConfigId (com.yahoo.vespa.applicationmodel.ConfigId)13 Test (org.junit.Test)7 ServiceType (com.yahoo.vespa.applicationmodel.ServiceType)6 ClusterId (com.yahoo.vespa.applicationmodel.ClusterId)5 HostName (com.yahoo.vespa.applicationmodel.HostName)5 ServiceInstance (com.yahoo.vespa.applicationmodel.ServiceInstance)5 ApplicationInstanceId (com.yahoo.vespa.applicationmodel.ApplicationInstanceId)4 ApplicationInstanceReference (com.yahoo.vespa.applicationmodel.ApplicationInstanceReference)4 ServiceCluster (com.yahoo.vespa.applicationmodel.ServiceCluster)4 TenantId (com.yahoo.vespa.applicationmodel.TenantId)4 ApplicationInstance (com.yahoo.vespa.applicationmodel.ApplicationInstance)3 ServiceStatus (com.yahoo.vespa.applicationmodel.ServiceStatus)3 ApplicationId (com.yahoo.config.provision.ApplicationId)2 ConfigserverConfig (com.yahoo.cloud.config.ConfigserverConfig)1 Node (com.yahoo.vespa.hosted.provision.Node)1 Host (com.yahoo.vespa.orchestrator.Host)1 Orchestrator (com.yahoo.vespa.orchestrator.Orchestrator)1 OrchestratorConfig (com.yahoo.vespa.orchestrator.config.OrchestratorConfig)1 ClusterControllerClient (com.yahoo.vespa.orchestrator.controller.ClusterControllerClient)1 ClusterControllerClientFactory (com.yahoo.vespa.orchestrator.controller.ClusterControllerClientFactory)1