Search in sources :

Example 1 with ConfigIgnoredEvent

use of com.couchbase.client.core.cnc.events.config.ConfigIgnoredEvent 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)

Example 2 with ConfigIgnoredEvent

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

the class DefaultConfigurationProvider method proposeBucketConfig.

@Override
public void proposeBucketConfig(final ProposedBucketConfigContext ctx) {
    if (!shutdown.get()) {
        try {
            BucketConfig config = BucketConfigParser.parse(ctx.config(), core.context().environment(), ctx.origin());
            checkAndApplyConfig(config);
        } catch (Exception ex) {
            eventBus.publish(new ConfigIgnoredEvent(core.context(), ConfigIgnoredEvent.Reason.PARSE_FAILURE, Optional.of(ex), Optional.of(ctx.config()), Optional.of(ctx.bucketName())));
        }
    } else {
        eventBus.publish(new ConfigIgnoredEvent(core.context(), ConfigIgnoredEvent.Reason.ALREADY_SHUTDOWN, Optional.empty(), Optional.of(ctx.config()), Optional.of(ctx.bucketName())));
    }
}
Also used : ConfigIgnoredEvent(com.couchbase.client.core.cnc.events.config.ConfigIgnoredEvent) BucketNotFoundDuringLoadException(com.couchbase.client.core.error.BucketNotFoundDuringLoadException) UnsupportedConfigMechanismException(com.couchbase.client.core.error.UnsupportedConfigMechanismException) CouchbaseException(com.couchbase.client.core.error.CouchbaseException) ConfigException(com.couchbase.client.core.error.ConfigException) RequestCanceledException(com.couchbase.client.core.error.RequestCanceledException) BucketNotReadyDuringLoadException(com.couchbase.client.core.error.BucketNotReadyDuringLoadException) SeedNodeOutdatedException(com.couchbase.client.core.error.SeedNodeOutdatedException) AlreadyShutdownException(com.couchbase.client.core.error.AlreadyShutdownException)

Example 3 with ConfigIgnoredEvent

use of com.couchbase.client.core.cnc.events.config.ConfigIgnoredEvent 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 GlobalConfig newConfig) {
    final GlobalConfig oldConfig = currentConfig.globalConfig();
    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.empty()));
        return;
    }
    eventBus.publish(new GlobalConfigUpdatedEvent(core.context(), newConfig));
    currentConfig.setGlobalConfig(newConfig);
    checkAlternateAddress();
    updateSeedNodeList();
    pushConfig();
}
Also used : GlobalConfigUpdatedEvent(com.couchbase.client.core.cnc.events.config.GlobalConfigUpdatedEvent) ConfigIgnoredEvent(com.couchbase.client.core.cnc.events.config.ConfigIgnoredEvent)

Example 4 with ConfigIgnoredEvent

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

the class DefaultConfigurationProvider method proposeGlobalConfig.

@Override
public void proposeGlobalConfig(final ProposedGlobalConfigContext ctx) {
    if (!shutdown.get()) {
        try {
            GlobalConfig config = GlobalConfigParser.parse(ctx.config(), ctx.origin());
            checkAndApplyConfig(config);
        } catch (Exception ex) {
            eventBus.publish(new ConfigIgnoredEvent(core.context(), ConfigIgnoredEvent.Reason.PARSE_FAILURE, Optional.of(ex), Optional.of(ctx.config()), Optional.empty()));
        }
    } else {
        eventBus.publish(new ConfigIgnoredEvent(core.context(), ConfigIgnoredEvent.Reason.ALREADY_SHUTDOWN, Optional.empty(), Optional.of(ctx.config()), Optional.empty()));
    }
}
Also used : ConfigIgnoredEvent(com.couchbase.client.core.cnc.events.config.ConfigIgnoredEvent) BucketNotFoundDuringLoadException(com.couchbase.client.core.error.BucketNotFoundDuringLoadException) UnsupportedConfigMechanismException(com.couchbase.client.core.error.UnsupportedConfigMechanismException) CouchbaseException(com.couchbase.client.core.error.CouchbaseException) ConfigException(com.couchbase.client.core.error.ConfigException) RequestCanceledException(com.couchbase.client.core.error.RequestCanceledException) BucketNotReadyDuringLoadException(com.couchbase.client.core.error.BucketNotReadyDuringLoadException) SeedNodeOutdatedException(com.couchbase.client.core.error.SeedNodeOutdatedException) AlreadyShutdownException(com.couchbase.client.core.error.AlreadyShutdownException)

Aggregations

ConfigIgnoredEvent (com.couchbase.client.core.cnc.events.config.ConfigIgnoredEvent)4 AlreadyShutdownException (com.couchbase.client.core.error.AlreadyShutdownException)2 BucketNotFoundDuringLoadException (com.couchbase.client.core.error.BucketNotFoundDuringLoadException)2 BucketNotReadyDuringLoadException (com.couchbase.client.core.error.BucketNotReadyDuringLoadException)2 ConfigException (com.couchbase.client.core.error.ConfigException)2 CouchbaseException (com.couchbase.client.core.error.CouchbaseException)2 RequestCanceledException (com.couchbase.client.core.error.RequestCanceledException)2 SeedNodeOutdatedException (com.couchbase.client.core.error.SeedNodeOutdatedException)2 UnsupportedConfigMechanismException (com.couchbase.client.core.error.UnsupportedConfigMechanismException)2 BucketConfigUpdatedEvent (com.couchbase.client.core.cnc.events.config.BucketConfigUpdatedEvent)1 GlobalConfigUpdatedEvent (com.couchbase.client.core.cnc.events.config.GlobalConfigUpdatedEvent)1