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