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"));
}
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));
}
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: "));
}
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));
}
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;
}
Aggregations