use of com.yahoo.vespa.clustercontroller.core.restapiv2.Id in project vespa by vespa-engine.
the class ClusterStateRequest method calculateResult.
@Override
public Response.ClusterResponse calculateResult(RemoteClusterControllerTask.Context context) throws StateRestApiException {
Response.ClusterResponse result = new Response.ClusterResponse();
result.addState("generated", new Response.UnitStateImpl(context.currentConsolidatedState.getClusterState()));
for (NodeType type : NodeType.getTypes()) {
Id.Service serviceId = new Id.Service(id, type);
if (recursive > 0) {
ServiceStateRequest ssr = new ServiceStateRequest(serviceId, recursive - 1);
result.addEntry("service", type.toString(), ssr.calculateResult(context));
} else {
result.addLink("service", type.toString(), serviceId.toString());
}
}
result.setPublishedState(bundleToDistributionState(context.publishedClusterStateBundle));
return result;
}
use of com.yahoo.vespa.clustercontroller.core.restapiv2.Id in project vespa by vespa-engine.
the class StateRestApiV2HandlerTest method testMappingOfIndexToClusterControllers.
@Test
public void testMappingOfIndexToClusterControllers() {
ClusterInfoConfig.Builder builder = new ClusterInfoConfig.Builder().clusterId("cluster-id").nodeCount(1).services(new ClusterInfoConfig.Services.Builder().index(1).hostname("host-1").ports(new ClusterInfoConfig.Services.Ports.Builder().number(80).tags("state http")).ports(new ClusterInfoConfig.Services.Ports.Builder().number(81).tags("ignored port http"))).services(new ClusterInfoConfig.Services.Builder().index(3).hostname("host-3").ports(new ClusterInfoConfig.Services.Ports.Builder().number(85).tags("state http")).ports(new ClusterInfoConfig.Services.Ports.Builder().number(86).tags("foo http bar state")));
ClusterInfoConfig config = new ClusterInfoConfig(builder);
Map<Integer, ClusterControllerStateRestAPI.Socket> mapping = StateRestApiV2Handler.getClusterControllerSockets(config);
Map<Integer, ClusterControllerStateRestAPI.Socket> expected = new TreeMap<>();
expected.put(1, new ClusterControllerStateRestAPI.Socket("host-1", 80));
expected.put(3, new ClusterControllerStateRestAPI.Socket("host-3", 85));
assertEquals(expected, mapping);
}
use of com.yahoo.vespa.clustercontroller.core.restapiv2.Id in project vespa by vespa-engine.
the class NodeStateRequest method calculateResult.
@Override
public Response.NodeResponse calculateResult(RemoteClusterControllerTask.Context context) throws StateRestApiException {
Response.NodeResponse result = new Response.NodeResponse();
NodeInfo info = context.cluster.getNodeInfo(id.getNode());
if (info == null) {
throw new MissingResourceException("node " + id.getNode());
}
if (info.getGroup() != null) {
result.addAttribute("hierarchical-group", info.getGroup().getPath());
}
result.addState("generated", new Response.UnitStateImpl(context.currentConsolidatedState.getNodeState(id.getNode())));
result.addState("unit", new Response.UnitStateImpl(info.getReportedState()));
result.addState("user", new Response.UnitStateImpl(info.getWantedState()));
for (int i = 0; i < info.getReportedState().getDiskCount(); ++i) {
Id.Partition partitionId = new Id.Partition(id, i);
if (recursive > 0) {
PartitionStateRequest psr = new PartitionStateRequest(partitionId, verboseReports);
result.addEntry("partition", String.valueOf(i), psr.calculateResult(context));
} else {
result.addLink("partition", String.valueOf(i), partitionId.toString());
}
}
return result;
}
Aggregations