use of com.yahoo.config.subscription.ConfigSourceSet in project vespa by vespa-engine.
the class ConfigProxyRpcServerTest method setup.
@Before
public void setup() {
proxyServer = ProxyServer.createTestServer(new ConfigSourceSet(address));
rpcServer = new ConfigProxyRpcServer(proxyServer, new Supervisor(new Transport()), null);
}
use of com.yahoo.config.subscription.ConfigSourceSet 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", "");
}
use of com.yahoo.config.subscription.ConfigSourceSet in project vespa by vespa-engine.
the class ConfigHelperTest method basic.
@Test
public void basic() {
ConfigSourceSet configSourceSet = new ConfigSourceSet("host.com");
ConfigHelper helper = new ConfigHelper(configSourceSet);
assertThat(helper.getConfigSourceSet(), is(configSourceSet));
assertThat(helper.getConnectionPool().getAllSourceAddresses(), is("host.com"));
assertThat(helper.getTimingValues().getSubscribeTimeout(), is(new TimingValues().getSubscribeTimeout()));
// Specify timing values
TimingValues tv = new TimingValues();
tv.setSubscribeTimeout(11L);
helper = new ConfigHelper(configSourceSet, tv);
assertThat(helper.getTimingValues().getSubscribeTimeout(), is(tv.getSubscribeTimeout()));
}
use of com.yahoo.config.subscription.ConfigSourceSet in project vespa by vespa-engine.
the class JRTConnectionPoolTest method updateSources.
/**
* Tests that updating config sources works.
*/
@Test
public void updateSources() {
List<String> twoSources = new ArrayList<>();
twoSources.add("host0");
twoSources.add("host1");
JRTConnectionPool sourcePool = new JRTConnectionPool(twoSources);
ConfigSourceSet sourcesBefore = sourcePool.getSourceSet();
// Update to the same set, should be equal
sourcePool.updateSources(twoSources);
assertThat(sourcesBefore, is(sourcePool.getSourceSet()));
// Update to new set
List<String> newSources = new ArrayList<>();
newSources.add("host2");
newSources.add("host3");
sourcePool.updateSources(newSources);
ConfigSourceSet newSourceSet = sourcePool.getSourceSet();
assertNotNull(newSourceSet);
assertThat(newSourceSet.getSources().size(), is(2));
assertThat(newSourceSet, is(not(sourcesBefore)));
assertTrue(newSourceSet.getSources().contains("host2"));
assertTrue(newSourceSet.getSources().contains("host3"));
// Update to new set with just one host
List<String> newSources2 = new ArrayList<>();
newSources2.add("host4");
sourcePool.updateSources(newSources2);
ConfigSourceSet newSourceSet2 = sourcePool.getSourceSet();
assertNotNull(newSourceSet2);
assertThat(newSourceSet2.getSources().size(), is(1));
assertThat(newSourceSet2, is(not(newSourceSet)));
assertTrue(newSourceSet2.getSources().contains("host4"));
}
use of com.yahoo.config.subscription.ConfigSourceSet in project vespa by vespa-engine.
the class ExternalSlobrokPolicy method init.
@Override
public void init() {
if (slobroks != null) {
orb = new Supervisor(new Transport());
mirror = new Mirror(orb, slobroks);
}
if (configSources != null) {
if (mirror == null) {
orb = new Supervisor(new Transport());
subscriber = subscribe(slobrokConfigId, new ConfigSourceSet(configSources));
}
}
}
Aggregations