use of com.yahoo.vdslib.state.NodeState 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.NodeState in project vespa by vespa-engine.
the class FleetControllerTest method waitForNodeStateReported.
protected void waitForNodeStateReported(int nodeIndex, NodeState state, int ms) {
long timeoutAtTime = System.currentTimeMillis() + ms;
while (true) {
Node node = nodes.get(nodeIndex).getNode();
NodeState ns = fleetController.getReportedNodeState(node);
if ((ns == null && state == null) || (ns != null && state != null && ns.equals(state)))
break;
if (System.currentTimeMillis() > timeoutAtTime) {
throw new IllegalStateException("Failed to find " + node + " in nodestate " + state + " before timeout of " + ms + " milliseconds.");
}
}
}
use of com.yahoo.vdslib.state.NodeState in project vespa by vespa-engine.
the class GroupAutoTakedownTest method disk_states_are_preserved_across_group_down_up_edge.
@Test
public void disk_states_are_preserved_across_group_down_up_edge() {
ClusterFixture fixture = createFixtureForAllUpHierarchicCluster(DistributionBuilder.withGroups(3).eachWithNodeCount(2), 0.51);
final NodeState newState = new NodeState(NodeType.STORAGE, State.UP);
newState.setDiskCount(7);
newState.setDiskState(5, new DiskState(State.DOWN));
fixture.reportStorageNodeState(4, newState);
assertEquals("distributor:6 storage:6 .4.d:7 .4.d.5.s:d", fixture.generatedClusterState());
assertEquals("distributor:6 storage:4", stateAfterStorageTransition(fixture, 5, State.DOWN));
assertEquals("distributor:6 storage:6 .4.d:7 .4.d.5.s:d", stateAfterStorageTransition(fixture, 5, State.UP));
}
use of com.yahoo.vdslib.state.NodeState in project vespa by vespa-engine.
the class GroupAutoTakedownTest method previously_cleared_start_timestamps_are_not_reintroduced_on_up_edge.
@Test
public void previously_cleared_start_timestamps_are_not_reintroduced_on_up_edge() throws Exception {
ClusterFixture fixture = createFixtureForAllUpHierarchicCluster(DistributionBuilder.withGroups(3).eachWithNodeCount(2), 0.51);
final NodeState newState = new NodeState(NodeType.STORAGE, State.UP);
newState.setStartTimestamp(123456);
fixture.reportStorageNodeState(4, newState);
assertEquals("distributor:6 storage:6 .4.t:123456", fixture.generatedClusterState());
DatabaseHandler handler = mock(DatabaseHandler.class);
DatabaseHandler.Context context = mock(DatabaseHandler.Context.class);
when(context.getCluster()).thenReturn(fixture.cluster);
Set<ConfiguredNode> nodes = new HashSet<>(fixture.cluster.clusterInfo().getConfiguredNodes().values());
fixture.nodeStateChangeHandler.handleAllDistributorsInSync(fixture.annotatedGeneratedClusterState().getClusterState(), nodes, handler, context);
// Timestamp should now be cleared from state
assertEquals("distributor:6 storage:6", fixture.generatedClusterState());
// Trigger a group down+up edge. Timestamp should _not_ be reintroduced since it was previously cleared.
assertEquals("distributor:6 storage:4", stateAfterStorageTransition(fixture, 5, State.DOWN));
assertEquals("distributor:6 storage:6", stateAfterStorageTransition(fixture, 5, State.UP));
}
use of com.yahoo.vdslib.state.NodeState in project vespa by vespa-engine.
the class DatabaseHandler method loadWantedStates.
public boolean loadWantedStates(Context context) throws InterruptedException {
log.log(LogLevel.DEBUG, "Fleetcontroller " + nodeIndex + ": Retrieving node wanted states.");
synchronized (databaseMonitor) {
if (database != null && !database.isClosed()) {
currentlyStored.wantedStates = database.retrieveWantedStates();
}
}
Map<Node, NodeState> wantedStates = currentlyStored.wantedStates;
if (wantedStates == null) {
if (usingZooKeeper()) {
log.log(LogLevel.WARNING, "Fleetcontroller " + nodeIndex + ": Failed to retrieve wanted states from ZooKeeper. Assuming UP for all nodes.");
}
wantedStates = new TreeMap<>();
}
boolean altered = false;
for (Node node : wantedStates.keySet()) {
NodeInfo nodeInfo = context.getCluster().getNodeInfo(node);
// ignore wanted state of nodes which doesn't exist
if (nodeInfo == null)
continue;
NodeState wantedState = wantedStates.get(node);
if (!nodeInfo.getUserWantedState().equals(wantedState)) {
nodeInfo.setWantedState(wantedState);
context.getNodeStateUpdateListener().handleNewWantedNodeState(nodeInfo, wantedState);
altered = true;
}
log.log(LogLevel.DEBUG, "Fleetcontroller " + nodeIndex + ": Node " + node + " has wanted state " + wantedState);
}
// Remove wanted state from any node having a wanted state set that is no longer valid
for (NodeInfo info : context.getCluster().getNodeInfo()) {
NodeState wantedState = wantedStates.get(info.getNode());
if (wantedState == null && !info.getUserWantedState().equals(new NodeState(info.getNode().getType(), State.UP))) {
info.setWantedState(null);
context.getNodeStateUpdateListener().handleNewWantedNodeState(info, info.getWantedState().clone());
altered = true;
}
}
return altered;
}
Aggregations