Search in sources :

Example 1 with JRTConfigSubscription

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

the class JRTConfigRequestBase method created_from_subscription.

@Test
public void created_from_subscription() {
    ConfigSubscriber subscriber = new ConfigSubscriber();
    JRTConfigSubscription<SimpletypesConfig> sub = new JRTConfigSubscription<>(new ConfigKey<>(SimpletypesConfig.class, configId), subscriber, new ConfigSet(), new TimingValues());
    JRTClientConfigRequest request = createReq(sub, Trace.createNew(9));
    assertThat(request.getConfigKey().getName(), is(SimpletypesConfig.CONFIG_DEF_NAME));
    JRTServerConfigRequest serverRequest = createReq(request.getRequest());
    assertTrue(serverRequest.validateParameters());
}
Also used : SimpletypesConfig(com.yahoo.foo.SimpletypesConfig) GenericConfigSubscriber(com.yahoo.config.subscription.impl.GenericConfigSubscriber) 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 2 with JRTConfigSubscription

use of com.yahoo.config.subscription.impl.JRTConfigSubscription 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 JRTConfigSubscription

use of com.yahoo.config.subscription.impl.JRTConfigSubscription 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)

Aggregations

ConfigSubscriber (com.yahoo.config.subscription.ConfigSubscriber)3 JRTConfigSubscription (com.yahoo.config.subscription.impl.JRTConfigSubscription)3 TimingValues (com.yahoo.vespa.config.TimingValues)3 Test (org.junit.Test)3 ConfigSet (com.yahoo.config.subscription.ConfigSet)2 GenericConfigSubscriber (com.yahoo.config.subscription.impl.GenericConfigSubscriber)2 SimpletypesConfig (com.yahoo.foo.SimpletypesConfig)2 ConfigSourceSet (com.yahoo.config.subscription.ConfigSourceSet)1 MockConnection (com.yahoo.config.subscription.impl.MockConnection)1 FunctionTestConfig (com.yahoo.foo.FunctionTestConfig)1