Search in sources :

Example 46 with Node

use of com.yahoo.vdslib.state.Node in project vespa by vespa-engine.

the class RpcServerTest method testSetNodeState.

@Test
public void testSetNodeState() throws Exception {
    startingTest("RpcServerTest::testSetNodeState");
    FleetControllerOptions options = new FleetControllerOptions("mycluster");
    Set<Integer> nodeIndexes = new TreeSet<>(Arrays.asList(new Integer[] { 4, 6, 9, 10, 14, 16, 21, 22, 23, 25 }));
    options.setStorageDistribution(new Distribution(getDistConfig(nodeIndexes)));
    setUpFleetController(true, options);
    setUpVdsNodes(true, new DummyVdsNodeOptions(), false, nodeIndexes);
    waitForState("version:\\d+ distributor:26 .0.s:d .1.s:d .2.s:d .3.s:d .5.s:d .7.s:d .8.s:d .11.s:d .12.s:d .13.s:d .15.s:d .17.s:d .18.s:d .19.s:d .20.s:d .24.s:d storage:26 .0.s:d .1.s:d .2.s:d .3.s:d .5.s:d .7.s:d .8.s:d .11.s:d .12.s:d .13.s:d .15.s:d .17.s:d .18.s:d .19.s:d .20.s:d .24.s:d");
    int rpcPort = fleetController.getRpcPort();
    supervisor = new Supervisor(new Transport());
    Target connection = supervisor.connect(new Spec("localhost", rpcPort));
    assertTrue(connection.isValid());
    Request req = new Request("setNodeState");
    req.parameters().add(new StringValue("storage/cluster.mycluster/storage/14"));
    req.parameters().add(new StringValue("s:r"));
    connection.invokeSync(req, timeoutS);
    assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
    assertTrue(req.toString(), req.checkReturnTypes("s"));
    waitForState("version:\\d+ distributor:26 .* storage:26 .* .14.s:r .*");
    req = new Request("setNodeState");
    req.parameters().add(new StringValue("storage/cluster.mycluster/storage/16"));
    req.parameters().add(new StringValue("s:m"));
    connection.invokeSync(req, timeoutS);
    assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
    assertTrue(req.toString(), req.checkReturnTypes("s"));
    ClusterState state = waitForState("version:\\d+ distributor:26 .* storage:26 .* .14.s:r.* .16.s:m .*");
    nodes.get(5 * 2 + 1).disconnect();
    waitForCompleteCycle();
    timer.advanceTime(100000000);
    waitForCompleteCycle();
    assertEquals(State.MAINTENANCE, fleetController.getSystemState().getNodeState(new Node(NodeType.STORAGE, 16)).getState());
    nodes.get(4 * 2 + 1).disconnect();
    waitForState("version:\\d+ distributor:26 .* storage:26 .* .14.s:m.* .16.s:m .*");
    nodes.get(4 * 2 + 1).connect();
    timer.advanceTime(100000000);
    // Might need to pass more actual time while waiting below?
    waitForState("version:\\d+ distributor:26 .* storage:26 .* .14.s:r.* .16.s:m .*");
}
Also used : Supervisor(com.yahoo.jrt.Supervisor) ClusterState(com.yahoo.vdslib.state.ClusterState) Node(com.yahoo.vdslib.state.Node) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) Request(com.yahoo.jrt.Request) Target(com.yahoo.jrt.Target) TreeSet(java.util.TreeSet) Distribution(com.yahoo.vdslib.distribution.Distribution) Transport(com.yahoo.jrt.Transport) Spec(com.yahoo.jrt.Spec) StringValue(com.yahoo.jrt.StringValue) Test(org.junit.Test)

Example 47 with Node

use of com.yahoo.vdslib.state.Node 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 48 with Node

use of com.yahoo.vdslib.state.Node 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)

Example 49 with Node

use of com.yahoo.vdslib.state.Node in project vespa by vespa-engine.

the class ClusterStateGeneratorTest method transition_from_controlled_stop_to_down_does_not_add_to_crash_counter.

// Stopping -> Down is expected and does not indicate an unstable node.
@Test
public void transition_from_controlled_stop_to_down_does_not_add_to_crash_counter() {
    final ClusterFixture fixture = ClusterFixture.forFlatCluster(2).bringEntireClusterUp().reportStorageNodeState(1, State.STOPPING, // urgh, string matching logic
    "controlled shutdown").reportStorageNodeState(1, State.DOWN);
    final NodeInfo nodeInfo = fixture.cluster.getNodeInfo(new Node(NodeType.STORAGE, 1));
    assertThat(nodeInfo.getPrematureCrashCount(), equalTo(0));
}
Also used : ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) ClusterFixture.storageNode(com.yahoo.vespa.clustercontroller.core.ClusterFixture.storageNode) Node(com.yahoo.vdslib.state.Node) HasStateReasonForNode.hasStateReasonForNode(com.yahoo.vespa.clustercontroller.core.matchers.HasStateReasonForNode.hasStateReasonForNode) Test(org.junit.Test)

Example 50 with Node

use of com.yahoo.vdslib.state.Node in project vespa by vespa-engine.

the class ClusterStateGeneratorTest method exceeded_crash_count_does_not_override_wanted_maintenance_state.

@Test
public void exceeded_crash_count_does_not_override_wanted_maintenance_state() {
    final ClusterFixture fixture = ClusterFixture.forFlatCluster(5).bringEntireClusterUp().proposeStorageNodeWantedState(1, State.MAINTENANCE);
    final ClusterStateGenerator.Params params = fixture.generatorParams().maxPrematureCrashes(10);
    final NodeInfo nodeInfo = fixture.cluster.getNodeInfo(new Node(NodeType.STORAGE, 1));
    nodeInfo.setPrematureCrashCount(11);
    final AnnotatedClusterState state = ClusterStateGenerator.generatedStateFrom(params);
    assertThat(state.toString(), equalTo("distributor:5 storage:5 .1.s:m"));
}
Also used : ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) ClusterFixture.storageNode(com.yahoo.vespa.clustercontroller.core.ClusterFixture.storageNode) Node(com.yahoo.vdslib.state.Node) HasStateReasonForNode.hasStateReasonForNode(com.yahoo.vespa.clustercontroller.core.matchers.HasStateReasonForNode.hasStateReasonForNode) 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