Commit 9cb8ed9f authored by 李德才's avatar 李德才

兼容单个Redis实例的配置信息

parent a681395e
......@@ -3,9 +3,11 @@ package com.archser.aserver.common.config.plugins;
import com.archser.aserver.plugin.redis.RedisSentinelPlugin;
import com.jfinal.config.Plugins;
import com.jfinal.kit.Prop;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.redis.RedisPlugin;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.criteria.CriteriaBuilder.In;
import redis.clients.jedis.HostAndPort;
/**
......@@ -19,29 +21,31 @@ public class RedisConfig {
public RedisConfig(Plugins plugins, Prop prop) {
boolean openRedisSentinel = prop.getBoolean("openRedisSentinel");
String redisUrl = prop.get("redis.url");
// 哨兵配置
if (openRedisSentinel) {
String redisSentinel = prop.get("redisSentinel.url");
if (redisUrl.contains(",")) {
Set<HostAndPort> sentinels = new HashSet<HostAndPort>();
String[] split = redisSentinel.split(",");
String[] split = redisUrl.split(",");
int port = 26379;
for (String item : split) {
sentinels.add(new HostAndPort(item.split(":")[0], Integer.parseInt(item.split(":")[1])));
if (item.contains(":")) {
port = Integer.parseInt(item.split(":")[1]);
}
sentinels.add(new HostAndPort(item.split(":")[0], port));
}
RedisSentinelPlugin redisSentinelPlugin = new RedisSentinelPlugin(
prop.get("redisSentinel.CacheName", "redisSentinel"),
prop.get("redisSentinel.masterName", "mymaster"),
sentinels, prop.get("redisSentinel.password", "archser_redis"));
sentinels, prop.get("redis.password", "archser_redis"));
plugins.add(redisSentinelPlugin);
}
// 普通Redis单实例配置
if (!openRedisSentinel) {
} else {
// 普通Redis单实例配置
RedisPlugin redis = new RedisPlugin("redis", prop.get("redis.url"),
prop.getInt("redis.port", 6379),
prop.get("redis.password"));
plugins.add(redis);
}
}
}
......@@ -42,19 +42,14 @@ MiddlewareType=dev
### don't open redis and redisSentinel At the same time
### \u4E0D\u8981\u540C\u65F6\u6253\u5F00 redis \u5355\u5B9E\u4F8B \u548C redisSentinel \u54E8\u5175\u96C6\u7FA4
## open the redis sentinel ? \u662F\u5426\u5F00\u542F redis \u54E8\u5175\u96C6\u7FA4
openRedisSentinel=false
# redis \u5355\u5B9E\u4F8B
#redis.url=192.168.31.151:26379,192.168.31.154:26379,192.168.31.157:26379
redis.url=127.0.0.1
redis.port=6379
redis.password=archser_redis
# redisSentinel \u54E8\u5175\u96C6\u7FA4
redisSentinel.url=192.168.31.151:26379,192.168.31.154:26379,192.168.31.157:26379
redisSentinel.password=archser_redis
redisSentinel.CacheName=redisSentinel
redisSentinel.masterName=mymaster
#\u5355\u70B9\u767B\u9646\u5730\u5740
basic.url=http://39.104.21.218:11038
## \u662F\u5426\u540C\u6B65Redis\u4E2D\u7684\u6570\u636E
......@@ -64,7 +59,7 @@ updateRedis=true
MyIpAddress=127.0.0.1,0:0:0:0:0:0:0:1
#activemq
activemq.brokerURL=tcp://39.104.21.218:61616
activemq.brokerURL=failover://(tcp://192.168.31.151:61616,tcp://192.168.31.154:61616,tcp://192.168.31.157:61616)
authUrl=http://125.77.26.133:7001/auth/token
userInfoUrl=http://125.77.26.133:7001/api/info/user_info
......@@ -175,8 +170,9 @@ FserverName=fserver
#================sserver=================================
#Elasticsearch\u670D\u52A1\u5668\u8BBE\u7F6E
es.host=39.104.21.218
es.host=192.168.31.151:9200,192.168.31.154:9200,192.168.31.157:9200
es.port=9200
es.http=http
es.user=es
es.password=Admin@123456
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment