Search in sources :

Example 66 with NodeState

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

the class ClusterStateGenerator method generatedStateFrom.

static AnnotatedClusterState generatedStateFrom(final Params params) {
    final ContentCluster cluster = params.cluster;
    final ClusterState workingState = ClusterState.emptyState();
    final Map<Node, NodeStateReason> nodeStateReasons = new HashMap<>();
    for (final NodeInfo nodeInfo : cluster.getNodeInfo()) {
        final NodeState nodeState = computeEffectiveNodeState(nodeInfo, params);
        workingState.setNodeState(nodeInfo.getNode(), nodeState);
    }
    takeDownGroupsWithTooLowAvailability(workingState, nodeStateReasons, params);
    final Optional<ClusterStateReason> reasonToBeDown = clusterDownReason(workingState, params);
    if (reasonToBeDown.isPresent()) {
        workingState.setClusterState(State.DOWN);
    }
    workingState.setDistributionBits(inferDistributionBitCount(cluster, workingState, params));
    return new AnnotatedClusterState(workingState, reasonToBeDown, nodeStateReasons);
}
Also used : ClusterState(com.yahoo.vdslib.state.ClusterState) NodeState(com.yahoo.vdslib.state.NodeState) HashMap(java.util.HashMap) Node(com.yahoo.vdslib.state.Node)

Example 67 with NodeState

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

the class ClusterStateGenerator method takeDownGroupsWithTooLowAvailability.

private static void takeDownGroupsWithTooLowAvailability(final ClusterState workingState, Map<Node, NodeStateReason> nodeStateReasons, final Params params) {
    final GroupAvailabilityCalculator calc = new GroupAvailabilityCalculator.Builder().withMinNodeRatioPerGroup(params.minNodeRatioPerGroup).withDistribution(params.cluster.getDistribution()).build();
    final Set<Integer> nodesToTakeDown = calc.nodesThatShouldBeDown(workingState);
    for (Integer idx : nodesToTakeDown) {
        final Node node = storageNode(idx);
        final NodeState newState = new NodeState(NodeType.STORAGE, State.DOWN);
        newState.setDescription("group node availability below configured threshold");
        workingState.setNodeState(node, newState);
        nodeStateReasons.put(node, NodeStateReason.GROUP_IS_DOWN);
    }
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) Node(com.yahoo.vdslib.state.Node)

Example 68 with NodeState

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

the class EventDiffCalculator method emitSingleNodeEvents.

private static void emitSingleNodeEvents(PerStateParams params, List<Event> events, ContentCluster cluster, ClusterState fromState, ClusterState toState, Node n) {
    final NodeState nodeFrom = fromState.getNodeState(n);
    final NodeState nodeTo = toState.getNodeState(n);
    if (!nodeTo.equals(nodeFrom)) {
        final NodeInfo info = cluster.getNodeInfo(n);
        events.add(createNodeEvent(info, String.format("Altered node state in cluster state from '%s' to '%s'", nodeFrom.toString(true), nodeTo.toString(true)), params));
        NodeStateReason prevReason = params.fromState.getNodeStateReasons().get(n);
        NodeStateReason currReason = params.toState.getNodeStateReasons().get(n);
        if (isGroupDownEdge(prevReason, currReason)) {
            events.add(createNodeEvent(info, "Group node availability is below configured threshold", params));
        } else if (isGroupUpEdge(prevReason, currReason)) {
            events.add(createNodeEvent(info, "Group node availability has been restored", params));
        } else if (isMayHaveMergesPendingUpEdge(prevReason, currReason)) {
            events.add(createNodeEvent(info, "Node may have merges pending", params));
        } else if (isMayHaveMergesPendingDownEdge(prevReason, currReason)) {
            events.add(createNodeEvent(info, "Node no longer have merges pending", params));
        }
    }
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState)

Aggregations

NodeState (com.yahoo.vdslib.state.NodeState)68 Node (com.yahoo.vdslib.state.Node)31 Test (org.junit.Test)30 ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)21 ClusterState (com.yahoo.vdslib.state.ClusterState)11 NodeInfo (com.yahoo.vespa.clustercontroller.core.NodeInfo)6 Request (com.yahoo.jrt.Request)5 Target (com.yahoo.jrt.Target)5 State (com.yahoo.vdslib.state.State)5 ClusterFixture.storageNode (com.yahoo.vespa.clustercontroller.core.ClusterFixture.storageNode)5 HasStateReasonForNode.hasStateReasonForNode (com.yahoo.vespa.clustercontroller.core.matchers.HasStateReasonForNode.hasStateReasonForNode)5 Spec (com.yahoo.jrt.Spec)4 StringValue (com.yahoo.jrt.StringValue)4 Supervisor (com.yahoo.jrt.Supervisor)4 Transport (com.yahoo.jrt.Transport)4 DiskState (com.yahoo.vdslib.state.DiskState)4 ArrayList (java.util.ArrayList)4 PrintWriter (java.io.PrintWriter)3 StringWriter (java.io.StringWriter)3 HashSet (java.util.HashSet)3