Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-cloud-netflix
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-cloud-netflix
Commits
f41edfd4
Commit
f41edfd4
authored
Sep 24, 2014
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add conditional config guard for MBeanServer
parent
b9350276
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
15 deletions
+22
-15
EurekaClientConfiguration.java
...ework/cloud/netflix/eureka/EurekaClientConfiguration.java
+18
-12
ServoMetricsAutoConfiguration.java
...rk/cloud/netflix/servo/ServoMetricsAutoConfiguration.java
+4
-3
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/eureka/EurekaClientConfiguration.java
View file @
f41edfd4
...
...
@@ -21,6 +21,7 @@ import javax.management.MBeanServer;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
...
...
@@ -56,10 +57,11 @@ import com.netflix.discovery.EurekaClientConfig;
public
class
EurekaClientConfiguration
implements
ApplicationListener
<
ContextRefreshedEvent
>,
SmartLifecycle
,
Ordered
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
EurekaClientConfiguration
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
EurekaClientConfiguration
.
class
);
private
boolean
running
;
private
int
order
=
0
;
@Autowired
...
...
@@ -70,16 +72,17 @@ public class EurekaClientConfiguration implements
@Override
public
void
onApplicationEvent
(
ContextRefreshedEvent
event
)
{
logger
.
info
(
"Registering application {} with eureka with status UP"
,
instanceConfig
.
getAppname
());
logger
.
info
(
"Registering application {} with eureka with status UP"
,
instanceConfig
.
getAppname
());
ApplicationInfoManager
.
getInstance
().
setInstanceStatus
(
InstanceStatus
.
UP
);
}
@PreDestroy
public
void
close
()
{
logger
.
info
(
"Removing application {} from eureka"
,
instanceConfig
.
getAppname
());
logger
.
info
(
"Removing application {} from eureka"
,
instanceConfig
.
getAppname
());
DiscoveryManager
.
getInstance
().
shutdownComponent
();
}
@Override
public
void
start
()
{
DiscoveryManager
.
getInstance
().
initComponent
(
instanceConfig
,
clientConfig
);
...
...
@@ -109,23 +112,26 @@ public class EurekaClientConfiguration implements
public
void
stop
(
Runnable
callback
)
{
callback
.
run
();
}
@Override
public
int
getOrder
()
{
return
order
;
}
@Bean
@Lazy
@Scope
(
proxyMode
=
ScopedProxyMode
.
TARGET_CLASS
)
@Scope
(
proxyMode
=
ScopedProxyMode
.
TARGET_CLASS
)
public
DiscoveryClient
discoveryClient
()
{
return
DiscoveryManager
.
getInstance
().
getDiscoveryClient
();
}
@Bean
@ConditionalOnMissingBean
public
EurekaHealthIndicator
eurekaHealthIndicator
(
MBeanServer
server
,
EurekaInstanceConfig
config
)
{
return
new
EurekaHealthIndicator
(
discoveryClient
(),
new
ServoMetricReader
(
server
),
config
);
@ConditionalOnBean
(
MBeanServer
.
class
)
public
EurekaHealthIndicator
eurekaHealthIndicator
(
MBeanServer
server
,
EurekaInstanceConfig
config
)
{
return
new
EurekaHealthIndicator
(
discoveryClient
(),
new
ServoMetricReader
(
server
),
config
);
}
}
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/servo/ServoMetricsAutoConfiguration.java
View file @
f41edfd4
...
...
@@ -35,14 +35,15 @@ import com.netflix.servo.monitor.Monitors;
*
*/
@Configuration
@ConditionalOnClass
({
Monitors
.
class
,
MetricReader
.
class
})
@ConditionalOnBean
(
{
MBeanServer
.
class
,
MetricReader
.
class
}
)
@ConditionalOnClass
({
Monitors
.
class
,
MetricReader
.
class
})
@ConditionalOnBean
(
MetricReader
.
class
)
@AutoConfigureBefore
(
EndpointAutoConfiguration
.
class
)
@AutoConfigureAfter
(
MetricRepositoryAutoConfiguration
.
class
)
public
class
ServoMetricsAutoConfiguration
{
@Bean
@ConditionalOnMissingBean
@ConditionalOnBean
(
MBeanServer
.
class
)
public
ServoPublicMetrics
servoPublicMetrics
(
MetricReader
reader
,
MBeanServer
server
)
{
return
new
ServoPublicMetrics
(
reader
,
server
);
}
...
...
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