Search in sources :

Example 6 with Request

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

the class ConfigProxyRpcServerTest method testRpcMethodListSourceConnections.

/**
 * Tests printStatistics RPC command
 */
@Test
public void testRpcMethodListSourceConnections() {
    Request req = new Request("listSourceConnections");
    rpcServer.listSourceConnections(req);
    assertFalse(req.errorMessage(), req.isError());
    assertThat(req.returnValues().size(), is(1));
    final String[] ret = req.returnValues().get(0).asStringArray();
    assertThat(ret.length, is(2));
    assertThat(ret[0], is("Current source: " + address));
    assertThat(ret[1], is("All sources:\n" + address + "\n"));
}
Also used : Request(com.yahoo.jrt.Request) Test(org.junit.Test)

Example 7 with Request

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

the class ConfigProxyRpcServerTest method testRpcMethodGetModeAndSetMode.

/**
 * Tests getMode and setMode RPC commands
 */
@Test
public void testRpcMethodGetModeAndSetMode() {
    Request req = new Request("getMode");
    rpcServer.getMode(req);
    assertFalse(req.errorMessage(), req.isError());
    assertThat(req.returnValues().size(), is(1));
    assertThat(req.returnValues().get(0).asString(), is("default"));
    req = new Request("setMode");
    String mode = "memorycache";
    req.parameters().add(new StringValue(mode));
    rpcServer.setMode(req);
    assertFalse(req.errorMessage(), req.isError());
    assertThat(req.returnValues().size(), is(1));
    String[] ret = req.returnValues().get(0).asStringArray();
    assertThat(ret.length, is(2));
    assertThat(ret[0], is("0"));
    assertThat(ret[1], is("success"));
    assertThat(proxyServer.getMode().name(), is(mode));
    req = new Request("getMode");
    rpcServer.getMode(req);
    assertFalse(req.errorMessage(), req.isError());
    assertThat(req.returnValues().size(), is(1));
    assertThat(req.returnValues().get(0).asString(), is(mode));
    req = new Request("setMode");
    String oldMode = mode;
    mode = "invalid";
    req.parameters().add(new StringValue(mode));
    rpcServer.setMode(req);
    assertFalse(req.errorMessage(), req.isError());
    ret = req.returnValues().get(0).asStringArray();
    assertThat(ret.length, is(2));
    assertThat(ret[0], is("1"));
    assertThat(ret[1], is("Could not set mode to '" + mode + "'. Legal modes are '" + Mode.modes() + "'"));
    assertThat(proxyServer.getMode().name(), is(oldMode));
}
Also used : Request(com.yahoo.jrt.Request) StringValue(com.yahoo.jrt.StringValue) Test(org.junit.Test)

Example 8 with Request

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

the class ConfigProxyRpcServerTest method testRpcMethodPrintStatistics.

/**
 * Tests printStatistics RPC command
 */
@Test
public void testRpcMethodPrintStatistics() {
    Request req = new Request("printStatistics");
    rpcServer.printStatistics(req);
    assertFalse(req.errorMessage(), req.isError());
    assertThat(req.returnValues().size(), is(1));
    assertThat(req.returnValues().get(0).asString(), is("\n" + "Delayed responses queue size: 0\n" + "Contents: "));
}
Also used : Request(com.yahoo.jrt.Request) Test(org.junit.Test)

Example 9 with Request

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

the class JRTConfigRequesterTest method testFirstRequestAfterSubscribing.

@Test
public void testFirstRequestAfterSubscribing() {
    ConfigSubscriber subscriber = new ConfigSubscriber();
    final TimingValues timingValues = getTestTimingValues();
    JRTConfigSubscription<SimpletypesConfig> sub = createSubscription(subscriber, timingValues);
    final MockConnection connection = new MockConnection();
    JRTConfigRequester requester = new JRTConfigRequester(connection, timingValues);
    assertThat(requester.getConnectionPool(), is(connection));
    requester.request(sub);
    final Request request = connection.getRequest();
    assertNotNull(request);
    assertThat(connection.getNumberOfRequests(), is(1));
    JRTServerConfigRequestV3 receivedRequest = JRTServerConfigRequestV3.createFromRequest(request);
    assertTrue(receivedRequest.validateParameters());
    assertThat(receivedRequest.getTimeout(), is(timingValues.getSubscribeTimeout()));
    assertThat(requester.getFatalFailures(), is(0));
    assertThat(requester.getTransientFailures(), is(0));
}
Also used : SimpletypesConfig(com.yahoo.foo.SimpletypesConfig) ConfigSubscriber(com.yahoo.config.subscription.ConfigSubscriber) TimingValues(com.yahoo.vespa.config.TimingValues) Request(com.yahoo.jrt.Request) JRTServerConfigRequestV3(com.yahoo.vespa.config.protocol.JRTServerConfigRequestV3) Test(org.junit.Test)

Example 10 with Request

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

the class FileDistributionStatus method getHostStatus.

HostStatus getHostStatus(String hostname, int port, Duration timeout) {
    Target target = supervisor.connect(new Spec(hostname, port));
    Request request = new Request("filedistribution.getActiveFileReferencesStatus");
    target.invokeSync(request, timeout.toMillis() / 1000);
    HostStatus hostStatus = createHostStatusFromResponse(hostname, request);
    target.close();
    return hostStatus;
}
Also used : Target(com.yahoo.jrt.Target) Request(com.yahoo.jrt.Request) Spec(com.yahoo.jrt.Spec)

Aggregations

Request (com.yahoo.jrt.Request)36 Test (org.junit.Test)18 Spec (com.yahoo.jrt.Spec)14 StringValue (com.yahoo.jrt.StringValue)14 Target (com.yahoo.jrt.Target)13 Supervisor (com.yahoo.jrt.Supervisor)10 Transport (com.yahoo.jrt.Transport)10 Int32Value (com.yahoo.jrt.Int32Value)6 NodeState (com.yahoo.vdslib.state.NodeState)5 ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)4 Node (com.yahoo.vdslib.state.Node)4 DataValue (com.yahoo.jrt.DataValue)3 Int8Value (com.yahoo.jrt.Int8Value)3 Distribution (com.yahoo.vdslib.distribution.Distribution)3 StringArray (com.yahoo.jrt.StringArray)2 Values (com.yahoo.jrt.Values)2 ClusterState (com.yahoo.vdslib.state.ClusterState)2 RawConfig (com.yahoo.vespa.config.RawConfig)2 JRTServerConfigRequestV3 (com.yahoo.vespa.config.protocol.JRTServerConfigRequestV3)2 ArrayList (java.util.ArrayList)2