Search in sources :

Example 11 with Spec

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

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

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

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

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

the class ContainerRpcAdaptor method listen.

public synchronized void listen(int port) {
    Spec spec = new Spec(port);
    try {
        acceptor = supervisor.listen(spec);
        log.log(LogLevel.DEBUG, "Added new rpc server listening at" + " port '" + port + "'.");
    } catch (ListenFailedException e) {
        throw new RuntimeException("Could not create rpc server listening on " + spec, e);
    }
}
Also used : Spec(com.yahoo.jrt.Spec) ListenFailedException(com.yahoo.jrt.ListenFailedException)

Aggregations

Spec (com.yahoo.jrt.Spec)26 Request (com.yahoo.jrt.Request)14 Target (com.yahoo.jrt.Target)14 Supervisor (com.yahoo.jrt.Supervisor)13 Transport (com.yahoo.jrt.Transport)13 Test (org.junit.Test)9 StringValue (com.yahoo.jrt.StringValue)8 ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)4 NodeState (com.yahoo.vdslib.state.NodeState)4 Slobrok (com.yahoo.jrt.slobrok.server.Slobrok)3 Distribution (com.yahoo.vdslib.distribution.Distribution)3 Node (com.yahoo.vdslib.state.Node)3 Register (com.yahoo.jrt.slobrok.api.Register)2 SlobrokList (com.yahoo.jrt.slobrok.api.SlobrokList)2 Identity (com.yahoo.messagebus.network.Identity)2 ClusterState (com.yahoo.vdslib.state.ClusterState)2 ArrayList (java.util.ArrayList)2 TreeSet (java.util.TreeSet)2 HostInfo (com.yahoo.config.model.api.HostInfo)1 PortInfo (com.yahoo.config.model.api.PortInfo)1