Search in sources :

Example 21 with Node

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());
}
Also used : Node(com.yahoo.vdslib.state.Node) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) Test(org.junit.Test)

Example 22 with Node

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());
}
Also used : Node(com.yahoo.vdslib.state.Node) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 23 with Node

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()));
    }
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) Node(com.yahoo.vdslib.state.Node) TreeMap(java.util.TreeMap) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 24 with Node

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()));
    }
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) Node(com.yahoo.vdslib.state.Node) TreeMap(java.util.TreeMap) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 25 with Node

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;
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) Node(com.yahoo.vdslib.state.Node)

Aggregations

Node (com.yahoo.vdslib.state.Node)65 Test (org.junit.Test)34 NodeState (com.yahoo.vdslib.state.NodeState)32 ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)31 ClusterFixture.storageNode (com.yahoo.vespa.clustercontroller.core.ClusterFixture.storageNode)15 HasStateReasonForNode.hasStateReasonForNode (com.yahoo.vespa.clustercontroller.core.matchers.HasStateReasonForNode.hasStateReasonForNode)15 ClusterState (com.yahoo.vdslib.state.ClusterState)9 NodeInfo (com.yahoo.vespa.clustercontroller.core.NodeInfo)6 NodeType (com.yahoo.vdslib.state.NodeType)5 PrintWriter (java.io.PrintWriter)5 StringWriter (java.io.StringWriter)5 Request (com.yahoo.jrt.Request)4 State (com.yahoo.vdslib.state.State)4 IOException (java.io.IOException)4 Spec (com.yahoo.jrt.Spec)3 StringValue (com.yahoo.jrt.StringValue)3 Supervisor (com.yahoo.jrt.Supervisor)3 Target (com.yahoo.jrt.Target)3 Transport (com.yahoo.jrt.Transport)3 TreeMap (java.util.TreeMap)3