Search in sources :

Example 6 with JRTServerConfigRequest

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());
}
Also used : JRTServerConfigRequest(com.yahoo.vespa.config.protocol.JRTServerConfigRequest) GetConfigContext(com.yahoo.vespa.config.server.GetConfigContext) Test(org.junit.Test)

Example 7 with JRTServerConfigRequest

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));
}
Also used : JRTServerConfigRequest(com.yahoo.vespa.config.protocol.JRTServerConfigRequest) Test(org.junit.Test)

Example 8 with JRTServerConfigRequest

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());
}
Also used : JRTServerConfigRequest(com.yahoo.vespa.config.protocol.JRTServerConfigRequest) Test(org.junit.Test)

Example 9 with JRTServerConfigRequest

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));
}
Also used : JRTServerConfigRequest(com.yahoo.vespa.config.protocol.JRTServerConfigRequest) Test(org.junit.Test)

Example 10 with JRTServerConfigRequest

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);
    }
}
Also used : JRTServerConfigRequest(com.yahoo.vespa.config.protocol.JRTServerConfigRequest)

Aggregations

JRTServerConfigRequest (com.yahoo.vespa.config.protocol.JRTServerConfigRequest)12 Test (org.junit.Test)8 TenantName (com.yahoo.config.provision.TenantName)1 ConfigCacheKey (com.yahoo.vespa.config.ConfigCacheKey)1 RawConfig (com.yahoo.vespa.config.RawConfig)1 GetConfigContext (com.yahoo.vespa.config.server.GetConfigContext)1 GetConfigProcessor (com.yahoo.vespa.config.server.rpc.GetConfigProcessor)1 MockRpc (com.yahoo.vespa.config.server.rpc.MockRpc)1 MockTenantProvider (com.yahoo.vespa.config.server.tenant.MockTenantProvider)1 Date (java.util.Date)1 Delayed (java.util.concurrent.Delayed)1 TimeUnit (java.util.concurrent.TimeUnit)1