Search in sources :

Example 1 with NodeState

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

the class ClusterStateView method getIndicesOfUpNodes.

/**
 * Returns the set of nodes that are up for a given node type. Non-private for testing.
 */
static Set<Integer> getIndicesOfUpNodes(ClusterState clusterState, NodeType type) {
    int nodeCount = clusterState.getNodeCount(type);
    Set<Integer> nodesBeingUp = new HashSet<>();
    for (int i = 0; i < nodeCount; ++i) {
        Node node = new Node(type, i);
        NodeState nodeState = clusterState.getNodeState(node);
        State state = nodeState.getState();
        if (state == State.UP || state == State.INITIALIZING || state == State.RETIRED || state == State.MAINTENANCE) {
            nodesBeingUp.add(i);
        }
    }
    return nodesBeingUp;
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) ClusterState(com.yahoo.vdslib.state.ClusterState) NodeState(com.yahoo.vdslib.state.NodeState) State(com.yahoo.vdslib.state.State) Node(com.yahoo.vdslib.state.Node) HashSet(java.util.HashSet)

Example 2 with NodeState

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

the class ClusterStateGenerator method computeEffectiveNodeState.

private static NodeState computeEffectiveNodeState(final NodeInfo nodeInfo, final Params params) {
    final NodeState reported = nodeInfo.getReportedState();
    final NodeState wanted = nodeInfo.getWantedState();
    final NodeState baseline = reported.clone();
    if (nodeIsConsideredTooUnstable(nodeInfo, params)) {
        baseline.setState(State.DOWN);
    }
    if (startupTimestampAlreadyObservedByAllNodes(nodeInfo, baseline)) {
        baseline.setStartTimestamp(0);
    }
    if (nodeInfo.isStorage()) {
        applyStorageSpecificStateTransforms(nodeInfo, params, reported, wanted, baseline);
    }
    if (baseline.above(wanted)) {
        applyWantedStateToBaselineState(baseline, wanted);
    }
    return baseline;
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState)

Example 3 with NodeState

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

the class ClusterStateGeneratorTest method reported_disk_state_not_hidden_by_wanted_state.

@Test
public void reported_disk_state_not_hidden_by_wanted_state() {
    final NodeState stateWithDisks = new NodeState(NodeType.STORAGE, State.UP);
    stateWithDisks.setDiskCount(5);
    stateWithDisks.setDiskState(3, new DiskState(State.DOWN));
    final ClusterFixture fixture = ClusterFixture.forFlatCluster(9).bringEntireClusterUp().reportStorageNodeState(2, stateWithDisks).proposeStorageNodeWantedState(2, State.RETIRED).reportStorageNodeState(3, stateWithDisks).proposeStorageNodeWantedState(3, State.MAINTENANCE);
    final AnnotatedClusterState state = generateFromFixtureWithDefaultParams(fixture);
    // We do not publish disk states for nodes in Down state. This differs from how the
    // legacy controller did things, but such states cannot be counted on for ideal state
    // calculations either way. In particular, reported disk states are not persisted and
    // only exist transiently in the cluster controller's memory. A controller restart is
    // sufficient to clear all disk states that have been incidentally remembered for now
    // downed nodes.
    // The keen reader may choose to convince themselves of this independently by reading the
    // code in com.yahoo.vdslib.distribution.Distribution#getIdealStorageNodes and observing
    // how disk states for nodes that are in a down-state are never considered.
    assertThat(state.toString(), equalTo("distributor:9 storage:9 .2.s:r .2.d:5 .2.d.3.s:d " + ".3.s:m .3.d:5 .3.d.3.s:d"));
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) DiskState(com.yahoo.vdslib.state.DiskState) Test(org.junit.Test)

Example 4 with NodeState

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

the class ClusterStateGeneratorTest method storage_node_with_crashes_but_not_unstable_init_does_not_have_init_state_substituted_by_down.

@Test
public void storage_node_with_crashes_but_not_unstable_init_does_not_have_init_state_substituted_by_down() {
    final ClusterFixture fixture = ClusterFixture.forFlatCluster(5).bringEntireClusterUp().reportStorageNodeState(0, new NodeState(NodeType.STORAGE, State.INITIALIZING).setInitProgress(0.5));
    final NodeInfo nodeInfo = fixture.cluster.getNodeInfo(new Node(NodeType.STORAGE, 0));
    nodeInfo.setPrematureCrashCount(5);
    final AnnotatedClusterState state = generateFromFixtureWithDefaultParams(fixture);
    assertThat(state.toString(), equalTo("distributor:5 storage:5 .0.s:i .0.i:0.5"));
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) ClusterFixture.storageNode(com.yahoo.vespa.clustercontroller.core.ClusterFixture.storageNode) Node(com.yahoo.vdslib.state.Node) HasStateReasonForNode.hasStateReasonForNode(com.yahoo.vespa.clustercontroller.core.matchers.HasStateReasonForNode.hasStateReasonForNode) Test(org.junit.Test)

Example 5 with NodeState

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

the class ClusterStateGeneratorTest method distribution_bits_bounded_by_lowest_reporting_storage_node.

@Test
public void distribution_bits_bounded_by_lowest_reporting_storage_node() {
    final ClusterFixture fixture = ClusterFixture.forFlatCluster(3).bringEntireClusterUp().reportStorageNodeState(0, new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(6)).reportStorageNodeState(1, new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(5));
    final AnnotatedClusterState state = generateFromFixtureWithDefaultParams(fixture);
    assertThat(state.toString(), equalTo("bits:5 distributor:3 storage:3"));
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) Test(org.junit.Test)

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