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
c37279e5
Commit
c37279e5
authored
Jun 08, 2016
by
Johannes Edmeier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add option to ignore services from discovery
fixes #205
parent
e1eeb038
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
2 deletions
+33
-2
index.adoc
spring-boot-admin-docs/src/main/asciidoc/index.adoc
+4
-0
DiscoveryClientConfiguration.java
...ntric/boot/admin/config/DiscoveryClientConfiguration.java
+1
-0
ApplicationDiscoveryListener.java
...ic/boot/admin/discovery/ApplicationDiscoveryListener.java
+16
-2
ApplicationDiscoveryListenerTest.java
...oot/admin/discovery/ApplicationDiscoveryListenerTest.java
+12
-0
No files found.
spring-boot-admin-docs/src/main/asciidoc/index.adoc
View file @
c37279e5
...
...
@@ -293,6 +293,10 @@ TIP: When the default conversion kicks in, you can use the `spring.boot.admin.di
| spring.boot.admin.discovery.converter.health-endpoint
| Will be appended to the management-url of the discovered service when the health-url is converted by the `DefaultServiceInstanceConverter`.
| `"health"`
| spring.boot.admin.discovery.ignored-services
| This services will be ignored when using discovery and not registered as application.
|
|===
[[hazelcast-support]]
...
...
spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/config/DiscoveryClientConfiguration.java
View file @
c37279e5
...
...
@@ -49,6 +49,7 @@ public class DiscoveryClientConfiguration {
@Bean
@ConditionalOnMissingBean
@ConfigurationProperties
(
prefix
=
"spring.boot.admin.discovery"
)
public
ApplicationDiscoveryListener
applicationDiscoveryListener
(
ServiceInstanceConverter
serviceInstanceConverter
)
{
ApplicationDiscoveryListener
listener
=
new
ApplicationDiscoveryListener
(
discoveryClient
,
...
...
spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/discovery/ApplicationDiscoveryListener.java
View file @
c37279e5
...
...
@@ -15,6 +15,9 @@
*/
package
de
.
codecentric
.
boot
.
admin
.
discovery
;
import
java.util.HashSet
;
import
java.util.Set
;
import
org.springframework.cloud.client.ServiceInstance
;
import
org.springframework.cloud.client.discovery.DiscoveryClient
;
import
org.springframework.cloud.client.discovery.event.HeartbeatEvent
;
...
...
@@ -32,12 +35,16 @@ import de.codecentric.boot.admin.registry.ApplicationRegistry;
* @author Johannes Edmeier
*/
public
class
ApplicationDiscoveryListener
{
private
final
DiscoveryClient
discoveryClient
;
private
final
ApplicationRegistry
registry
;
private
final
HeartbeatMonitor
monitor
=
new
HeartbeatMonitor
();
private
ServiceInstanceConverter
converter
=
new
DefaultServiceInstanceConverter
();
/**
* Set of serviceIds to be ignored and not to be registered as application.
*/
private
Set
<
String
>
ignoredServices
=
new
HashSet
<>();
public
ApplicationDiscoveryListener
(
DiscoveryClient
discoveryClient
,
ApplicationRegistry
registry
)
{
this
.
discoveryClient
=
discoveryClient
;
...
...
@@ -68,7 +75,9 @@ public class ApplicationDiscoveryListener {
protected
void
discover
()
{
for
(
String
serviceId
:
discoveryClient
.
getServices
())
{
for
(
ServiceInstance
instance
:
discoveryClient
.
getInstances
(
serviceId
))
{
registry
.
register
(
convert
(
instance
));
if
(!
ignoredServices
.
contains
(
serviceId
))
{
registry
.
register
(
convert
(
instance
));
}
}
}
}
...
...
@@ -80,4 +89,8 @@ public class ApplicationDiscoveryListener {
public
void
setConverter
(
ServiceInstanceConverter
converter
)
{
this
.
converter
=
converter
;
}
public
void
setIgnoredServices
(
Set
<
String
>
ignoredServices
)
{
this
.
ignoredServices
=
ignoredServices
;
}
}
\ No newline at end of file
spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/discovery/ApplicationDiscoveryListenerTest.java
View file @
c37279e5
...
...
@@ -51,6 +51,18 @@ public class ApplicationDiscoveryListenerTest {
}
@Test
public
void
test_ignore
()
{
when
(
discovery
.
getServices
()).
thenReturn
(
Collections
.
singletonList
(
"service"
));
when
(
discovery
.
getInstances
(
"service"
)).
thenReturn
(
Collections
.
singletonList
(
(
ServiceInstance
)
new
DefaultServiceInstance
(
"service"
,
"localhost"
,
80
,
false
)));
listener
.
setIgnoredServices
(
Collections
.
singleton
(
"service"
));
listener
.
onInstanceRegistered
(
new
InstanceRegisteredEvent
<>(
new
Object
(),
null
));
assertEquals
(
0
,
registry
.
getApplications
().
size
());
}
@Test
public
void
test_register_and_convert
()
{
when
(
discovery
.
getServices
()).
thenReturn
(
Collections
.
singletonList
(
"service"
));
when
(
discovery
.
getInstances
(
"service"
)).
thenReturn
(
Collections
.
singletonList
(
...
...
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