Search in sources :

Example 6 with ConfigSubscriber

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

the class JRTConfigRequesterTest method testTimeout.

@Test
public void testTimeout() {
    ConfigSubscriber subscriber = new ConfigSubscriber();
    final TimingValues timingValues = getTestTimingValues();
    JRTConfigSubscription<SimpletypesConfig> sub = createSubscription(subscriber, timingValues);
    sub.close();
    final MockConnection connection = new MockConnection(new DelayedResponseHandler(timingValues.getSubscribeTimeout()), // fake that we have more than one source
    2);
    JRTConfigRequester requester = new JRTConfigRequester(connection, timingValues);
    requester.request(createSubscription(subscriber, timingValues));
    // Check that no further request was sent?
    try {
        Thread.sleep(timingValues.getFixedDelay() * 2);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    assertTrue(connection.getNumberOfFailovers() >= 1);
}
Also used : SimpletypesConfig(com.yahoo.foo.SimpletypesConfig) ConfigSubscriber(com.yahoo.config.subscription.ConfigSubscriber) TimingValues(com.yahoo.vespa.config.TimingValues) Test(org.junit.Test)

Example 7 with ConfigSubscriber

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

the class JRTConfigRequesterTest method testTransientError.

@Test
public void testTransientError() {
    ConfigSubscriber subscriber = new ConfigSubscriber();
    final TimingValues timingValues = getTestTimingValues();
    final MockConnection connection = new MockConnection(new ErrorResponseHandler(com.yahoo.jrt.ErrorCode.TIMEOUT));
    JRTConfigRequester requester = new JRTConfigRequester(connection, timingValues);
    requester.request(createSubscription(subscriber, timingValues));
    waitUntilResponse(connection);
    assertThat(requester.getFatalFailures(), is(0));
    assertThat(requester.getTransientFailures(), is(1));
}
Also used : ConfigSubscriber(com.yahoo.config.subscription.ConfigSubscriber) TimingValues(com.yahoo.vespa.config.TimingValues) Test(org.junit.Test)

Example 8 with ConfigSubscriber

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

the class JRTConfigRequestFactoryTest method testCreateFromSub.

@Test
public void testCreateFromSub() {
    ConfigSubscriber subscriber = new ConfigSubscriber();
    Class<FunctionTestConfig> clazz = FunctionTestConfig.class;
    final String configId = "foo";
    JRTConfigSubscription<FunctionTestConfig> sub = new JRTConfigSubscription<>(new ConfigKey<>(clazz, configId), subscriber, new ConfigSet(), new TimingValues());
    // Default vespa version
    JRTClientConfigRequest request = JRTConfigRequestFactory.createFromSub(sub);
    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.createFromSub(sub);
    assertThat(request.getProtocolVersion(), is(3L));
    assertThat(request.getVespaVersion().get(), is(VespaVersion.fromString(version)));
    System.clearProperty(JRTConfigRequestFactory.VESPA_VERSION);
}
Also used : FunctionTestConfig(com.yahoo.foo.FunctionTestConfig) ConfigSubscriber(com.yahoo.config.subscription.ConfigSubscriber) TimingValues(com.yahoo.vespa.config.TimingValues) JRTConfigSubscription(com.yahoo.config.subscription.impl.JRTConfigSubscription) ConfigSet(com.yahoo.config.subscription.ConfigSet) Test(org.junit.Test)

Example 9 with ConfigSubscriber

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

the class ConfigAgent method subscribe.

/**
 * Start listening for config updates. This method will not return until the handler has been configured at least
 * once unless an exception is thrown.
 */
public void subscribe() {
    if (configURI != null) {
        subscriber = new ConfigSubscriber(configURI.getSource());
        subscriber.subscribe(this, MessagebusConfig.class, configURI.getConfigId());
    }
}
Also used : ConfigSubscriber(com.yahoo.config.subscription.ConfigSubscriber)

Example 10 with ConfigSubscriber

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

the class DocumentTypeManagerConfigurer method configure.

public ConfigSubscriber configure(String configId) {
    ConfigSubscriber subscriber = new ConfigSubscriber();
    subscriber.subscribe(this, DocumentmanagerConfig.class, configId);
    return subscriber;
}
Also used : ConfigSubscriber(com.yahoo.config.subscription.ConfigSubscriber)

Aggregations

ConfigSubscriber (com.yahoo.config.subscription.ConfigSubscriber)18 Test (org.junit.Test)15 TimingValues (com.yahoo.vespa.config.TimingValues)12 SimpletypesConfig (com.yahoo.foo.SimpletypesConfig)11 FileSource (com.yahoo.config.subscription.FileSource)3 JRTConfigSubscription (com.yahoo.config.subscription.impl.JRTConfigSubscription)3 ConfigSet (com.yahoo.config.subscription.ConfigSet)2 GenericConfigSubscriber (com.yahoo.config.subscription.impl.GenericConfigSubscriber)2 ConfigSourceSet (com.yahoo.config.subscription.ConfigSourceSet)1 DirSource (com.yahoo.config.subscription.DirSource)1 MockConnection (com.yahoo.config.subscription.impl.MockConnection)1 FunctionTestConfig (com.yahoo.foo.FunctionTestConfig)1 TestReferenceConfig (com.yahoo.foo.TestReferenceConfig)1 Request (com.yahoo.jrt.Request)1 ConfigKey (com.yahoo.vespa.config.ConfigKey)1 JRTServerConfigRequestV3 (com.yahoo.vespa.config.protocol.JRTServerConfigRequestV3)1 File (java.io.File)1