Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-boot-admin
Project
Overview
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
openSource
spring-boot-admin
Commits
b034099c
Commit
b034099c
authored
Jul 24, 2018
by
赵天增
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
啦啦啦
parent
c2ccd6dd
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
106 additions
and
13 deletions
+106
-13
application.yml
monitor-core/src/main/resources/application.yml
+29
-0
AdminServerAutoConfiguration.java
...oot/admin/server/config/AdminServerAutoConfiguration.java
+5
-0
ServicesList.java
...de/codecentric/boot/admin/server/notify/ServicesList.java
+22
-0
ApplicationsController.java
...centric/boot/admin/server/web/ApplicationsController.java
+50
-13
No files found.
monitor-core/src/main/resources/application.yml
View file @
b034099c
...
...
@@ -15,3 +15,32 @@ management:
endpoint
:
health
:
show-details
:
ALWAYS
# 微服务列表,如果服务不存在会触发邮件提醒
spring
:
boot
:
admin
:
notify
:
mail
:
enabled
:
true
to
:
tianzeng.zhao@medtap.cn
from
:
tianzeng.zhao@medtap.cn
services
:
YJY-APPLICATION-USER,
YJY-APPLICATION-COMMON,
YJY-APPLICATION-WECHAT,
YJY-APPLICATION-PAYMENT,
YJY-APPLICATION-SERVICE,
YJY-APPLICATION-THIRD,
YJY-APPLICATION-DOCTOR,
YJY-APPLICATION-OPERATION,
YJY-APPLICATION-TRADE,
YJY-APPLICATION-SHOP,
YJY-APPLICATION-CRM,
OPERATION-API,
USER-API,
PROMOTION-API,
RESOURCE-API,
ITEM-API,
BABABABBABA
spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/config/AdminServerAutoConfiguration.java
View file @
b034099c
...
...
@@ -21,6 +21,7 @@ import de.codecentric.boot.admin.server.domain.entities.SnapshottingInstanceRepo
import
de.codecentric.boot.admin.server.domain.events.InstanceEvent
;
import
de.codecentric.boot.admin.server.eventstore.InMemoryEventStore
;
import
de.codecentric.boot.admin.server.eventstore.InstanceEventStore
;
import
de.codecentric.boot.admin.server.notify.ServicesList
;
import
de.codecentric.boot.admin.server.services.EndpointDetectionTrigger
;
import
de.codecentric.boot.admin.server.services.EndpointDetector
;
import
de.codecentric.boot.admin.server.services.HashingInstanceUrlIdGenerator
;
...
...
@@ -74,6 +75,10 @@ public class AdminServerAutoConfiguration {
}
@Bean
public
ServicesList
servicesList
(){
return
new
ServicesList
();
}
@Bean
@ConditionalOnMissingBean
public
InstanceIdGenerator
instanceIdGenerator
()
{
return
new
HashingInstanceUrlIdGenerator
();
...
...
spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/notify/ServicesList.java
0 → 100644
View file @
b034099c
package
de
.
codecentric
.
boot
.
admin
.
server
.
notify
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.env.Environment
;
import
org.springframework.stereotype.Component
;
import
javax.validation.constraints.Max
;
import
java.util.List
;
@Component
public
class
ServicesList
{
@Autowired
private
Environment
env
;
public
List
<
String
>
getServices
()
{
return
env
.
getProperty
(
"spring.boot.admin.services"
,
List
.
class
);
}
}
spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/web/ApplicationsController.java
View file @
b034099c
...
...
@@ -20,20 +20,11 @@ import de.codecentric.boot.admin.server.domain.entities.Instance;
import
de.codecentric.boot.admin.server.domain.values.BuildVersion
;
import
de.codecentric.boot.admin.server.domain.values.StatusInfo
;
import
de.codecentric.boot.admin.server.eventstore.InstanceEventPublisher
;
import
de.codecentric.boot.admin.server.notify.ServicesList
;
import
de.codecentric.boot.admin.server.services.InstanceRegistry
;
import
reactor.core.publisher.Flux
;
import
reactor.core.publisher.Mono
;
import
reactor.util.function.Tuple2
;
import
reactor.util.function.Tuples
;
import
java.time.Duration
;
import
java.time.Instant
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.codec.ServerSentEvent
;
...
...
@@ -41,6 +32,14 @@ import org.springframework.web.bind.annotation.DeleteMapping;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
reactor.core.publisher.Flux
;
import
reactor.core.publisher.Mono
;
import
reactor.util.function.Tuple2
;
import
reactor.util.function.Tuples
;
import
java.time.Duration
;
import
java.time.Instant
;
import
java.util.*
;
import
static
java
.
util
.
Comparator
.
naturalOrder
;
import
static
java
.
util
.
stream
.
Collectors
.
toList
;
...
...
@@ -64,6 +63,10 @@ public class ApplicationsController {
this
.
eventPublisher
=
eventPublisher
;
}
@Autowired
private
ServicesList
servicesList
;
@GetMapping
(
path
=
"/applications"
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
Flux
<
Application
>
applications
()
{
Flux
<
Application
>
applicationFlux
=
registry
.
getInstances
()
...
...
@@ -71,9 +74,44 @@ public class ApplicationsController {
.
groupBy
(
instance
->
instance
.
getRegistration
().
getName
())
.
flatMap
(
grouped
->
toApplication
(
grouped
.
key
(),
grouped
));
List
<
String
>
appNames
=
new
ArrayList
<>();
applicationFlux
.
subscribe
(
application
->
appNames
.
add
(
application
.
getName
()));
for
(
String
appName
:
minus
(
servicesList
.
getServices
(),
appNames
))
{
Application
group
=
new
Application
(
appName
.
toUpperCase
());
group
.
setStatus
(
"OFFINE"
);
group
.
setInstances
(
Collections
.
EMPTY_LIST
);
applicationFlux
=
applicationFlux
.
concatWithValues
(
group
);
}
return
applicationFlux
;
}
/**
* 求两数组的差集
*
* @param arr1 模板数组
* @param arr2 比较数组
* @return
*/
public
static
String
[]
minus
(
List
<
String
>
arr1
,
List
<
String
>
arr2
)
{
LinkedList
<
String
>
list
=
new
LinkedList
<>();
LinkedList
<
String
>
history
=
new
LinkedList
<>();
for
(
String
str
:
arr1
)
{
if
(!
list
.
contains
(
str
.
toUpperCase
()))
{
list
.
add
(
str
.
toUpperCase
());
}
}
for
(
String
str
:
arr2
)
{
list
.
remove
(
str
.
toUpperCase
());
}
String
[]
result
=
{};
return
list
.
toArray
(
result
);
}
@GetMapping
(
path
=
"/applications"
,
produces
=
MediaType
.
TEXT_EVENT_STREAM_VALUE
)
public
Flux
<
ServerSentEvent
<
Application
>>
applicationsStream
()
{
return
Flux
.
from
(
eventPublisher
)
...
...
@@ -107,8 +145,7 @@ public class ApplicationsController {
group
.
setInstances
(
instanceList
);
group
.
setBuildVersion
(
getBuildVersion
(
instanceList
));
Tuple2
<
String
,
Instant
>
status
=
getStatus
(
instanceList
);
// group.setStatus(status.getT1());
group
.
setStatus
(
"UP"
);
group
.
setStatus
(
status
.
getT1
());
group
.
setStatusTimestamp
(
status
.
getT2
());
return
group
;
});
...
...
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