Search in sources :

Example 1 with Id

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;
}
Also used : Response(com.yahoo.vespa.clustercontroller.core.restapiv2.Response) NodeType(com.yahoo.vdslib.state.NodeType) Id(com.yahoo.vespa.clustercontroller.core.restapiv2.Id)

Example 2 with Id

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);
}
Also used : TreeMap(java.util.TreeMap) ClusterControllerStateRestAPI(com.yahoo.vespa.clustercontroller.core.restapiv2.ClusterControllerStateRestAPI) ClusterInfoConfig(com.yahoo.cloud.config.ClusterInfoConfig) Test(org.junit.Test)

Example 3 with Id

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;
}
Also used : Response(com.yahoo.vespa.clustercontroller.core.restapiv2.Response) NodeInfo(com.yahoo.vespa.clustercontroller.core.NodeInfo) MissingResourceException(com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.MissingResourceException) Id(com.yahoo.vespa.clustercontroller.core.restapiv2.Id)

Aggregations

Id (com.yahoo.vespa.clustercontroller.core.restapiv2.Id)2 Response (com.yahoo.vespa.clustercontroller.core.restapiv2.Response)2 ClusterInfoConfig (com.yahoo.cloud.config.ClusterInfoConfig)1 NodeType (com.yahoo.vdslib.state.NodeType)1 NodeInfo (com.yahoo.vespa.clustercontroller.core.NodeInfo)1 ClusterControllerStateRestAPI (com.yahoo.vespa.clustercontroller.core.restapiv2.ClusterControllerStateRestAPI)1 MissingResourceException (com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.MissingResourceException)1 TreeMap (java.util.TreeMap)1 Test (org.junit.Test)1