Search in sources :

Example 6 with State

use of com.yahoo.vdslib.state.State in project vespa by vespa-engine.

the class NodeStateChangeChecker method contentNodesWithAvailableNodeState.

private int contentNodesWithAvailableNodeState(ClusterState clusterState) {
    final int nodeCount = clusterState.getNodeCount(NodeType.STORAGE);
    int upNodesCount = 0;
    for (int i = 0; i < nodeCount; ++i) {
        final Node node = new Node(NodeType.STORAGE, i);
        final State state = clusterState.getNodeState(node).getState();
        if (state == State.UP || state == State.RETIRED || state == State.INITIALIZING) {
            upNodesCount++;
        }
    }
    return upNodesCount;
}
Also used : ClusterState(com.yahoo.vdslib.state.ClusterState) NodeState(com.yahoo.vdslib.state.NodeState) State(com.yahoo.vdslib.state.State) StorageNode(com.yahoo.vespa.clustercontroller.core.hostinfo.StorageNode) Node(com.yahoo.vdslib.state.Node)

Example 7 with State

use of com.yahoo.vdslib.state.State in project vespa by vespa-engine.

the class NodeStateChangeChecker method canSetStateDownPermanently.

private Result canSetStateDownPermanently(NodeInfo nodeInfo, ClusterState clusterState) {
    State reportedState = nodeInfo.getReportedState().getState();
    if (reportedState != State.UP) {
        return Result.createDisallowed("Reported state (" + reportedState + ") is not UP, so no bucket data is available");
    }
    State currentState = clusterState.getNodeState(nodeInfo.getNode()).getState();
    if (currentState != State.RETIRED) {
        return Result.createDisallowed("Only retired nodes are allowed to be set to DOWN in safe mode - is " + currentState);
    }
    Result thresholdCheckResult = checkUpThresholds(clusterState);
    if (!thresholdCheckResult.settingWantedStateIsAllowed()) {
        return thresholdCheckResult;
    }
    HostInfo hostInfo = nodeInfo.getHostInfo();
    Integer hostInfoNodeVersion = hostInfo.getClusterStateVersionOrNull();
    int clusterControllerVersion = clusterState.getVersion();
    if (hostInfoNodeVersion == null || hostInfoNodeVersion != clusterControllerVersion) {
        return Result.createDisallowed("Cluster controller at version " + clusterControllerVersion + " got info for storage node " + nodeInfo.getNodeIndex() + " at a different version " + hostInfoNodeVersion);
    }
    Optional<Metrics.Value> bucketsMetric = hostInfo.getMetrics().getValue(BUCKETS_METRIC_NAME);
    if (!bucketsMetric.isPresent() || bucketsMetric.get().getLast() == null) {
        return Result.createDisallowed("Missing last value of the " + BUCKETS_METRIC_NAME + " metric for storage node " + nodeInfo.getNodeIndex());
    }
    long lastBuckets = bucketsMetric.get().getLast();
    if (lastBuckets > 0) {
        return Result.createDisallowed("The storage node manages " + lastBuckets + " buckets");
    }
    return Result.allowSettingOfWantedState();
}
Also used : ClusterState(com.yahoo.vdslib.state.ClusterState) NodeState(com.yahoo.vdslib.state.NodeState) State(com.yahoo.vdslib.state.State) HostInfo(com.yahoo.vespa.clustercontroller.core.hostinfo.HostInfo)

Aggregations

ClusterState (com.yahoo.vdslib.state.ClusterState)7 NodeState (com.yahoo.vdslib.state.NodeState)7 State (com.yahoo.vdslib.state.State)7 Node (com.yahoo.vdslib.state.Node)4 UnitState (com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitState)2 ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)1 NodeInfo (com.yahoo.vespa.clustercontroller.core.NodeInfo)1 HostInfo (com.yahoo.vespa.clustercontroller.core.hostinfo.HostInfo)1 StorageNode (com.yahoo.vespa.clustercontroller.core.hostinfo.StorageNode)1 InvalidContentException (com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.InvalidContentException)1 HashSet (java.util.HashSet)1