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);
}
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);
}
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);
}
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);
}
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);
}
}
Aggregations