use of com.yahoo.vdslib.state.Node in project vespa by vespa-engine.
the class NodeStateChangeCheckerTest method transitionToMaintenanceWithOneStorageNodeDown.
private NodeStateChangeChecker.Result transitionToMaintenanceWithOneStorageNodeDown(int storageNodeIndex, boolean alternatingUpRetiredAndInitializing) {
ContentCluster cluster = createCluster(createNodes(4));
NodeStateChangeChecker nodeStateChangeChecker = createChangeChecker(cluster);
for (int x = 0; x < cluster.clusterInfo().getConfiguredNodes().size(); x++) {
State state = State.UP;
// Pick some retired and initializing nodes too
if (alternatingUpRetiredAndInitializing) {
// TODO: Move this into the calling test
if (x % 3 == 1)
state = State.RETIRED;
else if (x % 3 == 2)
state = State.INITIALIZING;
}
cluster.clusterInfo().getDistributorNodeInfo(x).setReportedState(new NodeState(NodeType.DISTRIBUTOR, state), 0);
cluster.clusterInfo().getDistributorNodeInfo(x).setHostInfo(HostInfo.createHostInfo(createDistributorHostInfo(4, 5, 6)));
cluster.clusterInfo().getStorageNodeInfo(x).setReportedState(new NodeState(NodeType.STORAGE, state), 0);
}
ClusterState clusterState = defaultAllUpClusterState();
if (storageNodeIndex >= 0) {
// TODO: Move this into the calling test
NodeState downNodeState = new NodeState(NodeType.STORAGE, State.DOWN);
cluster.clusterInfo().getStorageNodeInfo(storageNodeIndex).setReportedState(downNodeState, 4);
clusterState.setNodeState(new Node(NodeType.STORAGE, storageNodeIndex), downNodeState);
}
return nodeStateChangeChecker.evaluateTransition(nodeStorage, clusterState, SetUnitStateRequest.Condition.SAFE, UP_NODE_STATE, MAINTENANCE_NODE_STATE);
}
use of com.yahoo.vdslib.state.Node in project vespa by vespa-engine.
the class NodeStateChangeCheckerTest method testUnknownStorageNode.
@Test
public void testUnknownStorageNode() {
ContentCluster cluster = createCluster(createNodes(4));
NodeStateChangeChecker nodeStateChangeChecker = new NodeStateChangeChecker(5, /* min storage nodes */
minRatioOfStorageNodesUp, requiredRedundancy, cluster.clusterInfo());
NodeStateChangeChecker.Result result = nodeStateChangeChecker.evaluateTransition(new Node(NodeType.STORAGE, 10), defaultAllUpClusterState(), SetUnitStateRequest.Condition.SAFE, UP_NODE_STATE, MAINTENANCE_NODE_STATE);
assertFalse(result.settingWantedStateIsAllowed());
assertFalse(result.wantedStateAlreadySet());
assertThat(result.getReason(), is("Unknown node storage.10"));
}
use of com.yahoo.vdslib.state.Node in project vespa by vespa-engine.
the class StateChangeHandlerTest method startWithStableStateClusterWithNodesUp.
private void startWithStableStateClusterWithNodesUp() {
for (NodeType type : NodeType.getTypes()) {
for (ConfiguredNode i : configuredNodes) {
NodeInfo nodeInfo = cluster.clusterInfo().setRpcAddress(new Node(type, i.index()), null);
nodeInfo.markRpcAddressLive();
nodeStateChangeHandler.handleNewReportedNodeState(currentClusterState(), nodeInfo, new NodeState(type, State.UP), null);
nodeInfo.setReportedState(new NodeState(type, State.UP), clock.getCurrentTimeInMillis());
}
}
for (NodeType type : NodeType.getTypes()) {
for (ConfiguredNode i : configuredNodes) {
Node n = new Node(type, i.index());
assertEquals(State.UP, currentClusterState().getNodeState(n).getState());
}
}
clock.advanceTime(config.stableStateTime);
}
use of com.yahoo.vdslib.state.Node in project vespa by vespa-engine.
the class StateChangeHandlerTest method testUnstableNodeInSlobrok.
@Test
public void testUnstableNodeInSlobrok() {
initialize(new Config());
startWithStableStateClusterWithNodesUp();
Node node = new Node(NodeType.STORAGE, 0);
for (int j = 0; j < 3; ++j) {
log.info("Iteration " + j);
assertEquals(0, cluster.getNodeInfo(node).getPrematureCrashCount());
assertEquals(State.UP, cluster.getNodeInfo(node).getWantedState().getState());
assertEquals(State.UP, currentClusterState().getNodeState(node).getState());
for (int k = 0; k < config.maxPrematureCrashes; ++k) {
log.info("Premature iteration " + k);
markNodeOutOfSlobrok(node);
log.info("Passing max disconnect time period. Watching timers");
clock.advanceTime(config.maxSlobrokDisconnectPeriod);
verifyNodeStateAfterTimerWatch(node, State.MAINTENANCE);
cluster.getNodeInfo(node).setReportedState(new NodeState(node.getType(), State.DOWN), clock.getCurrentTimeInMillis());
assertEquals(k, cluster.getNodeInfo(node).getPrematureCrashCount());
markNodeBackIntoSlobrok(node, State.UP);
verifyClusterStateChanged(node, State.UP);
}
log.info("Passing steady state to get premature crash count flag cleared");
clock.advanceTime(config.stableStateTime);
verifyPrematureCrashCountCleared(node);
}
}
use of com.yahoo.vdslib.state.Node in project vespa by vespa-engine.
the class RpcServerTest method testGetSystemState.
@Test
public void testGetSystemState() throws Exception {
LogFormatter.initializeLogging();
startingTest("RpcServerTest::testGetSystemState");
FleetControllerOptions options = new FleetControllerOptions("mycluster");
setUpFleetController(true, options);
setUpVdsNodes(true, new DummyVdsNodeOptions());
waitForStableSystem();
assertEquals(true, nodes.get(0).isDistributor());
log.log(LogLevel.INFO, "Disconnecting distributor 0. Waiting for state to reflect change.");
nodes.get(0).disconnect();
nodes.get(19).disconnect();
fleetController.waitForNodesInSlobrok(9, 9, timeoutMS);
timer.advanceTime(options.nodeStateRequestTimeoutMS + options.maxSlobrokDisconnectGracePeriod);
wait(new WaitCondition.StateWait(fleetController, fleetController.getMonitor()) {
@Override
public String isConditionMet() {
if (currentState == null) {
return "No cluster state defined yet";
}
NodeState distState = currentState.getNodeState(new Node(NodeType.DISTRIBUTOR, 0));
if (distState.getState() != State.DOWN) {
return "Distributor not detected down yet: " + currentState.toString();
}
NodeState storState = currentState.getNodeState(new Node(NodeType.STORAGE, 9));
if (!storState.getState().oneOf("md")) {
return "Storage node not detected down yet: " + currentState.toString();
}
return null;
}
}, null, timeoutMS);
int rpcPort = fleetController.getRpcPort();
supervisor = new Supervisor(new Transport());
Target connection = supervisor.connect(new Spec("localhost", rpcPort));
assertTrue(connection.isValid());
Request req = new Request("getSystemState");
connection.invokeSync(req, timeoutS);
assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
assertTrue(req.toString(), req.checkReturnTypes("ss"));
String systemState = req.returnValues().get(1).asString();
ClusterState retrievedClusterState = new ClusterState(systemState);
assertEquals(systemState, State.DOWN, retrievedClusterState.getNodeState(new Node(NodeType.DISTRIBUTOR, 0)).getState());
assertTrue(systemState, retrievedClusterState.getNodeState(new Node(NodeType.STORAGE, 9)).getState().oneOf("md"));
}
Aggregations