Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
holmes
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
QA
holmes
Commits
ef6fc310
Commit
ef6fc310
authored
Sep 18, 2021
by
黎博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增mq对比接口
parent
68a79e99
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
1 deletion
+78
-1
K8sController.java
src/main/java/cn/qg/holmes/controller/k8s/K8sController.java
+10
-0
MqService.java
src/main/java/cn/qg/holmes/service/k8s/MqService.java
+68
-1
No files found.
src/main/java/cn/qg/holmes/controller/k8s/K8sController.java
View file @
ef6fc310
...
@@ -412,6 +412,16 @@ public class K8sController {
...
@@ -412,6 +412,16 @@ public class K8sController {
return
JsonResult
.
buildSuccessResult
(
mqService
.
setDefinitions
(
host
));
return
JsonResult
.
buildSuccessResult
(
mqService
.
setDefinitions
(
host
));
}
}
/**
* 比较线上和测试mq
* @param host
* @return
*/
@GetMapping
(
"/mq/diff"
)
public
JsonResult
getMqDiffResult
(
@RequestParam
String
host
)
{
return
JsonResult
.
buildSuccessResult
(
mqService
.
getMqDiff
(
host
));
}
/**
/**
* 情况测试环境redis
* 情况测试环境redis
* @param namespace 环境
* @param namespace 环境
...
...
src/main/java/cn/qg/holmes/service/k8s/MqService.java
View file @
ef6fc310
...
@@ -16,6 +16,7 @@ public class MqService {
...
@@ -16,6 +16,7 @@ public class MqService {
/**
/**
* 获取MQ信息
* 获取MQ信息
*
* @param host
* @param host
* @param auth
* @param auth
* @return
* @return
...
@@ -29,6 +30,7 @@ public class MqService {
...
@@ -29,6 +30,7 @@ public class MqService {
/**
/**
* 同步线上MQ到测试
* 同步线上MQ到测试
*
* @param host
* @param host
* @return
* @return
*/
*/
...
@@ -39,7 +41,7 @@ public class MqService {
...
@@ -39,7 +41,7 @@ public class MqService {
Map
<
String
,
Object
>
onlineDefinitions
=
getDefinitionsOfHost
(
ONLINE_MQ_URL
,
ONLINE_MQ_AUTH
);
Map
<
String
,
Object
>
onlineDefinitions
=
getDefinitionsOfHost
(
ONLINE_MQ_URL
,
ONLINE_MQ_AUTH
);
List
<
Map
<
String
,
String
>>
permissionList
=
(
List
<
Map
<
String
,
String
>>)
onlineDefinitions
.
get
(
"permissions"
);
List
<
Map
<
String
,
String
>>
permissionList
=
(
List
<
Map
<
String
,
String
>>)
onlineDefinitions
.
get
(
"permissions"
);
List
<
Map
<
String
,
String
>>
qaPermissionList
=
new
ArrayList
<>();
List
<
Map
<
String
,
String
>>
qaPermissionList
=
new
ArrayList
<>();
for
(
Map
<
String
,
String
>
permission:
permissionList
)
{
for
(
Map
<
String
,
String
>
permission
:
permissionList
)
{
if
(
permission
.
get
(
"user"
).
equals
(
"rabbit_admin"
))
{
if
(
permission
.
get
(
"user"
).
equals
(
"rabbit_admin"
))
{
qaPermissionList
.
add
(
permission
);
qaPermissionList
.
add
(
permission
);
permission
.
put
(
"user"
,
"qa"
);
permission
.
put
(
"user"
,
"qa"
);
...
@@ -65,6 +67,71 @@ public class MqService {
...
@@ -65,6 +67,71 @@ public class MqService {
}
}
}
}
/**
* 获取 sourceMapList 比 targetMapList 多出的元素
*
* @param sourceMapList
* @param targetMapList
* @return
*/
public
List
<
String
>
mqListCompare
(
List
<
Map
<
String
,
String
>>
sourceMapList
,
List
<
Map
<
String
,
String
>>
targetMapList
)
{
List
<
String
>
resultList
=
new
ArrayList
<>();
for
(
Map
<
String
,
String
>
sourceMap
:
sourceMapList
)
{
boolean
flag
=
false
;
for
(
Map
<
String
,
String
>
targetMap
:
targetMapList
)
{
if
(
sourceMap
.
get
(
"name"
).
equals
(
targetMap
.
get
(
"name"
)))
{
flag
=
true
;
}
}
if
(!
flag
)
{
resultList
.
add
(
sourceMap
.
get
(
"name"
));
}
}
return
resultList
;
}
/**
* 比较测试环境与线上mq
* @param host 测试环境mq地址:ip+端口
* @return
*/
public
Map
<
String
,
Object
>
getMqDiff
(
String
host
)
{
String
ONLINE_MQ_URL
=
"http://172.30.3.140:15672"
;
String
ONLINE_MQ_AUTH
=
"Basic cmFiYml0X2FkbWluOmFiYzEyMzQ="
;
Map
<
String
,
Object
>
onlineDefinitions
=
getDefinitionsOfHost
(
ONLINE_MQ_URL
,
ONLINE_MQ_AUTH
);
String
qaMqUrl
=
"http://"
+
host
;
String
QA_MQ_AUTH
=
"Basic cWE6cWF0ZXN0"
;
Map
<
String
,
Object
>
qaDefinitions
=
getDefinitionsOfHost
(
qaMqUrl
,
QA_MQ_AUTH
);
List
<
Map
<
String
,
String
>>
onlineHostList
=
(
List
<
Map
<
String
,
String
>>)
onlineDefinitions
.
get
(
"vhosts"
);
List
<
Map
<
String
,
String
>>
qaHostList
=
(
List
<
Map
<
String
,
String
>>)
qaDefinitions
.
get
(
"vhosts"
);
List
<
Map
<
String
,
String
>>
onlineQueueList
=
(
List
<
Map
<
String
,
String
>>)
onlineDefinitions
.
get
(
"queues"
);
List
<
Map
<
String
,
String
>>
qaQueueList
=
(
List
<
Map
<
String
,
String
>>)
qaDefinitions
.
get
(
"queues"
);
List
<
String
>
lostVhostList
=
mqListCompare
(
onlineHostList
,
qaHostList
);
List
<
String
>
moreVhostList
=
mqListCompare
(
qaHostList
,
onlineHostList
);
List
<
String
>
lostQueueList
=
mqListCompare
(
onlineQueueList
,
qaQueueList
);
List
<
String
>
moreQueueList
=
mqListCompare
(
qaQueueList
,
onlineQueueList
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
lostMap
=
new
HashMap
<>();
lostMap
.
put
(
"vhost"
,
lostVhostList
);
lostMap
.
put
(
"queue"
,
lostQueueList
);
Map
<
String
,
Object
>
moreMap
=
new
HashMap
<>();
moreMap
.
put
(
"vhost"
,
moreVhostList
);
moreMap
.
put
(
"queue"
,
moreQueueList
);
if
(
lostVhostList
.
size
()
>
0
||
lostQueueList
.
size
()
>
0
)
{
lostMap
.
put
(
"show"
,
true
);
}
else
{
lostMap
.
put
(
"show"
,
false
);
}
if
(
moreVhostList
.
size
()
>
0
||
moreQueueList
.
size
()
>
0
)
{
moreMap
.
put
(
"show"
,
true
);
}
else
{
moreMap
.
put
(
"show"
,
false
);
}
map
.
put
(
"lost"
,
lostMap
);
map
.
put
(
"more"
,
moreMap
);
return
map
;
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
MqService
mqService
=
new
MqService
();
MqService
mqService
=
new
MqService
();
mqService
.
setDefinitions
(
"172.17.5.17:31426"
);
mqService
.
setDefinitions
(
"172.17.5.17:31426"
);
...
...
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