Search in sources :

Example 41 with Node

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

Example 42 with Node

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

Example 43 with Node

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

Example 44 with Node

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

Example 45 with 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"));
}
Also used : WaitCondition(com.yahoo.vespa.clustercontroller.core.testutils.WaitCondition) Supervisor(com.yahoo.jrt.Supervisor) ClusterState(com.yahoo.vdslib.state.ClusterState) NodeState(com.yahoo.vdslib.state.NodeState) Node(com.yahoo.vdslib.state.Node) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) Request(com.yahoo.jrt.Request) Target(com.yahoo.jrt.Target) Transport(com.yahoo.jrt.Transport) Spec(com.yahoo.jrt.Spec) Test(org.junit.Test)

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