Search in sources :

Example 1 with MissingIdException

use of com.yahoo.vespa.clustercontroller.core.restapiv2.MissingIdException in project vespa by vespa-engine.

the class SetNodeStateRequest method setWantedState.

static SetResponse setWantedState(ContentCluster cluster, SetUnitStateRequest.Condition condition, Map<String, UnitState> newStates, Node node, NodeStateOrHostInfoChangeHandler stateListener, ClusterState currentClusterState) throws StateRestApiException {
    if (!cluster.hasConfiguredNode(node.getIndex())) {
        throw new MissingIdException(cluster.getName(), node);
    }
    NodeInfo nodeInfo = cluster.getNodeInfo(node);
    if (nodeInfo == null)
        throw new IllegalArgumentException("Cannot set the wanted state of unknown node " + node);
    NodeState wantedState = nodeInfo.getUserWantedState();
    NodeState newWantedState = getRequestedNodeState(newStates, node);
    NodeStateChangeChecker.Result result = cluster.calculateEffectOfNewState(node, currentClusterState, condition, wantedState, newWantedState);
    log.log(LogLevel.DEBUG, "node=" + node + " current-cluster-state=" + // Includes version in output format
    currentClusterState + " condition=" + condition + " wanted-state=" + wantedState + " new-wanted-state=" + newWantedState + " change-check=" + result);
    boolean success = setWantedStateAccordingToResult(result, newWantedState, condition, nodeInfo, cluster, stateListener);
    // If the state was successfully set, just return an "ok" message back.
    String reason = success ? "ok" : result.getReason();
    return new SetResponse(reason, success);
}
Also used : SetResponse(com.yahoo.vespa.clustercontroller.utils.staterestapi.response.SetResponse) NodeState(com.yahoo.vdslib.state.NodeState) MissingIdException(com.yahoo.vespa.clustercontroller.core.restapiv2.MissingIdException) NodeInfo(com.yahoo.vespa.clustercontroller.core.NodeInfo) NodeStateChangeChecker(com.yahoo.vespa.clustercontroller.core.NodeStateChangeChecker)

Aggregations

NodeState (com.yahoo.vdslib.state.NodeState)1 NodeInfo (com.yahoo.vespa.clustercontroller.core.NodeInfo)1 NodeStateChangeChecker (com.yahoo.vespa.clustercontroller.core.NodeStateChangeChecker)1 MissingIdException (com.yahoo.vespa.clustercontroller.core.restapiv2.MissingIdException)1 SetResponse (com.yahoo.vespa.clustercontroller.utils.staterestapi.response.SetResponse)1