Search in sources :

Example 6 with Target

use of com.yahoo.jrt.Target in project vespa by vespa-engine.

the class FleetControllerTest method setWantedState.

protected void setWantedState(DummyVdsNode node, State state, String reason) {
    if (supervisor == null) {
        supervisor = new Supervisor(new Transport());
    }
    NodeState ns = new NodeState(node.getType(), state);
    if (reason != null)
        ns.setDescription(reason);
    Target connection = supervisor.connect(new Spec("localhost", fleetController.getRpcPort()));
    Request req = new Request("setNodeState");
    req.parameters().add(new StringValue(node.getSlobrokName()));
    req.parameters().add(new StringValue(ns.serialize()));
    connection.invokeSync(req, timeoutS);
    if (req.isError()) {
        assertTrue("Failed to invoke setNodeState(): " + req.errorCode() + ": " + req.errorMessage(), false);
    }
    if (!req.checkReturnTypes("s")) {
        assertTrue("Failed to invoke setNodeState(): Invalid return types.", false);
    }
}
Also used : Supervisor(com.yahoo.jrt.Supervisor) Target(com.yahoo.jrt.Target) NodeState(com.yahoo.vdslib.state.NodeState) Request(com.yahoo.jrt.Request) Transport(com.yahoo.jrt.Transport) Spec(com.yahoo.jrt.Spec) StringValue(com.yahoo.jrt.StringValue)

Example 7 with Target

use of com.yahoo.jrt.Target in project vespa by vespa-engine.

the class DatabaseTest method setWantedState.

// Note: different semantics than FleetControllerTest.setWantedState
protected void setWantedState(Node n, NodeState ns, Map<Node, NodeState> wantedStates) {
    int rpcPort = fleetController.getRpcPort();
    if (supervisor == null) {
        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/" + n.getType().toString() + "/" + n.getIndex()));
    req.parameters().add(new StringValue(ns.serialize(true)));
    connection.invokeSync(req, timeoutS);
    assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
    assertTrue(req.toString(), req.checkReturnTypes("s"));
    wantedStates.put(n, ns);
}
Also used : Supervisor(com.yahoo.jrt.Supervisor) Target(com.yahoo.jrt.Target) Request(com.yahoo.jrt.Request) Transport(com.yahoo.jrt.Transport) Spec(com.yahoo.jrt.Spec) StringValue(com.yahoo.jrt.StringValue)

Example 8 with Target

use of com.yahoo.jrt.Target in project vespa by vespa-engine.

the class RpcServerTest method testGetNodeList.

@Test
public void testGetNodeList() throws Exception {
    startingTest("RpcServerTest::testGetNodeList");
    setUpFleetController(true, new FleetControllerOptions("mycluster"));
    setUpVdsNodes(true, new DummyVdsNodeOptions());
    waitForStableSystem();
    assertEquals(true, nodes.get(0).isDistributor());
    nodes.get(0).disconnect();
    waitForState("version:\\d+ distributor:10 .0.s:d storage:10");
    int rpcPort = fleetController.getRpcPort();
    supervisor = new Supervisor(new Transport());
    Target connection = supervisor.connect(new Spec("localhost", rpcPort));
    assertTrue(connection.isValid());
    // Possibly do request multiple times if we haven't lost slobrok contact first times yet.
    for (int j = 0; j <= 10; ++j) {
        Request req = new Request("getNodeList");
        connection.invokeSync(req, timeoutS);
        assertEquals(req.errorMessage(), ErrorCode.NONE, req.errorCode());
        assertTrue(req.toString(), req.checkReturnTypes("SS"));
        String[] slobrok = req.returnValues().get(0).asStringArray().clone();
        String[] rpc = req.returnValues().get(1).asStringArray().clone();
        assertEquals(20, slobrok.length);
        assertEquals(20, rpc.length);
        // Verify that we can connect to all addresses returned.
        for (int i = 0; i < 20; ++i) {
            if (slobrok[i].equals("storage/cluster.mycluster/distributor/0")) {
                if (j < 10 && !"".equals(rpc[i])) {
                    continue;
                }
                assertEquals(slobrok[i], "", rpc[i]);
                continue;
            }
            assertTrue(slobrok[i], !rpc[i].equals(""));
            Request req2 = new Request("getnodestate2");
            req2.parameters().add(new StringValue("unknown"));
            Target connection2 = supervisor.connect(new Spec(rpc[i]));
            connection2.invokeSync(req2, timeoutS);
            assertEquals(req2.toString(), ErrorCode.NONE, req.errorCode());
        }
        break;
    }
}
Also used : Supervisor(com.yahoo.jrt.Supervisor) Target(com.yahoo.jrt.Target) Request(com.yahoo.jrt.Request) Transport(com.yahoo.jrt.Transport) Spec(com.yahoo.jrt.Spec) StringValue(com.yahoo.jrt.StringValue) Test(org.junit.Test)

Example 9 with Target

use of com.yahoo.jrt.Target 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 10 with Target

use of com.yahoo.jrt.Target 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

Target (com.yahoo.jrt.Target)15 Spec (com.yahoo.jrt.Spec)14 Request (com.yahoo.jrt.Request)13 Supervisor (com.yahoo.jrt.Supervisor)11 Transport (com.yahoo.jrt.Transport)11 StringValue (com.yahoo.jrt.StringValue)7 Test (org.junit.Test)7 NodeState (com.yahoo.vdslib.state.NodeState)5 ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)4 Distribution (com.yahoo.vdslib.distribution.Distribution)3 Node (com.yahoo.vdslib.state.Node)3 ClusterState (com.yahoo.vdslib.state.ClusterState)2 TreeSet (java.util.TreeSet)2 Int32Value (com.yahoo.jrt.Int32Value)1 StringArray (com.yahoo.jrt.StringArray)1 WaitCondition (com.yahoo.vespa.clustercontroller.core.testutils.WaitCondition)1 JRTServerConfigRequest (com.yahoo.vespa.config.protocol.JRTServerConfigRequest)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1