Search in sources :

Example 1 with Node

use of com.yahoo.vdslib.state.Node 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 Node

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

the class ClusterStateGeneratorTest method transient_maintenance_mode_does_not_override_wanted_down_state.

@Test
public void transient_maintenance_mode_does_not_override_wanted_down_state() {
    final ClusterFixture fixture = ClusterFixture.forFlatCluster(5).bringEntireClusterUp();
    final ClusterStateGenerator.Params params = fixture.generatorParams().currentTimeInMilllis(10_000).transitionTimes(2000);
    fixture.proposeStorageNodeWantedState(2, State.DOWN);
    fixture.reportStorageNodeState(2, State.DOWN);
    final NodeInfo nodeInfo = fixture.cluster.getNodeInfo(new Node(NodeType.STORAGE, 2));
    nodeInfo.setTransitionTime(9000);
    final AnnotatedClusterState state = ClusterStateGenerator.generatedStateFrom(params);
    // Should _not_ be in maintenance mode, since we explicitly want it to stay down.
    assertThat(state.toString(), equalTo("distributor:5 storage:5 .2.s:d"));
}
Also used : 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 3 with Node

use of com.yahoo.vdslib.state.Node 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 4 with Node

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

the class ClusterStateGeneratorTest method distributor_nodes_are_not_implicitly_transitioned_to_maintenance_mode.

@Test
public void distributor_nodes_are_not_implicitly_transitioned_to_maintenance_mode() {
    final ClusterFixture fixture = ClusterFixture.forFlatCluster(5).bringEntireClusterUp();
    final ClusterStateGenerator.Params params = fixture.generatorParams().currentTimeInMilllis(10_000).transitionTimes(2000);
    fixture.reportDistributorNodeState(2, State.DOWN);
    final NodeInfo nodeInfo = fixture.cluster.getNodeInfo(new Node(NodeType.DISTRIBUTOR, 2));
    nodeInfo.setTransitionTime(9000);
    final AnnotatedClusterState state = ClusterStateGenerator.generatedStateFrom(params);
    assertThat(state.toString(), equalTo("distributor:5 .2.s:d storage:5"));
}
Also used : 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 Node

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

the class ClusterStateGeneratorTest method reported_down_retired_node_within_transition_time_transitions_to_maintenance.

@Test
public void reported_down_retired_node_within_transition_time_transitions_to_maintenance() {
    final ClusterFixture fixture = ClusterFixture.forFlatCluster(5).bringEntireClusterUp();
    final ClusterStateGenerator.Params params = fixture.generatorParams().currentTimeInMilllis(10_000).transitionTimes(2000);
    fixture.proposeStorageNodeWantedState(2, State.RETIRED);
    fixture.reportStorageNodeState(2, State.DOWN);
    final NodeInfo nodeInfo = fixture.cluster.getNodeInfo(new Node(NodeType.STORAGE, 2));
    nodeInfo.setTransitionTime(9000);
    final AnnotatedClusterState state = ClusterStateGenerator.generatedStateFrom(params);
    assertThat(state.toString(), equalTo("distributor:5 storage:5 .2.s:m"));
}
Also used : 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)

Aggregations

Node (com.yahoo.vdslib.state.Node)65 Test (org.junit.Test)34 NodeState (com.yahoo.vdslib.state.NodeState)32 ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)31 ClusterFixture.storageNode (com.yahoo.vespa.clustercontroller.core.ClusterFixture.storageNode)15 HasStateReasonForNode.hasStateReasonForNode (com.yahoo.vespa.clustercontroller.core.matchers.HasStateReasonForNode.hasStateReasonForNode)15 ClusterState (com.yahoo.vdslib.state.ClusterState)9 NodeInfo (com.yahoo.vespa.clustercontroller.core.NodeInfo)6 NodeType (com.yahoo.vdslib.state.NodeType)5 PrintWriter (java.io.PrintWriter)5 StringWriter (java.io.StringWriter)5 Request (com.yahoo.jrt.Request)4 State (com.yahoo.vdslib.state.State)4 IOException (java.io.IOException)4 Spec (com.yahoo.jrt.Spec)3 StringValue (com.yahoo.jrt.StringValue)3 Supervisor (com.yahoo.jrt.Supervisor)3 Target (com.yahoo.jrt.Target)3 Transport (com.yahoo.jrt.Transport)3 TreeMap (java.util.TreeMap)3