use of com.couchbase.client.core.cnc.events.core.ReconfigurationErrorDetectedEvent in project couchbase-jvm-clients by couchbase.
the class Core method reconfigureDisconnectAll.
/**
* This reconfiguration sequence takes all nodes and disconnects them.
*
* <p>This is usually called by the parent {@link #reconfigure()} when all buckets are closed which
* points to a shutdown/all buckets closed disconnect phase.</p>
*/
private void reconfigureDisconnectAll() {
long start = System.nanoTime();
Flux.fromIterable(new ArrayList<>(nodes)).flatMap(Node::disconnect).doOnComplete(nodes::clear).subscribe(v -> {
}, e -> {
clearReconfigureInProgress();
eventBus.publish(new ReconfigurationErrorDetectedEvent(context(), e));
}, () -> {
clearReconfigureInProgress();
eventBus.publish(new ReconfigurationCompletedEvent(Duration.ofNanos(System.nanoTime() - start), coreContext));
});
}
use of com.couchbase.client.core.cnc.events.core.ReconfigurationErrorDetectedEvent in project couchbase-jvm-clients by couchbase.
the class Core method reconfigure.
/**
* Reconfigures the SDK topology to align with the current server configuration.
*
* <p>When reconfigure is called, it will grab a current configuration and then add/remove
* nodes/services to mirror the current topology and configuration settings.</p>
*
* <p>This is a eventually consistent process, so in-flight operations might still be rescheduled
* and then picked up later (or cancelled, depending on the strategy). For those coming from 1.x,
* it works very similar.</p>
*/
private void reconfigure() {
if (reconfigureInProgress.compareAndSet(false, true)) {
final ClusterConfig configForThisAttempt = currentConfig;
if (configForThisAttempt.bucketConfigs().isEmpty() && configForThisAttempt.globalConfig() == null) {
reconfigureDisconnectAll();
return;
}
final long start = System.nanoTime();
Flux<BucketConfig> bucketConfigFlux = Flux.just(configForThisAttempt).flatMap(cc -> Flux.fromIterable(cc.bucketConfigs().values()));
reconfigureBuckets(bucketConfigFlux).then(reconfigureGlobal(configForThisAttempt.globalConfig())).then(Mono.defer(() -> Flux.fromIterable(new ArrayList<>(nodes)).flatMap(n -> maybeRemoveNode(n, configForThisAttempt)).then())).subscribe(v -> {
}, e -> {
clearReconfigureInProgress();
eventBus.publish(new ReconfigurationErrorDetectedEvent(context(), e));
}, () -> {
clearReconfigureInProgress();
eventBus.publish(new ReconfigurationCompletedEvent(Duration.ofNanos(System.nanoTime() - start), coreContext));
});
} else {
moreConfigsPending.set(true);
eventBus.publish(new ReconfigurationIgnoredEvent(coreContext));
}
}
Aggregations