
org.redisson.config.SentinelServersConfig Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of redisson Show documentation
Show all versions of redisson Show documentation
Redis Java client with features of In-Memory Data Grid
/**
* Copyright 2016 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 java.net.URI;
import java.util.ArrayList;
import java.util.List;
import org.redisson.misc.URIBuilder;
/**
*
* @author Nikita Koksharov
*
*/
public class SentinelServersConfig extends BaseMasterSlaveServersConfig {
private List sentinelAddresses = new ArrayList();
private String masterName;
/**
* Database index used for Redis connection
*/
private int database = 0;
public SentinelServersConfig() {
}
SentinelServersConfig(SentinelServersConfig config) {
super(config);
setSentinelAddresses(config.getSentinelAddresses());
setMasterName(config.getMasterName());
setDatabase(config.getDatabase());
}
/**
* Master server name used by Redis Sentinel servers and master change monitoring task.
*
* @param masterName of Redis
* @return config
*/
public SentinelServersConfig setMasterName(String masterName) {
this.masterName = masterName;
return this;
}
public String getMasterName() {
return masterName;
}
/**
* Add Redis Sentinel node address in host:port format. Multiple nodes at once could be added.
*
* @param addresses of Redis
* @return config
*/
public SentinelServersConfig addSentinelAddress(String ... addresses) {
for (String address : addresses) {
sentinelAddresses.add(URIBuilder.create(address));
}
return this;
}
public List getSentinelAddresses() {
return sentinelAddresses;
}
void setSentinelAddresses(List sentinelAddresses) {
this.sentinelAddresses = sentinelAddresses;
}
/**
* Database index used for Redis connection
* Default is 0
*
* @param database number
* @return config
*/
public SentinelServersConfig setDatabase(int database) {
this.database = database;
return this;
}
public int getDatabase() {
return database;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy