Search in sources :

Example 26 with Request

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

the class ConfigProxyRpcServerTest method testRpcMethodListCachedConfigFull.

/**
 * Tests listCachedConfig RPC command
 */
@Test
public void testRpcMethodListCachedConfigFull() {
    Request req = new Request("listCachedConfigFull");
    rpcServer.listCachedConfigFull(req);
    assertFalse(req.errorMessage(), req.isError());
    assertThat(req.returnValues().size(), is(1));
    String[] ret = req.returnValues().get(0).asStringArray();
    assertThat(ret.length, is(0));
    final RawConfig config = ProxyServerTest.fooConfig;
    proxyServer.getMemoryCache().put(config);
    req = new Request("listCachedConfigFull");
    rpcServer.listCachedConfigFull(req);
    assertFalse(req.errorMessage(), req.isError());
    ret = req.returnValues().get(0).asStringArray();
    assertThat(ret.length, is(1));
    assertThat(ret[0], is(config.getNamespace() + "." + config.getName() + "," + config.getConfigId() + "," + config.getGeneration() + "," + config.getConfigMd5() + "," + config.getPayload().getData()));
}
Also used : Request(com.yahoo.jrt.Request) RawConfig(com.yahoo.vespa.config.RawConfig) Test(org.junit.Test)

Example 27 with Request

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

the class ConfigProxyRpcServerTest method testRpcMethodDumpCache.

/**
 * Tests dumpCache RPC command
 */
@Test
public void testRpcMethodDumpCache() {
    Request req = new Request("dumpCache");
    String path = "/tmp";
    req.parameters().add(new StringValue(path));
    rpcServer.dumpCache(req);
    assertFalse(req.errorMessage(), req.isError());
    assertThat(req.returnValues().size(), is(1));
    assertThat(req.returnValues().get(0).asString(), is("success"));
}
Also used : Request(com.yahoo.jrt.Request) StringValue(com.yahoo.jrt.StringValue) Test(org.junit.Test)

Example 28 with Request

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

the class ConfigProxyRpcServerTest method testRpcMethodInvalidateCache.

/**
 * Tests invalidateCache RPC command
 */
@Test
public void testRpcMethodInvalidateCache() {
    Request req = new Request("invalidateCache");
    rpcServer.invalidateCache(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("0"));
    assertThat(ret[1], is("success"));
}
Also used : Request(com.yahoo.jrt.Request) Test(org.junit.Test)

Example 29 with Request

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

the class ConfigProxyRpcServerTest method testRpcMethodPing.

/**
 * Tests ping RPC command
 */
@Test
public void testRpcMethodPing() {
    Request req = new Request("ping");
    rpcServer.ping(req);
    assertFalse(req.errorMessage(), req.isError());
    assertThat(req.returnValues().size(), is(1));
    assertThat(req.returnValues().get(0).asInt32(), is(0));
}
Also used : Request(com.yahoo.jrt.Request) Test(org.junit.Test)

Example 30 with Request

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

the class RpcConfigSourceClient method checkConfigSources.

/**
 * Checks if config sources are available
 */
private void checkConfigSources() {
    if (configSourceSet == null || configSourceSet.getSources() == null || configSourceSet.getSources().size() == 0) {
        log.log(LogLevel.WARNING, "No config sources defined, could not check connection");
    } else {
        Request req = new Request("ping");
        for (String configSource : configSourceSet.getSources()) {
            Spec spec = new Spec(configSource);
            Target target = supervisor.connect(spec);
            target.invokeSync(req, 30.0);
            if (target.isValid()) {
                log.log(LogLevel.DEBUG, () -> "Created connection to config source at " + spec.toString());
                return;
            } else {
                log.log(LogLevel.INFO, "Could not connect to config source at " + spec.toString());
            }
            target.close();
        }
        String extra = "";
        log.log(LogLevel.INFO, "Could not connect to any config source in set " + configSourceSet.toString() + ", please make sure config server(s) are running. " + extra);
    }
}
Also used : Target(com.yahoo.jrt.Target) Request(com.yahoo.jrt.Request) JRTServerConfigRequest(com.yahoo.vespa.config.protocol.JRTServerConfigRequest) 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