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