Search in sources :

Example 1 with ReplicateTo

use of com.couchbase.client.java.kv.ReplicateTo in project kafka-connect-couchbase by couchbase.

the class DurabilitySetter method create.

static DurabilitySetter create(DurabilityConfig config) {
    DurabilityLevel durabilityLevel = config.durability();
    if (durabilityLevel != DurabilityLevel.NONE) {
        if (config.persistTo() != PersistTo.NONE || config.replicateTo() != ReplicateTo.NONE) {
            String durabilityKey = keyName(DurabilityConfig.class, DurabilityConfig::durability);
            String replicateToKey = keyName(DurabilityConfig.class, DurabilityConfig::replicateTo);
            String persistToKey = keyName(DurabilityConfig.class, DurabilityConfig::persistTo);
            throw new ConnectException("Invalid durability config. When '" + durabilityKey + "' is set," + " you must not set '" + replicateToKey + "' or '" + persistToKey + "'.");
        }
        return options -> options.durability(durabilityLevel);
    }
    PersistTo persistTo = config.persistTo();
    ReplicateTo replicateTo = config.replicateTo();
    return options -> options.durability(persistTo, replicateTo);
}
Also used : Consumer(java.util.function.Consumer) DurabilityConfig(com.couchbase.connect.kafka.config.sink.DurabilityConfig) ConfigHelper.keyName(com.couchbase.connect.kafka.util.config.ConfigHelper.keyName) ConnectException(org.apache.kafka.connect.errors.ConnectException) DurabilityLevel(com.couchbase.client.core.msg.kv.DurabilityLevel) PersistTo(com.couchbase.client.java.kv.PersistTo) ReplicateTo(com.couchbase.client.java.kv.ReplicateTo) CommonDurabilityOptions(com.couchbase.client.java.kv.CommonDurabilityOptions) DurabilityConfig(com.couchbase.connect.kafka.config.sink.DurabilityConfig) ReplicateTo(com.couchbase.client.java.kv.ReplicateTo) DurabilityLevel(com.couchbase.client.core.msg.kv.DurabilityLevel) PersistTo(com.couchbase.client.java.kv.PersistTo) ConnectException(org.apache.kafka.connect.errors.ConnectException)

Aggregations

DurabilityLevel (com.couchbase.client.core.msg.kv.DurabilityLevel)1 CommonDurabilityOptions (com.couchbase.client.java.kv.CommonDurabilityOptions)1 PersistTo (com.couchbase.client.java.kv.PersistTo)1 ReplicateTo (com.couchbase.client.java.kv.ReplicateTo)1 DurabilityConfig (com.couchbase.connect.kafka.config.sink.DurabilityConfig)1 ConfigHelper.keyName (com.couchbase.connect.kafka.util.config.ConfigHelper.keyName)1 Consumer (java.util.function.Consumer)1 ConnectException (org.apache.kafka.connect.errors.ConnectException)1