Skip to content

Commit

Permalink
去除Redis集群管理
Browse files Browse the repository at this point in the history
  • Loading branch information
夜色 committed Dec 19, 2016
1 parent 125cbf9 commit fc94063
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Expand Up @@ -16,6 +16,7 @@
package com.mpush.cache.redis.connection;

import com.mpush.cache.redis.RedisServer;
import com.mpush.tools.config.data.RedisNode;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.slf4j.Logger;
Expand Down Expand Up @@ -49,7 +50,7 @@ public class RedisConnectionFactory {
private JedisPoolConfig poolConfig = new JedisPoolConfig();
private int dbIndex = 0;
private JedisCluster cluster;
private List<RedisServer> redisServers;
private List<RedisNode> redisServers;
private boolean isCluster = false;

/**
Expand Down Expand Up @@ -127,11 +128,11 @@ private JedisCluster createCluster() {
* @return
* @since 1.7
*/
protected JedisCluster createCluster(List<RedisServer> servers, GenericObjectPoolConfig poolConfig) {
protected JedisCluster createCluster(List<RedisNode> servers, GenericObjectPoolConfig poolConfig) {

Set<HostAndPort> hostAndPort = servers
.stream()
.map(RedisServer::convert)
.map(redisNode -> new HostAndPort(redisNode.host, redisNode.port))
.collect(Collectors.toSet());

int redirects = 5;
Expand Down Expand Up @@ -318,7 +319,7 @@ public void setCluster(boolean cluster) {
isCluster = cluster;
}

public void setRedisServers(List<RedisServer> redisServers) {
public void setRedisServers(List<RedisNode> redisServers) {
Objects.requireNonNull(redisServers);
this.redisServers = redisServers;
this.hostName = redisServers.get(0).getHost();
Expand Down
Expand Up @@ -42,11 +42,9 @@ public final class RedisManager {

public void init() {
Logs.REDIS.info("begin init redis...");
RedisClusterManager clusterManager = new ZKRedisClusterManager();
clusterManager.init();
factory.setPassword(CC.mp.redis.password);
factory.setPoolConfig(CC.mp.redis.getPoolConfig(JedisPoolConfig.class));
factory.setRedisServers(clusterManager.getServers());
factory.setRedisServers(CC.mp.redis.nodes);
factory.setCluster(CC.mp.redis.isCluster());
factory.init();
test();
Expand Down
Expand Up @@ -36,10 +36,11 @@

import static com.mpush.zk.ZKPath.REDIS_SERVER;

public class ZKRedisClusterManager implements RedisClusterManager {
@Deprecated
class ZKRedisClusterManager implements RedisClusterManager {
private final ZKRedisNodeWatcher watcher = new ZKRedisNodeWatcher();

public ZKRedisClusterManager() {
private ZKRedisClusterManager() {
}

/**
Expand Down

0 comments on commit fc94063

Please sign in to comment.