use of com.yahoo.vespa.config.RawConfig in project vespa by vespa-engine.
the class ClientUpdaterTest method basic.
@Test
public void basic() {
assertThat(rpcServer.responses, is(0L));
final RawConfig fooConfig = ProxyServerTest.fooConfig;
clientUpdater.updateSubscribers(fooConfig);
// No delayed response, so not returned
assertEquals(0, rpcServer.responses);
delayedResponses.add(new DelayedResponse(JRTServerConfigRequestV3.createFromRequest(JRTConfigRequestFactory.createFromRaw(fooConfig, -10L).getRequest())));
clientUpdater.updateSubscribers(fooConfig);
assertEquals(1, rpcServer.responses);
// Will not find bar config in delayed responses
RawConfig barConfig = new RawConfig(new ConfigKey<>("bar", "id", "namespace"), fooConfig.getDefMd5());
clientUpdater.updateSubscribers(barConfig);
assertEquals(1, rpcServer.responses);
}
use of com.yahoo.vespa.config.RawConfig in project vespa by vespa-engine.
the class JRTConfigRequestFactoryTest method testCreateFromRaw.
@Test
public void testCreateFromRaw() {
Class<FunctionTestConfig> clazz = FunctionTestConfig.class;
final String configId = "foo";
RawConfig config = new RawConfig(new ConfigKey<>(clazz, configId), "595f44fec1e92a71d3e9e77456ba80d1");
// Default vespa version
JRTClientConfigRequest request = JRTConfigRequestFactory.createFromRaw(config, 1000);
assertThat(request.getProtocolVersion(), is(3L));
assertThat(request.getVespaVersion().get(), is(defaultVespaVersion));
// Create with vespa version set
String version = "5.37.38";
System.setProperty(JRTConfigRequestFactory.VESPA_VERSION, version);
request = JRTConfigRequestFactory.createFromRaw(config, 1000);
assertThat(request.getProtocolVersion(), is(3L));
assertThat(request.getVespaVersion().get(), is(VespaVersion.fromString(version)));
System.clearProperty(JRTConfigRequestFactory.VESPA_VERSION);
}
use of com.yahoo.vespa.config.RawConfig in project vespa by vespa-engine.
the class ConfigProxyRpcServerTest method testRpcMethodListCachedConfig.
/**
* Tests listCachedConfig RPC command
*/
@Test
public void testRpcMethodListCachedConfig() {
Request req = new Request("listCachedConfig");
rpcServer.listCachedConfig(req);
assertFalse(req.errorMessage(), req.isError());
String[] ret = req.returnValues().get(0).asStringArray();
assertThat(req.returnValues().size(), is(1));
assertThat(ret.length, is(0));
final RawConfig config = ProxyServerTest.fooConfig;
proxyServer.getMemoryCache().put(config);
req = new Request("listCachedConfig");
rpcServer.listCachedConfig(req);
assertFalse(req.errorMessage(), req.isError());
assertThat(req.returnValues().size(), is(1));
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()));
}
use of com.yahoo.vespa.config.RawConfig 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()));
}
use of com.yahoo.vespa.config.RawConfig in project vespa by vespa-engine.
the class MemoryCache method dumpCacheToDisk.
String dumpCacheToDisk(String path, MemoryCache cache) {
if (path == null || path.isEmpty()) {
path = DEFAULT_DUMP_DIR;
log.log(LogLevel.DEBUG, "dumpCache. No path or empty path. Using dir '" + path + "'");
}
if (path.endsWith("/")) {
path = path.substring(0, path.length() - 1);
}
log.log(LogLevel.DEBUG, "Dumping cache to path '" + path + "'");
IOUtils.createDirectory(path);
File dir = new File(path);
if (!dir.isDirectory() || !dir.canWrite()) {
return "Not a dir or not able to write to '" + dir + "'";
}
for (RawConfig config : cache.values()) {
writeConfigToFile(config, path);
}
return "success";
}
Aggregations