All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.redisson.config.ClusterServersConfig Maven / Gradle / Ivy

Go to download

Easy Redis Java client and Real-Time Data Platform. Valkey compatible. Sync/Async/RxJava3/Reactive API. Client side caching. Over 50 Redis based Java objects and services: JCache API, Apache Tomcat, Hibernate, Spring, Set, Multimap, SortedSet, Map, List, Queue, Deque, Semaphore, Lock, AtomicLong, Map Reduce, Bloom filter, Scheduler, RPC

The newest version!
/**
 * Copyright (c) 2013-2024 Nikita Koksharov
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.redisson.config;

import org.redisson.api.HostNatMapper;
import org.redisson.api.HostPortNatMapper;
import org.redisson.api.NatMapper;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * 
 * @author Nikita Koksharov
 *
 */
public class ClusterServersConfig extends BaseMasterSlaveServersConfig {

    private NatMapper natMapper = NatMapper.direct();
    
    /**
     * Redis cluster node urls list
     */
    private List nodeAddresses = new ArrayList<>();

    /**
     * Redis cluster scan interval in milliseconds
     */
    private int scanInterval = 5000;

    private boolean checkSlotsCoverage = true;

    private ShardedSubscriptionMode shardedSubscriptionMode = ShardedSubscriptionMode.AUTO;

    public ClusterServersConfig() {
    }

    ClusterServersConfig(ClusterServersConfig config) {
        super(config);
        setNodeAddresses(config.getNodeAddresses());
        setScanInterval(config.getScanInterval());
        setNatMapper(config.getNatMapper());
        setCheckSlotsCoverage(config.isCheckSlotsCoverage());
        setShardedSubscriptionMode(config.getShardedSubscriptionMode());
    }

    /**
     * Add Redis cluster node address. Use follow format -- host:port
     *
     * @param addresses in host:port format
     * @return config
     */
    public ClusterServersConfig addNodeAddress(String... addresses) {
        nodeAddresses.addAll(Arrays.asList(addresses));
        return this;
    }
    public List getNodeAddresses() {
        return nodeAddresses;
    }
    public void setNodeAddresses(List nodeAddresses) {
        this.nodeAddresses = nodeAddresses;
    }

    public int getScanInterval() {
        return scanInterval;
    }
    /**
     * Redis cluster scan interval in milliseconds
     * 

* Default is 5000 * * @param scanInterval in milliseconds * @return config */ public ClusterServersConfig setScanInterval(int scanInterval) { this.scanInterval = scanInterval; return this; } public boolean isCheckSlotsCoverage() { return checkSlotsCoverage; } /** * Enables cluster slots check during Redisson startup. *

* Default is true * * @param checkSlotsCoverage boolean value * @return config */ public ClusterServersConfig setCheckSlotsCoverage(boolean checkSlotsCoverage) { this.checkSlotsCoverage = checkSlotsCoverage; return this; } /* * Use {@link #setNatMapper(NatMapper)} */ @Deprecated public ClusterServersConfig setNatMap(Map natMap) { HostPortNatMapper mapper = new HostPortNatMapper(); mapper.setHostsPortMap(natMap); this.natMapper = mapper; return this; } public NatMapper getNatMapper() { return natMapper; } /** * Defines NAT mapper which maps Redis URI object. * Applied to all Redis connections. * * @see HostNatMapper * @see HostPortNatMapper * * @param natMapper nat mapper object * @return config */ public ClusterServersConfig setNatMapper(NatMapper natMapper) { this.natMapper = natMapper; return this; } public ShardedSubscriptionMode getShardedSubscriptionMode() { return shardedSubscriptionMode; } /** * Defines whether to use sharded subscription feature available in Redis 7.0+. *

* Used in RMapCache, RLocalCachedMap, RCountDownLatch, RLock, RPermitExpirableSemaphore, * RSemaphore, RLongAdder, RDoubleAdder, Micronaut Session, Apache Tomcat Manager objects. *

* Default is AUTO * * @param shardedSubscriptionMode param * @return config */ public ClusterServersConfig setShardedSubscriptionMode(ShardedSubscriptionMode shardedSubscriptionMode) { this.shardedSubscriptionMode = shardedSubscriptionMode; return this; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy