use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.
the class FleetController method consolidatedClusterState.
/**
* A "consolidated" cluster state is guaranteed to have up-to-date information on which nodes are
* up or down even when the whole cluster is down. The regular, published cluster state is not
* normally updated to reflect node events when the cluster is down.
*/
ClusterState consolidatedClusterState() {
final ClusterState publishedState = stateVersionTracker.getVersionedClusterState();
if (publishedState.getClusterState() == State.UP) {
// Short-circuit; already represents latest node state
return publishedState;
}
// Latest candidate state contains the most up to date state information, even if it may not
// have been published yet.
final ClusterState current = stateVersionTracker.getLatestCandidateState().getClusterState().clone();
current.setVersion(publishedState.getVersion());
return current;
}
use of com.yahoo.vdslib.state.ClusterState 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.ClusterState in project vespa by vespa-engine.
the class DistributionBitCountTest method testStorageNodeReportingLowerBitCount.
/**
* Test that then storage node report lower bit count, but another storage node with equally low bitcount, the fleetcontroller does nothing.
* Test that then storage node report lower bit count, and then becomes the smallest, the fleetcontroller adjusts to use that bit in system state.
*/
@Test
public void testStorageNodeReportingLowerBitCount() throws Exception {
setUpSystem("DistributionBitCountTest::testStorageNodeReportingLowerBitCount");
nodes.get(1).setNodeState(new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(13));
ClusterState currentState = waitForState("version:\\d+ bits:13 distributor:10 storage:10");
int version = currentState.getVersion();
nodes.get(3).setNodeState(new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(15));
assertEquals(version, currentState.getVersion());
nodes.get(3).setNodeState(new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(13));
assertEquals(version, currentState.getVersion());
nodes.get(3).setNodeState(new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(12));
waitForState("version:\\d+ bits:12 distributor:10 storage:10");
}
use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.
the class DistributionBitCountTest method testStorageNodeReportingHigherBitCount.
/**
* Test that when storage node reports higher bit count, but another storage
* node has equally low bitcount, the fleetcontroller does nothing.
*
* Test that when storage node reports higher bit count, but another storage
* node now being lowest, the fleetcontroller adjusts to use that bit in system state.
*/
@Test
public void testStorageNodeReportingHigherBitCount() throws Exception {
setUpSystem("DistributionBitCountTest::testStorageNodeReportingHigherBitCount");
nodes.get(1).setNodeState(new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(11));
nodes.get(3).setNodeState(new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(11));
ClusterState startState = waitForState("version:\\d+ bits:11 distributor:10 storage:10");
nodes.get(1).setNodeState(new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(12));
assertEquals(startState + "->" + fleetController.getSystemState(), startState.getVersion(), fleetController.getSystemState().getVersion());
for (int i = 0; i < 10; ++i) {
// nodes is array of [distr.0, stor.0, distr.1, stor.1, ...] and we just want the storage nodes
nodes.get(i * 2 + 1).setNodeState(new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(17));
}
assertEquals(startState.getVersion() + 1, waitForState("version:\\d+ bits:17 distributor:10 storage:10").getVersion());
}
use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.
the class ClusterFixture method doProposeWantedState.
private void doProposeWantedState(final Node node, final NodeState nodeState, String description) {
final ClusterState stateBefore = rawGeneratedClusterState();
nodeState.setDescription(description);
NodeInfo nodeInfo = cluster.getNodeInfo(node);
nodeInfo.setWantedState(nodeState);
nodeStateChangeHandler.proposeNewNodeState(stateBefore, nodeInfo, nodeState);
}
Aggregations