Search in sources :

Example 1 with MissingResourceException

use of com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.MissingResourceException 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

NodeInfo (com.yahoo.vespa.clustercontroller.core.NodeInfo)1 Id (com.yahoo.vespa.clustercontroller.core.restapiv2.Id)1 Response (com.yahoo.vespa.clustercontroller.core.restapiv2.Response)1 MissingResourceException (com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.MissingResourceException)1