use of com.yahoo.vdslib.state.NodeState 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.NodeState 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.NodeState 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"));
}
use of com.yahoo.vdslib.state.NodeState in project vespa by vespa-engine.
the class SetNodeStateRequestTest method testSetStateRequest.
private void testSetStateRequest(String wantedStateString, State storageWantedState, State distributorWantedState, NodeStateChangeChecker.Result result, Optional<State> expectedNewStorageWantedState, Optional<State> expectedNewDistributorWantedState) throws StateRestApiException {
when(cluster.hasConfiguredNode(NODE_INDEX)).thenReturn(true);
NodeInfo storageNodeInfo = mock(NodeInfo.class);
when(cluster.getNodeInfo(storageNode)).thenReturn(storageNodeInfo);
NodeState storageNodeState = new NodeState(NodeType.STORAGE, storageWantedState);
when(storageNodeInfo.getUserWantedState()).thenReturn(storageNodeState);
when(unitState.getId()).thenReturn(wantedStateString);
when(unitState.getReason()).thenReturn(REASON);
when(cluster.calculateEffectOfNewState(any(), any(), any(), any(), any())).thenReturn(result);
when(storageNodeInfo.isStorage()).thenReturn(storageNode.getType() == NodeType.STORAGE);
when(storageNodeInfo.getNodeIndex()).thenReturn(storageNode.getIndex());
NodeInfo distributorNodeInfo = mock(NodeInfo.class);
Node distributorNode = new Node(NodeType.DISTRIBUTOR, NODE_INDEX);
when(cluster.getNodeInfo(distributorNode)).thenReturn(distributorNodeInfo);
NodeState distributorNodeState = new NodeState(distributorNode.getType(), distributorWantedState);
when(distributorNodeInfo.getUserWantedState()).thenReturn(distributorNodeState);
setWantedState();
if (expectedNewStorageWantedState.isPresent()) {
NodeState expectedNewStorageNodeState = new NodeState(NodeType.STORAGE, expectedNewStorageWantedState.get());
verify(storageNodeInfo).setWantedState(expectedNewStorageNodeState);
verify(stateListener).handleNewWantedNodeState(storageNodeInfo, expectedNewStorageNodeState);
}
if (expectedNewDistributorWantedState.isPresent()) {
NodeState expectedNewDistributorNodeState = new NodeState(NodeType.DISTRIBUTOR, expectedNewDistributorWantedState.get());
verify(distributorNodeInfo).setWantedState(expectedNewDistributorNodeState);
verify(stateListener).handleNewWantedNodeState(distributorNodeInfo, expectedNewDistributorNodeState);
}
}
use of com.yahoo.vdslib.state.NodeState in project vespa by vespa-engine.
the class StatusPagesTest method testSimpleConnectionWithSomeContent.
@Test
public void testSimpleConnectionWithSomeContent() throws Exception {
// Set this to true temporary if you want to check status page from browser. Should be false in checked in code always.
boolean haltTestToViewStatusPage = false;
startingTest("StatusPagesTest::testSimpleConnectionWithSomeContent()");
FleetControllerOptions options = new FleetControllerOptions("mycluster");
options.setStorageDistribution(new Distribution(Distribution.getDefaultDistributionConfig(3, 10)));
// options.minRatioOfStorageNodesUp = 0.99;
if (haltTestToViewStatusPage) {
options.httpPort = 19234;
}
setUpFleetController(true, options);
setUpVdsNodes(true, new DummyVdsNodeOptions());
waitForStableSystem();
nodes.get(2).disconnectBreakConnection();
nodes.get(5).disconnectAsShutdown();
nodes.get(7).disconnectSlobrok();
fleetController.getCluster().getNodeInfo(new Node(NodeType.STORAGE, 3)).setWantedState(new NodeState(NodeType.STORAGE, State.MAINTENANCE).setDescription("Test&<>special"));
String content = doHttpGetRequest("/");
assertTrue(content, content.contains("<html>"));
assertTrue(content, content.contains("</html>"));
assertTrue(content, content.contains("Baseline cluster state"));
assertTrue(content, content.contains("Cluster states"));
assertTrue(content, content.contains("Event log"));
if (haltTestToViewStatusPage) {
System.err.println(content);
try {
Thread.sleep(1000000);
} catch (InterruptedException e) {
}
}
}
Aggregations