Search in sources :

Example 46 with NodeState

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);
}
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 47 with NodeState

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);
    }
}
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 48 with NodeState

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"));
}
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)

Example 49 with NodeState

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);
    }
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) NodeInfo(com.yahoo.vespa.clustercontroller.core.NodeInfo) Node(com.yahoo.vdslib.state.Node)

Example 50 with NodeState

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

Aggregations

NodeState (com.yahoo.vdslib.state.NodeState)68 Node (com.yahoo.vdslib.state.Node)31 Test (org.junit.Test)30 ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)21 ClusterState (com.yahoo.vdslib.state.ClusterState)11 NodeInfo (com.yahoo.vespa.clustercontroller.core.NodeInfo)6 Request (com.yahoo.jrt.Request)5 Target (com.yahoo.jrt.Target)5 State (com.yahoo.vdslib.state.State)5 ClusterFixture.storageNode (com.yahoo.vespa.clustercontroller.core.ClusterFixture.storageNode)5 HasStateReasonForNode.hasStateReasonForNode (com.yahoo.vespa.clustercontroller.core.matchers.HasStateReasonForNode.hasStateReasonForNode)5 Spec (com.yahoo.jrt.Spec)4 StringValue (com.yahoo.jrt.StringValue)4 Supervisor (com.yahoo.jrt.Supervisor)4 Transport (com.yahoo.jrt.Transport)4 DiskState (com.yahoo.vdslib.state.DiskState)4 ArrayList (java.util.ArrayList)4 PrintWriter (java.io.PrintWriter)3 StringWriter (java.io.StringWriter)3 HashSet (java.util.HashSet)3