Search in sources :

Example 1 with GenericConfigSubscriber

use of com.yahoo.config.subscription.impl.GenericConfigSubscriber in project vespa by vespa-engine.

the class JRTConfigRequestBase method created_from_existing_subscription.

@Test
public void created_from_existing_subscription() {
    System.setProperty("VESPA_CONFIG_PROTOCOL_VERSION", getProtocolVersion());
    MockConnection connection = new MockConnection(new MockConnection.AbstractResponseHandler() {

        @Override
        protected void createResponse() {
            JRTServerConfigRequest serverRequest = createReq(request);
            serverRequest.addOkResponse(createPayload(), currentGeneration, configMd5);
        }
    });
    ConfigSourceSet src = new ConfigSourceSet();
    ConfigSubscriber subscriber = new GenericConfigSubscriber(Collections.singletonMap(src, JRTConfigRequester.get(connection, new TimingValues())));
    JRTConfigSubscription<SimpletypesConfig> sub = new JRTConfigSubscription<>(new ConfigKey<>(SimpletypesConfig.class, configId), subscriber, src, new TimingValues());
    sub.subscribe(120_0000);
    assertTrue(sub.nextConfig(120_0000));
    sub.close();
    JRTClientConfigRequest nextReq = createReq(sub, Trace.createNew());
    SimpletypesConfig config = sub.getConfigState().getConfig();
    assertThat(nextReq.getRequestConfigMd5(), is(config.getConfigMd5()));
    assertThat(nextReq.getRequestGeneration(), is(currentGeneration));
    System.setProperty("VESPA_CONFIG_PROTOCOL_VERSION", "");
}
Also used : SimpletypesConfig(com.yahoo.foo.SimpletypesConfig) GenericConfigSubscriber(com.yahoo.config.subscription.impl.GenericConfigSubscriber) ConfigSubscriber(com.yahoo.config.subscription.ConfigSubscriber) GenericConfigSubscriber(com.yahoo.config.subscription.impl.GenericConfigSubscriber) MockConnection(com.yahoo.config.subscription.impl.MockConnection) TimingValues(com.yahoo.vespa.config.TimingValues) ConfigSourceSet(com.yahoo.config.subscription.ConfigSourceSet) JRTConfigSubscription(com.yahoo.config.subscription.impl.JRTConfigSubscription) Test(org.junit.Test)

Example 2 with GenericConfigSubscriber

use of com.yahoo.config.subscription.impl.GenericConfigSubscriber in project vespa by vespa-engine.

the class GenericConfigSubscriberTest method testOverriddenSubscribeInvalid2.

@Test(expected = UnsupportedOperationException.class)
public void testOverriddenSubscribeInvalid2() {
    GenericConfigSubscriber sub = new GenericConfigSubscriber();
    sub.subscribe(null, null, 0L);
}
Also used : GenericConfigSubscriber(com.yahoo.config.subscription.impl.GenericConfigSubscriber) JRTConfigRequesterTest(com.yahoo.config.subscription.impl.JRTConfigRequesterTest) Test(org.junit.Test)

Example 3 with GenericConfigSubscriber

use of com.yahoo.config.subscription.impl.GenericConfigSubscriber in project vespa by vespa-engine.

the class GenericConfigSubscriberTest method testGenericRequesterPooling.

@Test
public void testGenericRequesterPooling() {
    ConfigSourceSet source1 = new ConfigSourceSet("tcp/foo:78");
    ConfigSourceSet source2 = new ConfigSourceSet("tcp/bar:79");
    JRTConfigRequester req1 = JRTConfigRequester.get(new JRTConnectionPool(source1), JRTConfigRequesterTest.getTestTimingValues());
    JRTConfigRequester req2 = JRTConfigRequester.get(new JRTConnectionPool(source2), JRTConfigRequesterTest.getTestTimingValues());
    Map<ConfigSourceSet, JRTConfigRequester> requesters = new LinkedHashMap<>();
    requesters.put(source1, req1);
    requesters.put(source2, req2);
    GenericConfigSubscriber sub = new GenericConfigSubscriber(requesters);
    assertEquals(sub.requesters().get(source1).getConnectionPool().getCurrent().getAddress(), "tcp/foo:78");
    assertEquals(sub.requesters().get(source2).getConnectionPool().getCurrent().getAddress(), "tcp/bar:79");
}
Also used : JRTConnectionPool(com.yahoo.vespa.config.JRTConnectionPool) JRTConfigRequester(com.yahoo.config.subscription.impl.JRTConfigRequester) GenericConfigSubscriber(com.yahoo.config.subscription.impl.GenericConfigSubscriber) JRTConfigRequesterTest(com.yahoo.config.subscription.impl.JRTConfigRequesterTest) Test(org.junit.Test)

Example 4 with GenericConfigSubscriber

use of com.yahoo.config.subscription.impl.GenericConfigSubscriber in project vespa by vespa-engine.

the class GenericConfigSubscriberTest method testOverriddenSubscribeInvalid1.

@Test(expected = UnsupportedOperationException.class)
public void testOverriddenSubscribeInvalid1() {
    GenericConfigSubscriber sub = new GenericConfigSubscriber();
    sub.subscribe(null, null);
}
Also used : GenericConfigSubscriber(com.yahoo.config.subscription.impl.GenericConfigSubscriber) JRTConfigRequesterTest(com.yahoo.config.subscription.impl.JRTConfigRequesterTest) Test(org.junit.Test)

Example 5 with GenericConfigSubscriber

use of com.yahoo.config.subscription.impl.GenericConfigSubscriber in project vespa by vespa-engine.

the class GenericConfigSubscriberTest method testOverriddenSubscribeInvalid3.

@Test(expected = UnsupportedOperationException.class)
public void testOverriddenSubscribeInvalid3() {
    GenericConfigSubscriber sub = new GenericConfigSubscriber();
    sub.subscribe(null, null, "");
}
Also used : GenericConfigSubscriber(com.yahoo.config.subscription.impl.GenericConfigSubscriber) JRTConfigRequesterTest(com.yahoo.config.subscription.impl.JRTConfigRequesterTest) Test(org.junit.Test)

Aggregations

GenericConfigSubscriber (com.yahoo.config.subscription.impl.GenericConfigSubscriber)7 Test (org.junit.Test)6 JRTConfigRequesterTest (com.yahoo.config.subscription.impl.JRTConfigRequesterTest)5 JRTConfigRequester (com.yahoo.config.subscription.impl.JRTConfigRequester)2 MockConnection (com.yahoo.config.subscription.impl.MockConnection)2 ConfigSourceSet (com.yahoo.config.subscription.ConfigSourceSet)1 ConfigSubscriber (com.yahoo.config.subscription.ConfigSubscriber)1 GenericConfigHandle (com.yahoo.config.subscription.impl.GenericConfigHandle)1 JRTConfigSubscription (com.yahoo.config.subscription.impl.JRTConfigSubscription)1 SimpletypesConfig (com.yahoo.foo.SimpletypesConfig)1 ConfigKey (com.yahoo.vespa.config.ConfigKey)1 JRTConnectionPool (com.yahoo.vespa.config.JRTConnectionPool)1 TimingValues (com.yahoo.vespa.config.TimingValues)1