Search in sources :

Example 21 with ClusterState

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

the class StateChangeHandlerTest method markNodeBackIntoSlobrok.

private void markNodeBackIntoSlobrok(Node node, State state) {
    final ClusterState stateBefore = currentClusterState();
    log.info("Marking " + node + " back in slobrok");
    cluster.getNodeInfo(node).markRpcAddressLive();
    nodeStateChangeHandler.handleReturnedRpcAddress(cluster.getNodeInfo(node));
    nodeStateChangeHandler.handleNewReportedNodeState(stateBefore, cluster.getNodeInfo(node), new NodeState(node.getType(), state), nodeStateUpdateListener);
    cluster.getNodeInfo(node).setReportedState(new NodeState(node.getType(), state), clock.getCurrentTimeInMillis());
}
Also used : ClusterState(com.yahoo.vdslib.state.ClusterState) NodeState(com.yahoo.vdslib.state.NodeState)

Example 22 with ClusterState

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

the class StateChangeHandlerTest method markNodeOutOfSlobrok.

private void markNodeOutOfSlobrok(Node node) {
    final ClusterState stateBefore = currentClusterState();
    log.info("Marking " + node + " out of slobrok");
    cluster.getNodeInfo(node).markRpcAddressOutdated(clock);
    nodeStateChangeHandler.handleMissingNode(stateBefore, cluster.getNodeInfo(node), nodeStateUpdateListener);
    assertTrue(eventLog.toString(), eventLog.toString().contains("Node is no longer in slobrok"));
    eventLog.clear();
}
Also used : ClusterState(com.yahoo.vdslib.state.ClusterState)

Example 23 with ClusterState

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

the class ContentClusterHtmlRendrerTest method before.

@Before
public void before() throws JSONException, ParseException {
    final ClusterState state = new ClusterState("version:34633 bits:24 distributor:211 storage:211");
    final EventLog eventLog = new EventLog(new FakeTimer(), null);
    final VdsClusterHtmlRendrer.Table table = rendrer.createNewClusterHtmlTable(clusterName, slobrokGeneration);
    final ContentCluster contentCluster = mock(ContentCluster.class);
    for (int x = 0; x < 10; x++) {
        NodeInfo nodeInfo = new DistributorNodeInfo(contentCluster, x, "dist " + x, null);
        final Writer writer = new StringWriter();
        new JSONWriter(writer).object().key("vtag").object().key("version").value("release1" + (x == 2 ? "bad" : "")).endObject().endObject();
        nodeInfo.setHostInfo(HostInfo.createHostInfo(writer.toString()));
        distributorNodeInfoByIndex.put(x, nodeInfo);
    }
    storageNodeInfoByIndex.put(2, new StorageNodeInfo(contentCluster, 2, false, "storage" + 2, null));
    ClusterStatsAggregator statsAggregator = new ClusterStatsAggregator(Sets.newHashSet(2), Sets.newHashSet(2));
    table.renderNodes(storageNodeInfoByIndex, distributorNodeInfoByIndex, new FakeTimer(), state, statsAggregator, 1.0, 10, eventLog, "pathPrefix", "name");
    final StringBuilder stringBuilder = new StringBuilder();
    table.addTable(stringBuilder, 34);
    result = stringBuilder.toString();
}
Also used : JSONWriter(org.codehaus.jettison.json.JSONWriter) ClusterState(com.yahoo.vdslib.state.ClusterState) VdsClusterHtmlRendrer(com.yahoo.vespa.clustercontroller.core.status.statuspage.VdsClusterHtmlRendrer) StringWriter(java.io.StringWriter) JSONWriter(org.codehaus.jettison.json.JSONWriter) StringWriter(java.io.StringWriter) Writer(java.io.Writer) Before(org.junit.Before)

Example 24 with ClusterState

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

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

Aggregations

ClusterState (com.yahoo.vdslib.state.ClusterState)38 Test (org.junit.Test)11 NodeState (com.yahoo.vdslib.state.NodeState)10 Node (com.yahoo.vdslib.state.Node)8 BucketId (com.yahoo.document.BucketId)6 ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)6 State (com.yahoo.vdslib.state.State)4 Request (com.yahoo.jrt.Request)2 Spec (com.yahoo.jrt.Spec)2 Supervisor (com.yahoo.jrt.Supervisor)2 Target (com.yahoo.jrt.Target)2 Transport (com.yahoo.jrt.Transport)2 StringWriter (java.io.StringWriter)2 HashMap (java.util.HashMap)2 ParseException (com.yahoo.document.select.parser.ParseException)1 StringValue (com.yahoo.jrt.StringValue)1 Distribution (com.yahoo.vdslib.distribution.Distribution)1 NodeType (com.yahoo.vdslib.state.NodeType)1 AnnotatedClusterState (com.yahoo.vespa.clustercontroller.core.AnnotatedClusterState)1 HostInfo (com.yahoo.vespa.clustercontroller.core.hostinfo.HostInfo)1