Search in sources :

Example 6 with Supervisor

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

the class TargetPoolTestCase method setUp.

@Override
public void setUp() throws ListenFailedException {
    slobrok = new Slobrok();
    servers = new ArrayList<>();
    orb = new Supervisor(new Transport());
}
Also used : Supervisor(com.yahoo.jrt.Supervisor) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) Transport(com.yahoo.jrt.Transport)

Example 7 with Supervisor

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

the class ExternalSlobrokPolicy method init.

@Override
public void init() {
    if (slobroks != null) {
        orb = new Supervisor(new Transport());
        mirror = new Mirror(orb, slobroks);
    }
    if (configSources != null) {
        if (mirror == null) {
            orb = new Supervisor(new Transport());
            subscriber = subscribe(slobrokConfigId, new ConfigSourceSet(configSources));
        }
    }
}
Also used : Supervisor(com.yahoo.jrt.Supervisor) ConfigSourceSet(com.yahoo.config.subscription.ConfigSourceSet) Transport(com.yahoo.jrt.Transport) IMirror(com.yahoo.jrt.slobrok.api.IMirror) Mirror(com.yahoo.jrt.slobrok.api.Mirror)

Example 8 with Supervisor

use of com.yahoo.jrt.Supervisor 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 9 with Supervisor

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

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

Aggregations

Supervisor (com.yahoo.jrt.Supervisor)18 Transport (com.yahoo.jrt.Transport)18 Spec (com.yahoo.jrt.Spec)13 Target (com.yahoo.jrt.Target)11 Request (com.yahoo.jrt.Request)10 Test (org.junit.Test)8 StringValue (com.yahoo.jrt.StringValue)7 ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)4 NodeState (com.yahoo.vdslib.state.NodeState)4 Distribution (com.yahoo.vdslib.distribution.Distribution)3 Node (com.yahoo.vdslib.state.Node)3 ConfigSourceSet (com.yahoo.config.subscription.ConfigSourceSet)2 Mirror (com.yahoo.jrt.slobrok.api.Mirror)2 SlobrokList (com.yahoo.jrt.slobrok.api.SlobrokList)2 ClusterState (com.yahoo.vdslib.state.ClusterState)2 TreeSet (java.util.TreeSet)2 ConfigserverConfig (com.yahoo.cloud.config.ConfigserverConfig)1 Int32Value (com.yahoo.jrt.Int32Value)1 IMirror (com.yahoo.jrt.slobrok.api.IMirror)1 Register (com.yahoo.jrt.slobrok.api.Register)1