Search in sources :

Example 11 with StringValue

use of com.yahoo.jrt.StringValue 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 12 with StringValue

use of com.yahoo.jrt.StringValue 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 13 with StringValue

use of com.yahoo.jrt.StringValue 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 14 with StringValue

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

the class RpcServerTest method testSetNodeStateOutOfRange.

@Test
public void testSetNodeStateOutOfRange() throws Exception {
    startingTest("RpcServerTest::testSetNodeStateOutOfRange");
    FleetControllerOptions options = new FleetControllerOptions("mycluster");
    options.setStorageDistribution(new Distribution(Distribution.getDefaultDistributionConfig(2, 10)));
    setUpFleetController(true, options);
    setUpVdsNodes(true, new DummyVdsNodeOptions());
    waitForStableSystem();
    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/10"));
    req.parameters().add(new StringValue("s:m"));
    connection.invokeSync(req, timeoutS);
    assertEquals(req.toString(), ErrorCode.METHOD_FAILED, req.errorCode());
    assertEquals(req.toString(), "Cannot set wanted state of node storage.10. Index does not correspond to a configured node.", req.errorMessage());
    req = new Request("setNodeState");
    req.parameters().add(new StringValue("storage/cluster.mycluster/distributor/10"));
    req.parameters().add(new StringValue("s:m"));
    connection.invokeSync(req, timeoutS);
    assertEquals(req.toString(), ErrorCode.METHOD_FAILED, req.errorCode());
    assertEquals(req.toString(), "Cannot set wanted state of node distributor.10. Index does not correspond to a configured node.", req.errorMessage());
    req = new Request("setNodeState");
    req.parameters().add(new StringValue("storage/cluster.mycluster/storage/9"));
    req.parameters().add(new StringValue("s:m"));
    connection.invokeSync(req, timeoutS);
    assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
    waitForState("version:\\d+ distributor:10 storage:10 .9.s:m");
}
Also used : Supervisor(com.yahoo.jrt.Supervisor) Target(com.yahoo.jrt.Target) Distribution(com.yahoo.vdslib.distribution.Distribution) 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 15 with StringValue

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

the class DummyVdsNode method rpc_getNodeState2.

public void rpc_getNodeState2(Request req) {
    log.log(LogLevel.DEBUG, "Dummy node " + this + ": Got " + req.methodName() + " request");
    try {
        String oldState = req.parameters().get(0).asString();
        int timeout = req.parameters().get(1).asInt32();
        int index = -1;
        if (req.parameters().size() > 2) {
            index = req.parameters().get(2).asInt32();
        }
        synchronized (timer) {
            boolean sentReply = sendGetNodeStateReply(index);
            NodeState givenState = (oldState.equals("unknown") ? null : NodeState.deserialize(type, oldState));
            if (givenState != null && (givenState.equals(nodeState) || sentReply)) {
                log.log(LogLevel.DEBUG, "Dummy node " + this + ": Has same state as reported " + givenState + ". Queing request. Timeout is " + timeout + " ms. " + "Will be answered at time " + (timer.getCurrentTimeInMillis() + timeout * 800l / 1000));
                req.detach();
                waitingRequests.add(new Req(req, timer.getCurrentTimeInMillis() + timeout * 800l / 1000));
                log.log(LogLevel.DEBUG, "Dummy node " + this + " has now " + waitingRequests.size() + " entries and is " + (waitingRequests.isEmpty() ? "empty" : "not empty"));
                timer.notifyAll();
            } else {
                log.log(LogLevel.DEBUG, "Dummy node " + this + ": Request had " + (givenState == null ? "no state" : "different state(" + givenState + ")") + ". Answering with " + nodeState);
                req.returnValues().add(new StringValue(nodeState.serialize()));
                if (req.methodName().equals("getnodestate3")) {
                    req.returnValues().add(new StringValue("Dummy node host info"));
                }
                ++immediateStateReplies;
            }
        }
    } catch (Exception e) {
        log.log(LogLevel.ERROR, "Dummy node " + this + ": An error occured when answering " + req.methodName() + " request: " + e.getMessage());
        e.printStackTrace(System.err);
        req.setError(ErrorCode.METHOD_FAILED, e.getMessage());
    }
}
Also used : StringValue(com.yahoo.jrt.StringValue) UnknownHostException(java.net.UnknownHostException)

Aggregations

StringValue (com.yahoo.jrt.StringValue)24 Request (com.yahoo.jrt.Request)14 Spec (com.yahoo.jrt.Spec)8 Supervisor (com.yahoo.jrt.Supervisor)7 Target (com.yahoo.jrt.Target)7 Transport (com.yahoo.jrt.Transport)7 Test (org.junit.Test)7 Int32Value (com.yahoo.jrt.Int32Value)5 NodeState (com.yahoo.vdslib.state.NodeState)4 ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)3 Node (com.yahoo.vdslib.state.Node)3 UnknownHostException (java.net.UnknownHostException)3 FileReference (com.yahoo.config.FileReference)2 DataValue (com.yahoo.jrt.DataValue)2 ListenFailedException (com.yahoo.jrt.ListenFailedException)2 StringArray (com.yahoo.jrt.StringArray)2 Distribution (com.yahoo.vdslib.distribution.Distribution)2 TreeSet (java.util.TreeSet)2 DoubleValue (com.yahoo.jrt.DoubleValue)1 Int32Array (com.yahoo.jrt.Int32Array)1