use of com.yahoo.vdslib.state.Node in project vespa by vespa-engine.
the class NodeStateChangeCheckerTest method testCanUpgradeIfMissingMinReplicationFactor.
@Test
public void testCanUpgradeIfMissingMinReplicationFactor() {
ContentCluster cluster = createCluster(createNodes(4));
NodeStateChangeChecker nodeStateChangeChecker = createChangeChecker(cluster);
setAllNodesUp(cluster, HostInfo.createHostInfo(createDistributorHostInfo(4, 3, 6)));
NodeStateChangeChecker.Result result = nodeStateChangeChecker.evaluateTransition(new Node(NodeType.STORAGE, 3), defaultAllUpClusterState(), SetUnitStateRequest.Condition.SAFE, UP_NODE_STATE, MAINTENANCE_NODE_STATE);
assertTrue(result.settingWantedStateIsAllowed());
assertFalse(result.wantedStateAlreadySet());
}
use of com.yahoo.vdslib.state.Node in project vespa by vespa-engine.
the class NodeStateChangeCheckerTest method testCanUpgradeIfStorageNodeMissingFromNodeInfo.
@Test
public void testCanUpgradeIfStorageNodeMissingFromNodeInfo() {
ContentCluster cluster = createCluster(createNodes(4));
NodeStateChangeChecker nodeStateChangeChecker = createChangeChecker(cluster);
String hostInfo = "{\n" + " \"cluster-state-version\": 2,\n" + " \"distributor\": {\n" + " \"storage-nodes\": [\n" + " {\n" + " \"node-index\": 0,\n" + " \"min-current-replication-factor\": " + requiredRedundancy + "\n" + " }\n" + " ]\n" + " }\n" + "}\n";
setAllNodesUp(cluster, HostInfo.createHostInfo(hostInfo));
NodeStateChangeChecker.Result result = nodeStateChangeChecker.evaluateTransition(new Node(NodeType.STORAGE, 1), defaultAllUpClusterState(), SetUnitStateRequest.Condition.SAFE, UP_NODE_STATE, MAINTENANCE_NODE_STATE);
assertTrue(result.settingWantedStateIsAllowed());
assertFalse(result.wantedStateAlreadySet());
}
use of com.yahoo.vdslib.state.Node in project vespa by vespa-engine.
the class DatabaseTest method testWantedStatesInZooKeeper.
// These tests work in isolation but causes other tests to hang
@Ignore
@Test
public void testWantedStatesInZooKeeper() throws Exception {
startingTest("DatabaseTest::testWantedStatesInZooKeeper");
FleetControllerOptions options = new FleetControllerOptions("mycluster");
options.zooKeeperServerAddress = "127.0.0.1";
setUpFleetController(true, options);
setUpVdsNodes(true, new DummyVdsNodeOptions());
log.info("WAITING FOR STABLE SYSTEM");
waitForStableSystem();
log.info("VALIDATE STARTING WANTED STATES");
Map<Node, NodeState> wantedStates = new TreeMap<>();
for (DummyVdsNode node : nodes) {
wantedStates.put(node.getNode(), new NodeState(node.getType(), State.UP));
}
for (DummyVdsNode node : nodes) {
assertEquals(node.getNode().toString(), wantedStates.get(node.getNode()), fleetController.getWantedNodeState(node.getNode()));
}
log.info("SET A WANTED STATE AND SEE THAT IT GETS PROPAGATED");
setWantedState(new Node(NodeType.STORAGE, 3), new NodeState(NodeType.STORAGE, State.MAINTENANCE).setDescription("Yoo"), wantedStates);
waitForState("version:\\d+ distributor:10 storage:10 .3.s:m");
for (DummyVdsNode node : nodes) {
assertEquals(node.getNode().toString(), wantedStates.get(node.getNode()), fleetController.getWantedNodeState(node.getNode()));
}
log.info("SET ANOTHER WANTED STATE AND SEE THAT IT GETS PROPAGATED");
setWantedState(new Node(NodeType.DISTRIBUTOR, 2), new NodeState(NodeType.DISTRIBUTOR, State.DOWN), wantedStates);
waitForState("version:\\d+ distributor:10 .2.s:d storage:10 .3.s:m");
for (DummyVdsNode node : nodes) {
assertEquals(node.getNode().toString(), wantedStates.get(node.getNode()), fleetController.getWantedNodeState(node.getNode()));
}
log.info("SET YET ANOTHER WANTED STATE AND SEE THAT IT GETS PROPAGATED");
setWantedState(new Node(NodeType.STORAGE, 7), new NodeState(NodeType.STORAGE, State.RETIRED).setDescription("We wanna replace this node"), wantedStates);
waitForState("version:\\d+ distributor:10 .2.s:d storage:10 .3.s:m .7.s:r");
for (DummyVdsNode node : nodes) {
assertEquals(node.getNode().toString(), wantedStates.get(node.getNode()), fleetController.getWantedNodeState(node.getNode()));
}
log.info("CHECK THAT WANTED STATES PERSIST FLEETCONTROLLER RESTART");
stopFleetController();
startFleetController();
waitForState("version:\\d+ distributor:10 .2.s:d storage:10 .3.s:m .7.s:r");
for (DummyVdsNode node : nodes) {
assertEquals(node.getNode().toString(), wantedStates.get(node.getNode()), fleetController.getWantedNodeState(node.getNode()));
}
log.info("CLEAR WANTED STATE");
setWantedState(new Node(NodeType.STORAGE, 7), new NodeState(NodeType.STORAGE, State.UP), wantedStates);
for (DummyVdsNode node : nodes) {
assertEquals(node.getNode().toString(), wantedStates.get(node.getNode()), fleetController.getWantedNodeState(node.getNode()));
}
setWantedState(new Node(NodeType.DISTRIBUTOR, 5), new NodeState(NodeType.DISTRIBUTOR, State.DOWN), wantedStates);
for (DummyVdsNode node : nodes) {
assertEquals(node.getNode().toString(), wantedStates.get(node.getNode()), fleetController.getWantedNodeState(node.getNode()));
}
setWantedState(new Node(NodeType.DISTRIBUTOR, 2), new NodeState(NodeType.DISTRIBUTOR, State.UP), wantedStates);
for (DummyVdsNode node : nodes) {
assertEquals(node.getNode().toString(), wantedStates.get(node.getNode()), fleetController.getWantedNodeState(node.getNode()));
}
setWantedState(new Node(NodeType.STORAGE, 9), new NodeState(NodeType.STORAGE, State.DOWN), wantedStates);
for (DummyVdsNode node : nodes) {
assertEquals(node.getNode().toString(), wantedStates.get(node.getNode()), fleetController.getWantedNodeState(node.getNode()));
}
}
use of com.yahoo.vdslib.state.Node in project vespa by vespa-engine.
the class DatabaseTest method testWantedStateOfUnknownNode.
// These tests work in isolation but causes other tests to hang
@Ignore
@Test
public void testWantedStateOfUnknownNode() throws Exception {
startingTest("DatabaseTest::testWantedStatesOfUnknownNode");
FleetControllerOptions options = new FleetControllerOptions("mycluster");
options.minRatioOfDistributorNodesUp = 0;
options.minRatioOfStorageNodesUp = 0;
options.zooKeeperServerAddress = "localhost";
setUpFleetController(true, options);
setUpVdsNodes(true, new DummyVdsNodeOptions());
waitForStableSystem();
// Populate map of wanted states we should have
Map<Node, NodeState> wantedStates = new TreeMap<>();
for (DummyVdsNode node : nodes) {
wantedStates.put(node.getNode(), new NodeState(node.getType(), State.UP));
}
for (DummyVdsNode node : nodes) {
assertEquals(node.getNode().toString(), wantedStates.get(node.getNode()), fleetController.getWantedNodeState(node.getNode()));
}
setWantedState(new Node(NodeType.STORAGE, 1), new NodeState(NodeType.STORAGE, State.MAINTENANCE).setDescription("Yoo"), wantedStates);
waitForState("version:\\d+ distributor:10 storage:10 .1.s:m");
for (DummyVdsNode node : nodes) {
assertEquals(node.getNode().toString(), wantedStates.get(node.getNode()), fleetController.getWantedNodeState(node.getNode()));
}
// This should not show up, as it is down
setWantedState(new Node(NodeType.DISTRIBUTOR, 8), new NodeState(NodeType.DISTRIBUTOR, State.DOWN), wantedStates);
waitForState("version:\\d+ distributor:10 .8.s:d storage:10 .1.s:m");
for (DummyVdsNode node : nodes) {
assertEquals(node.getNode().toString(), wantedStates.get(node.getNode()), fleetController.getWantedNodeState(node.getNode()));
}
// This should show up, as down nodes can be turned to maintenance
setWantedState(new Node(NodeType.STORAGE, 6), new NodeState(NodeType.STORAGE, State.MAINTENANCE).setDescription("foobar"), wantedStates);
waitForState("version:\\d+ distributor:10 .8.s:d storage:10 .1.s:m .6.s:m");
for (DummyVdsNode node : nodes) {
assertEquals(node.getNode().toString(), wantedStates.get(node.getNode()), fleetController.getWantedNodeState(node.getNode()));
}
// This should not show up, as we cannot turn a down node retired
setWantedState(new Node(NodeType.STORAGE, 7), new NodeState(NodeType.STORAGE, State.RETIRED).setDescription("foobar"), wantedStates);
waitForState("version:\\d+ distributor:10 .8.s:d storage:10 .1.s:m .6.s:m .7.s:r");
for (DummyVdsNode node : nodes) {
assertEquals(node.getNode().toString(), wantedStates.get(node.getNode()), fleetController.getWantedNodeState(node.getNode()));
}
// This should not show up, as it is down
setWantedState(new Node(NodeType.STORAGE, 8), new NodeState(NodeType.STORAGE, State.DOWN).setDescription("foobar"), wantedStates);
waitForState("version:\\d+ distributor:10 .8.s:d storage:10 .1.s:m .6.s:m .7.s:r .8.s:d");
for (DummyVdsNode node : nodes) {
assertEquals(node.getNode().toString(), wantedStates.get(node.getNode()), fleetController.getWantedNodeState(node.getNode()));
}
stopFleetController();
for (int i = 6; i < nodes.size(); ++i) nodes.get(i).disconnect();
startFleetController();
waitForState("version:\\d+ distributor:3 storage:7 .1.s:m .3.s:d .4.s:d .5.s:d .6.s:m");
setWantedState(new Node(NodeType.STORAGE, 6), new NodeState(NodeType.STORAGE, State.UP), wantedStates);
waitForState("version:\\d+ distributor:3 storage:3 .1.s:m");
for (int i = 6; i < nodes.size(); ++i) nodes.get(i).connect();
waitForState("version:\\d+ distributor:10 .8.s:d storage:10 .1.s:m .7.s:r .8.s:d");
for (DummyVdsNode node : nodes) {
assertEquals(node.getNode().toString(), wantedStates.get(node.getNode()), fleetController.getWantedNodeState(node.getNode()));
}
}
use of com.yahoo.vdslib.state.Node in project vespa by vespa-engine.
the class ClusterFixture method reportStorageNodeState.
public ClusterFixture reportStorageNodeState(final int index, State state, String description) {
final Node node = new Node(NodeType.STORAGE, index);
final NodeState nodeState = new NodeState(NodeType.STORAGE, state);
nodeState.setDescription(description);
doReportNodeState(node, nodeState);
return this;
}
Aggregations