Search in sources :

Example 1 with ProposedGlobalConfigContext

use of com.couchbase.client.core.config.ProposedGlobalConfigContext in project couchbase-jvm-clients by couchbase.

the class GlobalLoaderIntegrationTest method loadGlobalConfigViaCarrierPublication.

/**
 * This is a very simplistic test that makes sure that we can "round trip" in the
 * {@link GlobalLoader} by grabbing a JSON decodable config through the full stack.
 */
@Test
void loadGlobalConfigViaCarrierPublication() {
    TestNodeConfig config = config().firstNodeWith(Services.KV).get();
    Core core = Core.create(env, authenticator(), seedNodes());
    GlobalLoader loader = new GlobalLoader(core);
    ProposedGlobalConfigContext globalConfigContext = loader.load(new NodeIdentifier(config.hostname(), config.ports().get(Services.MANAGER)), config.ports().get(Services.KV)).block();
    assertNotNull(globalConfigContext);
    assertNotNull(globalConfigContext.config());
    core.shutdown().block();
}
Also used : TestNodeConfig(com.couchbase.client.test.TestNodeConfig) ProposedGlobalConfigContext(com.couchbase.client.core.config.ProposedGlobalConfigContext) NodeIdentifier(com.couchbase.client.core.node.NodeIdentifier) Core(com.couchbase.client.core.Core) CoreIntegrationTest(com.couchbase.client.core.util.CoreIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 2 with ProposedGlobalConfigContext

use of com.couchbase.client.core.config.ProposedGlobalConfigContext in project couchbase-jvm-clients by couchbase.

the class GlobalBucketRefresherIntegrationTest method loadGlobalConfig.

/**
 * Not related, but to test the refresh we first need to load the global config and prime the config provider.
 */
private void loadGlobalConfig(final ConfigurationProvider provider) {
    TestNodeConfig config = config().firstNodeWith(Services.KV).get();
    GlobalLoader loader = new GlobalLoader(core);
    ProposedGlobalConfigContext globalConfigContext = loader.load(new NodeIdentifier(config.hostname(), config.ports().get(Services.MANAGER)), config.ports().get(Services.KV)).block();
    provider.proposeGlobalConfig(globalConfigContext);
}
Also used : GlobalLoader(com.couchbase.client.core.config.loader.GlobalLoader) TestNodeConfig(com.couchbase.client.test.TestNodeConfig) ProposedGlobalConfigContext(com.couchbase.client.core.config.ProposedGlobalConfigContext) NodeIdentifier(com.couchbase.client.core.node.NodeIdentifier)

Example 3 with ProposedGlobalConfigContext

use of com.couchbase.client.core.config.ProposedGlobalConfigContext in project couchbase-jvm-clients by couchbase.

the class GlobalRefresher method attemptUpdateGlobalConfig.

private Flux<ProposedGlobalConfigContext> attemptUpdateGlobalConfig(final Flux<PortInfo> nodes) {
    return nodes.flatMap(nodeInfo -> {
        CoreContext ctx = core.context();
        CarrierGlobalConfigRequest request = new CarrierGlobalConfigRequest(configRequestTimeout, ctx, FailFastRetryStrategy.INSTANCE, nodeInfo.identifier());
        core.send(request);
        return Reactor.wrap(request, request.response(), true).filter(response -> {
            // TODO: debug event that it got ignored.
            return response.status().success();
        }).map(response -> new ProposedGlobalConfigContext(new String(response.content(), UTF_8), nodeInfo.hostname())).onErrorResume(t -> {
            // TODO: raise a warning that fetching a config individual failed.
            return Mono.empty();
        });
    });
}
Also used : Disposable(reactor.core.Disposable) Reactor(com.couchbase.client.core.Reactor) UTF_8(java.nio.charset.StandardCharsets.UTF_8) GlobalConfig(com.couchbase.client.core.config.GlobalConfig) Mono(reactor.core.publisher.Mono) ProposedGlobalConfigContext(com.couchbase.client.core.config.ProposedGlobalConfigContext) KeyValueBucketRefresher.clampConfigRequestTimeout(com.couchbase.client.core.config.refresher.KeyValueBucketRefresher.clampConfigRequestTimeout) CarrierGlobalConfigRequest(com.couchbase.client.core.msg.kv.CarrierGlobalConfigRequest) FailFastRetryStrategy(com.couchbase.client.core.retry.FailFastRetryStrategy) ArrayList(java.util.ArrayList) Flux(reactor.core.publisher.Flux) AtomicLong(java.util.concurrent.atomic.AtomicLong) MAX_PARALLEL_FETCH(com.couchbase.client.core.config.refresher.KeyValueBucketRefresher.MAX_PARALLEL_FETCH) List(java.util.List) POLLER_INTERVAL(com.couchbase.client.core.config.refresher.KeyValueBucketRefresher.POLLER_INTERVAL) ServiceType(com.couchbase.client.core.service.ServiceType) CoreContext(com.couchbase.client.core.CoreContext) Duration(java.time.Duration) Core(com.couchbase.client.core.Core) ConfigurationProvider(com.couchbase.client.core.config.ConfigurationProvider) PortInfo(com.couchbase.client.core.config.PortInfo) CoreContext(com.couchbase.client.core.CoreContext) CarrierGlobalConfigRequest(com.couchbase.client.core.msg.kv.CarrierGlobalConfigRequest) ProposedGlobalConfigContext(com.couchbase.client.core.config.ProposedGlobalConfigContext)

Aggregations

ProposedGlobalConfigContext (com.couchbase.client.core.config.ProposedGlobalConfigContext)3 Core (com.couchbase.client.core.Core)2 NodeIdentifier (com.couchbase.client.core.node.NodeIdentifier)2 TestNodeConfig (com.couchbase.client.test.TestNodeConfig)2 CoreContext (com.couchbase.client.core.CoreContext)1 Reactor (com.couchbase.client.core.Reactor)1 ConfigurationProvider (com.couchbase.client.core.config.ConfigurationProvider)1 GlobalConfig (com.couchbase.client.core.config.GlobalConfig)1 PortInfo (com.couchbase.client.core.config.PortInfo)1 GlobalLoader (com.couchbase.client.core.config.loader.GlobalLoader)1 MAX_PARALLEL_FETCH (com.couchbase.client.core.config.refresher.KeyValueBucketRefresher.MAX_PARALLEL_FETCH)1 POLLER_INTERVAL (com.couchbase.client.core.config.refresher.KeyValueBucketRefresher.POLLER_INTERVAL)1 KeyValueBucketRefresher.clampConfigRequestTimeout (com.couchbase.client.core.config.refresher.KeyValueBucketRefresher.clampConfigRequestTimeout)1 CarrierGlobalConfigRequest (com.couchbase.client.core.msg.kv.CarrierGlobalConfigRequest)1 FailFastRetryStrategy (com.couchbase.client.core.retry.FailFastRetryStrategy)1 ServiceType (com.couchbase.client.core.service.ServiceType)1 CoreIntegrationTest (com.couchbase.client.core.util.CoreIntegrationTest)1 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)1 Duration (java.time.Duration)1 ArrayList (java.util.ArrayList)1