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