use of com.yahoo.vespa.config.protocol.JRTServerConfigRequest in project vespa by vespa-engine.
the class DelayedConfigResponseTest method testDelayedConfigResponses.
@Test
public void testDelayedConfigResponses() {
MockRpc rpc = new MockRpc(13337);
DelayedConfigResponses responses = new DelayedConfigResponses(rpc, 1, false);
assertThat(responses.size(), is(0));
JRTServerConfigRequest req = createRequest("foo", "md5", "myid", "mymd5", 3, 1000000, "bar");
req.setDelayedResponse(true);
GetConfigContext context = GetConfigContext.testContext(ApplicationId.defaultId());
responses.delayResponse(req, context);
assertThat(responses.size(), is(0));
req.setDelayedResponse(false);
responses.delayResponse(req, context);
responses.delayResponse(createRequest("foolio", "md5", "myid", "mymd5", 3, 100000, "bar"), context);
assertThat(responses.size(), is(2));
assertTrue(req.isDelayedResponse());
List<DelayedConfigResponses.DelayedConfigResponse> it = responses.allDelayedResponses();
assertTrue(!it.isEmpty());
}
use of com.yahoo.vespa.config.protocol.JRTServerConfigRequest in project vespa by vespa-engine.
the class DelayedConfigResponseTest method testDelayedConfigResponse.
@Test
public void testDelayedConfigResponse() {
MockRpc rpc = new MockRpc(13337);
DelayedConfigResponses responses = new DelayedConfigResponses(rpc, 1, false);
assertThat(responses.size(), is(0));
assertThat(responses.toString(), is("DelayedConfigResponses. Average Size=0"));
JRTServerConfigRequest req = createRequest("foo", "md5", "myid", "mymd5", 3, 100, "bar");
responses.delayResponse(req, GetConfigContext.testContext(ApplicationId.defaultId()));
rpc.waitUntilSet(5000);
assertThat(rpc.latestRequest, is(req));
}
use of com.yahoo.vespa.config.protocol.JRTServerConfigRequest in project vespa by vespa-engine.
the class ProxyServerTest method testNoCachingOfErrorRequests.
/**
* Verifies that error responses are not cached. When the config has been successfully retrieved,
* it must be put in the cache.
*/
@Test
public void testNoCachingOfErrorRequests() {
ConfigTester tester = new ConfigTester();
// Simulate an error response
source.put(fooConfig.getKey(), createConfigWithNextConfigGeneration(fooConfig, ErrorCode.INTERNAL_ERROR));
final MemoryCache cacheManager = proxy.getMemoryCache();
assertEquals(0, cacheManager.size());
RawConfig res = proxy.resolveConfig(tester.createRequest(fooConfig));
assertNotNull(res);
assertNotNull(res.getPayload());
assertTrue(res.isError());
assertEquals(0, cacheManager.size());
// Put a version of the same config into backend without error and see that it now works (i.e. we are
// not getting a cached response (of the error in the previous request)
source.put(fooConfig.getKey(), createConfigWithNextConfigGeneration(fooConfig, 0));
// Verify that we get the config now and that it is cached
res = proxy.resolveConfig(tester.createRequest(fooConfig));
assertNotNull(res);
assertNotNull(res.getPayload().getData());
assertThat(res.getPayload().toString(), is(ConfigTester.fooPayload.toString()));
assertEquals(1, cacheManager.size());
JRTServerConfigRequest newRequestBasedOnResponse = tester.createRequest(res);
RawConfig res2 = proxy.resolveConfig(newRequestBasedOnResponse);
assertFalse(ProxyServer.configOrGenerationHasChanged(res2, newRequestBasedOnResponse));
assertEquals(1, cacheManager.size());
}
use of com.yahoo.vespa.config.protocol.JRTServerConfigRequest in project vespa by vespa-engine.
the class ProxyServerTest method testReconfiguration.
@Test
public void testReconfiguration() {
ConfigTester tester = new ConfigTester();
RawConfig res = proxy.resolveConfig(tester.createRequest(fooConfig));
assertNotNull(res);
assertThat(res.getPayload().toString(), is(ConfigTester.fooPayload.toString()));
// Simulate deployment, add config with new config generation
long previousGeneration = res.getGeneration();
source.put(fooConfig.getKey(), createConfigWithNextConfigGeneration(res, 0));
JRTServerConfigRequest newRequestBasedOnResponse = tester.createRequest(res);
RawConfig res2 = proxy.resolveConfig(newRequestBasedOnResponse);
assertEquals(previousGeneration + 1, res2.getGeneration());
assertTrue(ProxyServer.configOrGenerationHasChanged(res2, newRequestBasedOnResponse));
}
use of com.yahoo.vespa.config.protocol.JRTServerConfigRequest in project vespa by vespa-engine.
the class ConfigProxyRpcServer method getConfigV3.
// ---------------- RPC methods ------------------------------------
/**
* Handles RPC method "config.v3.getConfig" requests.
*
* @param req a Request
*/
@SuppressWarnings({ "UnusedDeclaration" })
public final void getConfigV3(Request req) {
log.log(LogLevel.SPAM, () -> "getConfigV3");
JRTServerConfigRequest request = JRTServerConfigRequestV3.createFromRequest(req);
if (isProtocolVersionSupported(request)) {
preHandle(req);
getConfigImpl(request);
}
}
Aggregations