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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
7 deletions
+14
-7
EurekaClientConfiguration.java
...ework/cloud/netflix/eureka/EurekaClientConfiguration.java
+11
-5
ServoMetricsAutoConfiguration.java
...rk/cloud/netflix/servo/ServoMetricsAutoConfiguration.java
+3
-2
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;
...
@@ -21,6 +21,7 @@ import javax.management.MBeanServer;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
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.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
...
@@ -56,7 +57,8 @@ import com.netflix.discovery.EurekaClientConfig;
...
@@ -56,7 +57,8 @@ import com.netflix.discovery.EurekaClientConfig;
public
class
EurekaClientConfiguration
implements
public
class
EurekaClientConfiguration
implements
ApplicationListener
<
ContextRefreshedEvent
>,
SmartLifecycle
,
Ordered
{
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
boolean
running
;
...
@@ -70,7 +72,8 @@ public class EurekaClientConfiguration implements
...
@@ -70,7 +72,8 @@ public class EurekaClientConfiguration implements
@Override
@Override
public
void
onApplicationEvent
(
ContextRefreshedEvent
event
)
{
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
);
ApplicationInfoManager
.
getInstance
().
setInstanceStatus
(
InstanceStatus
.
UP
);
}
}
...
@@ -117,15 +120,18 @@ public class EurekaClientConfiguration implements
...
@@ -117,15 +120,18 @@ public class EurekaClientConfiguration implements
@Bean
@Bean
@Lazy
@Lazy
@Scope
(
proxyMode
=
ScopedProxyMode
.
TARGET_CLASS
)
@Scope
(
proxyMode
=
ScopedProxyMode
.
TARGET_CLASS
)
public
DiscoveryClient
discoveryClient
()
{
public
DiscoveryClient
discoveryClient
()
{
return
DiscoveryManager
.
getInstance
().
getDiscoveryClient
();
return
DiscoveryManager
.
getInstance
().
getDiscoveryClient
();
}
}
@Bean
@Bean
@ConditionalOnMissingBean
@ConditionalOnMissingBean
public
EurekaHealthIndicator
eurekaHealthIndicator
(
MBeanServer
server
,
EurekaInstanceConfig
config
)
{
@ConditionalOnBean
(
MBeanServer
.
class
)
return
new
EurekaHealthIndicator
(
discoveryClient
(),
new
ServoMetricReader
(
server
),
config
);
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;
...
@@ -35,14 +35,15 @@ import com.netflix.servo.monitor.Monitors;
*
*
*/
*/
@Configuration
@Configuration
@ConditionalOnClass
({
Monitors
.
class
,
MetricReader
.
class
})
@ConditionalOnClass
({
Monitors
.
class
,
MetricReader
.
class
})
@ConditionalOnBean
(
{
MBeanServer
.
class
,
MetricReader
.
class
}
)
@ConditionalOnBean
(
MetricReader
.
class
)
@AutoConfigureBefore
(
EndpointAutoConfiguration
.
class
)
@AutoConfigureBefore
(
EndpointAutoConfiguration
.
class
)
@AutoConfigureAfter
(
MetricRepositoryAutoConfiguration
.
class
)
@AutoConfigureAfter
(
MetricRepositoryAutoConfiguration
.
class
)
public
class
ServoMetricsAutoConfiguration
{
public
class
ServoMetricsAutoConfiguration
{
@Bean
@Bean
@ConditionalOnMissingBean
@ConditionalOnMissingBean
@ConditionalOnBean
(
MBeanServer
.
class
)
public
ServoPublicMetrics
servoPublicMetrics
(
MetricReader
reader
,
MBeanServer
server
)
{
public
ServoPublicMetrics
servoPublicMetrics
(
MetricReader
reader
,
MBeanServer
server
)
{
return
new
ServoPublicMetrics
(
reader
,
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