Search in sources :

Example 1 with PortInfo

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

the class GlobalRefresher method filterEligibleNodes.

private Flux<PortInfo> filterEligibleNodes() {
    return Flux.defer(() -> {
        GlobalConfig config = provider.config().globalConfig();
        if (config == null) {
            // todo: log debug that no node found to refresh a config from
            return Flux.empty();
        }
        List<PortInfo> nodes = new ArrayList<>(config.portInfos());
        shiftNodeList(nodes);
        return Flux.fromIterable(nodes).filter(n -> n.ports().containsKey(ServiceType.KV) || n.sslPorts().containsKey(ServiceType.KV)).take(MAX_PARALLEL_FETCH);
    });
}
Also used : PortInfo(com.couchbase.client.core.config.PortInfo) 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) GlobalConfig(com.couchbase.client.core.config.GlobalConfig) ArrayList(java.util.ArrayList)

Example 2 with PortInfo

use of com.couchbase.client.core.config.PortInfo 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

Core (com.couchbase.client.core.Core)2 CoreContext (com.couchbase.client.core.CoreContext)2 Reactor (com.couchbase.client.core.Reactor)2 ConfigurationProvider (com.couchbase.client.core.config.ConfigurationProvider)2 GlobalConfig (com.couchbase.client.core.config.GlobalConfig)2 PortInfo (com.couchbase.client.core.config.PortInfo)2 ProposedGlobalConfigContext (com.couchbase.client.core.config.ProposedGlobalConfigContext)2 MAX_PARALLEL_FETCH (com.couchbase.client.core.config.refresher.KeyValueBucketRefresher.MAX_PARALLEL_FETCH)2 POLLER_INTERVAL (com.couchbase.client.core.config.refresher.KeyValueBucketRefresher.POLLER_INTERVAL)2 KeyValueBucketRefresher.clampConfigRequestTimeout (com.couchbase.client.core.config.refresher.KeyValueBucketRefresher.clampConfigRequestTimeout)2 CarrierGlobalConfigRequest (com.couchbase.client.core.msg.kv.CarrierGlobalConfigRequest)2 FailFastRetryStrategy (com.couchbase.client.core.retry.FailFastRetryStrategy)2 ServiceType (com.couchbase.client.core.service.ServiceType)2 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)2 Duration (java.time.Duration)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 Disposable (reactor.core.Disposable)2 Flux (reactor.core.publisher.Flux)2