Search in sources :

Example 1 with BucketConfigUpdatedEvent

use of com.couchbase.client.core.cnc.events.config.BucketConfigUpdatedEvent in project couchbase-jvm-clients by couchbase.

the class DefaultConfigurationProvider method checkAndApplyConfig.

/**
 * Analyzes the given config and decides if to apply it (and does so if needed).
 *
 * @param newConfig the config to apply.
 */
private void checkAndApplyConfig(final BucketConfig newConfig) {
    final String name = newConfig.name();
    final BucketConfig oldConfig = currentConfig.bucketConfig(name);
    if (oldConfig != null && configIsOlderOrSame(oldConfig.revEpoch(), newConfig.revEpoch(), oldConfig.rev(), newConfig.rev())) {
        eventBus.publish(new ConfigIgnoredEvent(core.context(), ConfigIgnoredEvent.Reason.OLD_OR_SAME_REVISION, Optional.empty(), Optional.empty(), Optional.of(newConfig.name())));
        return;
    }
    if (newConfig.tainted()) {
        keyValueRefresher.markTainted(name);
        clusterManagerRefresher.markTainted(name);
    } else {
        keyValueRefresher.markUntainted(name);
        clusterManagerRefresher.markUntainted(name);
    }
    eventBus.publish(new BucketConfigUpdatedEvent(core.context(), newConfig));
    currentConfig.setBucketConfig(newConfig);
    checkAlternateAddress();
    updateSeedNodeList();
    pushConfig();
}
Also used : ConfigIgnoredEvent(com.couchbase.client.core.cnc.events.config.ConfigIgnoredEvent) BucketConfigUpdatedEvent(com.couchbase.client.core.cnc.events.config.BucketConfigUpdatedEvent)

Aggregations

BucketConfigUpdatedEvent (com.couchbase.client.core.cnc.events.config.BucketConfigUpdatedEvent)1 ConfigIgnoredEvent (com.couchbase.client.core.cnc.events.config.ConfigIgnoredEvent)1