Search in sources :

Example 11 with Supervisor

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

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

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

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

the class RpcServer method connect.

public void connect() throws ListenFailedException, UnknownHostException {
    disconnect();
    log.log(LogLevel.DEBUG, "Fleetcontroller " + fleetControllerIndex + ": Connecting RPC server.");
    if (supervisor != null)
        disconnect();
    supervisor = new Supervisor(new Transport());
    addMethods();
    log.log(LogLevel.DEBUG, "Fleetcontroller " + fleetControllerIndex + ": Attempting to bind to port " + port);
    acceptor = supervisor.listen(new Spec(port));
    log.log(LogLevel.DEBUG, "Fleetcontroller " + fleetControllerIndex + ": RPC server listening to port " + acceptor.port());
    StringBuffer slobroks = new StringBuffer("(");
    for (String s : slobrokConnectionSpecs) {
        slobroks.append(" ").append(s);
    }
    slobroks.append(" )");
    SlobrokList slist = new SlobrokList();
    slist.setup(slobrokConnectionSpecs);
    Spec spec = new Spec(HostName.getLocalhost(), acceptor.port());
    log.log(LogLevel.INFO, "Registering " + spec + " with slobrok at " + slobroks);
    if (slobrokBackOffPolicy != null) {
        register = new Register(supervisor, slist, spec, slobrokBackOffPolicy);
    } else {
        register = new Register(supervisor, slist, spec);
    }
    register.registerName(getSlobrokName());
}
Also used : Supervisor(com.yahoo.jrt.Supervisor) Register(com.yahoo.jrt.slobrok.api.Register) SlobrokList(com.yahoo.jrt.slobrok.api.SlobrokList) Transport(com.yahoo.jrt.Transport) Spec(com.yahoo.jrt.Spec)

Example 15 with Supervisor

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

the class SlobrokClient method setSlobrokConnectionSpecs.

public void setSlobrokConnectionSpecs(String[] slobrokConnectionSpecs) {
    if (equalsExistingSpec(slobrokConnectionSpecs))
        return;
    this.connectionSpecs = slobrokConnectionSpecs;
    shutdown();
    supervisor = new Supervisor(new Transport());
    SlobrokList slist = new SlobrokList();
    slist.setup(slobrokConnectionSpecs);
    mirror = new Mirror(supervisor, slist);
    freshMirror = true;
}
Also used : Supervisor(com.yahoo.jrt.Supervisor) SlobrokList(com.yahoo.jrt.slobrok.api.SlobrokList) Transport(com.yahoo.jrt.Transport) Mirror(com.yahoo.jrt.slobrok.api.Mirror)

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