Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
aserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
15所TongWeb
aserver
Commits
9cb8ed9f
Commit
9cb8ed9f
authored
Mar 04, 2021
by
李德才
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
兼容单个Redis实例的配置信息
parent
a681395e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
19 deletions
+19
-19
RedisConfig.java
...om/archser/aserver/common/config/plugins/RedisConfig.java
+14
-10
AppConfig-pro.properties
src/main/resources/AppConfig-pro.properties
+5
-9
No files found.
src/main/java/com/archser/aserver/common/config/plugins/RedisConfig.java
View file @
9cb8ed9f
...
@@ -3,9 +3,11 @@ package com.archser.aserver.common.config.plugins;
...
@@ -3,9 +3,11 @@ package com.archser.aserver.common.config.plugins;
import
com.archser.aserver.plugin.redis.RedisSentinelPlugin
;
import
com.archser.aserver.plugin.redis.RedisSentinelPlugin
;
import
com.jfinal.config.Plugins
;
import
com.jfinal.config.Plugins
;
import
com.jfinal.kit.Prop
;
import
com.jfinal.kit.Prop
;
import
com.jfinal.kit.StrKit
;
import
com.jfinal.plugin.redis.RedisPlugin
;
import
com.jfinal.plugin.redis.RedisPlugin
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Set
;
import
java.util.Set
;
import
javax.persistence.criteria.CriteriaBuilder.In
;
import
redis.clients.jedis.HostAndPort
;
import
redis.clients.jedis.HostAndPort
;
/**
/**
...
@@ -19,29 +21,31 @@ public class RedisConfig {
...
@@ -19,29 +21,31 @@ public class RedisConfig {
public
RedisConfig
(
Plugins
plugins
,
Prop
prop
)
{
public
RedisConfig
(
Plugins
plugins
,
Prop
prop
)
{
boolean
openRedisSentinel
=
prop
.
getBoolean
(
"openRedisSentine
l"
);
String
redisUrl
=
prop
.
get
(
"redis.ur
l"
);
// 哨兵配置
// 哨兵配置
if
(
openRedisSentinel
)
{
if
(
redisUrl
.
contains
(
","
))
{
String
redisSentinel
=
prop
.
get
(
"redisSentinel.url"
);
Set
<
HostAndPort
>
sentinels
=
new
HashSet
<
HostAndPort
>();
Set
<
HostAndPort
>
sentinels
=
new
HashSet
<
HostAndPort
>();
String
[]
split
=
redisSentinel
.
split
(
","
);
String
[]
split
=
redisUrl
.
split
(
","
);
int
port
=
26379
;
for
(
String
item
:
split
)
{
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
(
RedisSentinelPlugin
redisSentinelPlugin
=
new
RedisSentinelPlugin
(
prop
.
get
(
"redisSentinel.CacheName"
,
"redisSentinel"
),
prop
.
get
(
"redisSentinel.CacheName"
,
"redisSentinel"
),
prop
.
get
(
"redisSentinel.masterName"
,
"mymaster"
),
prop
.
get
(
"redisSentinel.masterName"
,
"mymaster"
),
sentinels
,
prop
.
get
(
"redis
Sentinel
.password"
,
"archser_redis"
));
sentinels
,
prop
.
get
(
"redis.password"
,
"archser_redis"
));
plugins
.
add
(
redisSentinelPlugin
);
plugins
.
add
(
redisSentinelPlugin
);
}
}
else
{
// 普通Redis单实例配置
// 普通Redis单实例配置
if
(!
openRedisSentinel
)
{
RedisPlugin
redis
=
new
RedisPlugin
(
"redis"
,
prop
.
get
(
"redis.url"
),
RedisPlugin
redis
=
new
RedisPlugin
(
"redis"
,
prop
.
get
(
"redis.url"
),
prop
.
getInt
(
"redis.port"
,
6379
),
prop
.
getInt
(
"redis.port"
,
6379
),
prop
.
get
(
"redis.password"
));
prop
.
get
(
"redis.password"
));
plugins
.
add
(
redis
);
plugins
.
add
(
redis
);
}
}
}
}
}
}
src/main/resources/AppConfig-pro.properties
View file @
9cb8ed9f
...
@@ -42,19 +42,14 @@ MiddlewareType=dev
...
@@ -42,19 +42,14 @@ MiddlewareType=dev
### don't open redis and redisSentinel At the same time
### 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
### \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 \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.url
=
127.0.0.1
redis.port
=
6379
redis.port
=
6379
redis.password
=
archser_redis
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.CacheName
=
redisSentinel
redisSentinel.masterName
=
mymaster
redisSentinel.masterName
=
mymaster
#\u5355\u70B9\u767B\u9646\u5730\u5740
#\u5355\u70B9\u767B\u9646\u5730\u5740
basic.url
=
http://39.104.21.218:11038
basic.url
=
http://39.104.21.218:11038
## \u662F\u5426\u540C\u6B65Redis\u4E2D\u7684\u6570\u636E
## \u662F\u5426\u540C\u6B65Redis\u4E2D\u7684\u6570\u636E
...
@@ -64,7 +59,7 @@ updateRedis=true
...
@@ -64,7 +59,7 @@ updateRedis=true
MyIpAddress
=
127.0.0.1,0:0:0:0:0:0:0:1
MyIpAddress
=
127.0.0.1,0:0:0:0:0:0:0:1
#activemq
#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
authUrl
=
http://125.77.26.133:7001/auth/token
userInfoUrl
=
http://125.77.26.133:7001/api/info/user_info
userInfoUrl
=
http://125.77.26.133:7001/api/info/user_info
...
@@ -175,8 +170,9 @@ FserverName=fserver
...
@@ -175,8 +170,9 @@ FserverName=fserver
#================sserver=================================
#================sserver=================================
#Elasticsearch\u670D\u52A1\u5668\u8BBE\u7F6E
#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.port
=
9200
es.http
=
http
es.user
=
es
es.user
=
es
es.password
=
Admin@123456
es.password
=
Admin@123456
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment