Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pms-dispatch-assistant
Project
Project
Details
Activity
Releases
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
姜耀祖
pms-dispatch-assistant
Commits
11f6222f
Commit
11f6222f
authored
Apr 21, 2025
by
赵灿灿
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改配置
parent
21dd3e19
Pipeline
#21051
passed with stages
in 3 minutes and 6 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
144 additions
and
7 deletions
+144
-7
RedisClusterConfiguration.java
...work/data/redis/connection/RedisClusterConfiguration.java
+137
-0
application-prod.yml
src/main/resources/application-prod.yml
+7
-7
No files found.
src/main/java/org/springframework/data/redis/connection/RedisClusterConfiguration.java
0 → 100644
View file @
11f6222f
package
org
.
springframework
.
data
.
redis
.
connection
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.core.env.MapPropertySource
;
import
org.springframework.core.env.PropertySource
;
import
org.springframework.lang.Nullable
;
import
org.springframework.util.Assert
;
import
org.springframework.util.NumberUtils
;
import
org.springframework.util.StringUtils
;
import
java.util.*
;
/**
* @Auther:wanggs
* @Date 2023/09/14 9:25
* @Description:
*/
public
class
RedisClusterConfiguration
implements
RedisConfiguration
,
RedisConfiguration
.
ClusterConfiguration
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
RedisClusterConfiguration
.
class
);
private
static
final
String
REDIS_CLUSTER_NODES_CONFIG_PROPERTY
=
"spring.redis.cluster.nodes"
;
private
static
final
String
REDIS_CLUSTER_MAX_REDIRECTS_CONFIG_PROPERTY
=
"spring.redis.cluster.max-redirects"
;
private
Set
<
RedisNode
>
clusterNodes
;
@Nullable
private
Integer
maxRedirects
;
private
RedisPassword
password
;
public
RedisClusterConfiguration
()
{
this
((
PropertySource
)(
new
MapPropertySource
(
"RedisClusterConfiguration"
,
Collections
.
emptyMap
())));
}
public
RedisClusterConfiguration
(
Collection
<
String
>
clusterNodes
)
{
this
((
PropertySource
)(
new
MapPropertySource
(
"RedisClusterConfiguration"
,
asMap
(
clusterNodes
,
-
1
))));
}
public
RedisClusterConfiguration
(
PropertySource
<?>
propertySource
)
{
this
.
password
=
RedisPassword
.
none
();
Assert
.
notNull
(
propertySource
,
"PropertySource must not be null!"
);
this
.
clusterNodes
=
new
LinkedHashSet
();
if
(
propertySource
.
containsProperty
(
"spring.redis.cluster.nodes"
))
{
this
.
appendClusterNodes
(
StringUtils
.
commaDelimitedListToSet
(
propertySource
.
getProperty
(
"spring.redis.cluster.nodes"
).
toString
()));
}
if
(
propertySource
.
containsProperty
(
"spring.redis.cluster.max-redirects"
))
{
this
.
maxRedirects
=
(
Integer
)
NumberUtils
.
parseNumber
(
propertySource
.
getProperty
(
"spring.redis.cluster.max-redirects"
).
toString
(),
Integer
.
class
);
}
}
public
void
setClusterNodes
(
Iterable
<
RedisNode
>
nodes
)
{
Assert
.
notNull
(
nodes
,
"Cannot set cluster nodes to 'null'."
);
this
.
clusterNodes
.
clear
();
Iterator
var2
=
nodes
.
iterator
();
while
(
var2
.
hasNext
())
{
RedisNode
clusterNode
=
(
RedisNode
)
var2
.
next
();
this
.
addClusterNode
(
clusterNode
);
}
}
public
Set
<
RedisNode
>
getClusterNodes
()
{
return
Collections
.
unmodifiableSet
(
this
.
clusterNodes
);
}
public
void
addClusterNode
(
RedisNode
node
)
{
Assert
.
notNull
(
node
,
"ClusterNode must not be 'null'."
);
this
.
clusterNodes
.
add
(
node
);
}
public
RedisClusterConfiguration
clusterNode
(
RedisNode
node
)
{
this
.
clusterNodes
.
add
(
node
);
return
this
;
}
public
Integer
getMaxRedirects
()
{
return
this
.
maxRedirects
!=
null
&&
this
.
maxRedirects
>
-
2147483648
?
this
.
maxRedirects
:
null
;
}
public
void
setMaxRedirects
(
int
maxRedirects
)
{
Assert
.
isTrue
(
maxRedirects
>=
0
,
"MaxRedirects must be greater or equal to 0"
);
this
.
maxRedirects
=
maxRedirects
;
}
public
RedisClusterConfiguration
clusterNode
(
String
host
,
Integer
port
)
{
return
this
.
clusterNode
(
new
RedisNode
(
host
,
port
));
}
private
void
appendClusterNodes
(
Set
<
String
>
hostAndPorts
)
{
Iterator
var2
=
hostAndPorts
.
iterator
();
while
(
var2
.
hasNext
())
{
String
hostAndPort
=
(
String
)
var2
.
next
();
this
.
addClusterNode
(
this
.
readHostAndPortFromString
(
hostAndPort
));
}
}
public
RedisPassword
getPassword
()
{
return
this
.
password
;
}
public
void
setPassword
(
RedisPassword
password
)
{
Assert
.
notNull
(
password
,
"RedisPassword must not be null!"
);
this
.
password
=
password
;
}
private
RedisNode
readHostAndPortFromString
(
String
hostAndPort
)
{
if
(
hostAndPort
.
contains
(
"@"
)){
String
[]
args
=
StringUtils
.
split
(
hostAndPort
,
"@"
);
logger
.
info
(
"redis host:"
+
args
[
0
]);
logger
.
info
(
"redis port:"
+
args
[
1
]);
Assert
.
notNull
(
args
,
"HostAndPort need to be seperated by '@'."
);
Assert
.
isTrue
(
args
.
length
==
2
,
"Host and Port String needs to specified as host@port"
);
return
new
RedisNode
(
args
[
0
],
Integer
.
valueOf
(
args
[
1
]));
}
else
{
String
[]
args
=
StringUtils
.
split
(
hostAndPort
,
":"
);
logger
.
info
(
"redis host:"
+
args
[
0
]);
logger
.
info
(
"redis port:"
+
args
[
1
]);
Assert
.
notNull
(
args
,
"HostAndPort need to be seperated by ':'."
);
Assert
.
isTrue
(
args
.
length
==
2
,
"Host and Port String needs to specified as host:port"
);
return
new
RedisNode
(
args
[
0
],
Integer
.
valueOf
(
args
[
1
]));
}
}
private
static
Map
<
String
,
Object
>
asMap
(
Collection
<
String
>
clusterHostAndPorts
,
int
redirects
)
{
Assert
.
notNull
(
clusterHostAndPorts
,
"ClusterHostAndPorts must not be null!"
);
Map
<
String
,
Object
>
map
=
new
HashMap
();
map
.
put
(
"spring.redis.cluster.nodes"
,
StringUtils
.
collectionToCommaDelimitedString
(
clusterHostAndPorts
));
if
(
redirects
>=
0
)
{
map
.
put
(
"spring.redis.cluster.max-redirects"
,
redirects
);
}
return
map
;
}
}
src/main/resources/application-prod.yml
View file @
11f6222f
...
@@ -10,12 +10,12 @@ spring:
...
@@ -10,12 +10,12 @@ spring:
password
:
Epoinfo0004#3
password
:
Epoinfo0004#3
cluster
:
cluster
:
nodes
:
nodes
:
-
"
[2409:8020:5c05:200::307:3191]:39025"
-
2409:8020:5c05:200::307:3191@39025
-
"
[2409:8020:5c05:200::307:3192]:39025"
-
2409:8020:5c05:200::307:3192@39025
-
"
[2409:8020:5c05:200::307:3193]:39025"
-
2409:8020:5c05:200::307:3193@39025
-
"
[2409:8020:5c05:200::307:3191]:33245"
-
2409:8020:5c05:200::307:3191@33245
-
"
[2409:8020:5c05:200::307:3192]:33245"
-
2409:8020:5c05:200::307:3192@33245
-
"
[2409:8020:5c05:200::307:3193]:33245"
-
2409:8020:5c05:200::307:3193@33245
# - 10.32.49.145:39025
# - 10.32.49.145:39025
# - 10.32.49.146:39025
# - 10.32.49.146:39025
# - 10.32.49.147:39025
# - 10.32.49.147:39025
...
@@ -74,4 +74,4 @@ spring:
...
@@ -74,4 +74,4 @@ spring:
api
:
api
:
url-map
:
url-map
:
# processEnginePrefix: http://10.32.40.24:30308/process-engine/
# processEnginePrefix: http://10.32.40.24:30308/process-engine/
processEnginePrefix
:
http://glxx.js.cmcc:30308/process-engine-
dispatchassistant
/
processEnginePrefix
:
http://glxx.js.cmcc:30308/process-engine-
software
/
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