Search in sources :

Example 1 with ConfigSourceSet

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);
}
Also used : Supervisor(com.yahoo.jrt.Supervisor) ConfigSourceSet(com.yahoo.config.subscription.ConfigSourceSet) Transport(com.yahoo.jrt.Transport) Before(org.junit.Before)

Example 2 with ConfigSourceSet

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", "");
}
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 3 with ConfigSourceSet

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

Example 4 with ConfigSourceSet

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"));
}
Also used : ConfigSourceSet(com.yahoo.config.subscription.ConfigSourceSet) Test(org.junit.Test)

Example 5 with ConfigSourceSet

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));
        }
    }
}
Also used : Supervisor(com.yahoo.jrt.Supervisor) ConfigSourceSet(com.yahoo.config.subscription.ConfigSourceSet) Transport(com.yahoo.jrt.Transport) IMirror(com.yahoo.jrt.slobrok.api.IMirror) Mirror(com.yahoo.jrt.slobrok.api.Mirror)

Aggregations

ConfigSourceSet (com.yahoo.config.subscription.ConfigSourceSet)7 Test (org.junit.Test)3 Supervisor (com.yahoo.jrt.Supervisor)2 Transport (com.yahoo.jrt.Transport)2 ConfigSubscriber (com.yahoo.config.subscription.ConfigSubscriber)1 GenericConfigSubscriber (com.yahoo.config.subscription.impl.GenericConfigSubscriber)1 JRTConfigSubscription (com.yahoo.config.subscription.impl.JRTConfigSubscription)1 MockConnection (com.yahoo.config.subscription.impl.MockConnection)1 SimpletypesConfig (com.yahoo.foo.SimpletypesConfig)1 Spec (com.yahoo.jrt.Spec)1 IMirror (com.yahoo.jrt.slobrok.api.IMirror)1 Mirror (com.yahoo.jrt.slobrok.api.Mirror)1 TimingValues (com.yahoo.vespa.config.TimingValues)1 Before (org.junit.Before)1