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);
}
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));
}
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);
}
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());
}
}
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;
}
Aggregations