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
5ef304a4
Commit
5ef304a4
authored
Nov 05, 2014
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure /hystrix.stream has the correct path
Fixes gh-52
parent
af1278a4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
82 additions
and
7 deletions
+82
-7
HystrixConfiguration.java
...framework/cloud/netflix/hystrix/HystrixConfiguration.java
+15
-6
HystrixStreamEndpoint.java
...ramework/cloud/netflix/hystrix/HystrixStreamEndpoint.java
+1
-1
HystrixConfigurationTests.java
...work/cloud/netflix/hystrix/HystrixConfigurationTests.java
+32
-0
HystrixStreamEndpointTests.java
...ork/cloud/netflix/hystrix/HystrixStreamEndpointTests.java
+34
-0
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/hystrix/HystrixConfiguration.java
View file @
5ef304a4
...
...
@@ -30,6 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.boot.actuate.metrics.GaugeService
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication
;
import
org.springframework.context.SmartLifecycle
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -64,13 +65,18 @@ public class HystrixConfiguration implements ImportAware {
return
new
HystrixShutdownHook
();
}
@
Bea
n
@
Configuratio
n
@ConditionalOnExpression
(
"${hystrix.stream.endpoint.enabled:true}"
)
// TODO: make it @ConditionalOnWebApp (need a nested class)
@ConditionalOnWebApplication
protected
static
class
HystrixWebConfiguration
{
@Bean
public
HystrixStreamEndpoint
hystrixStreamEndpoint
()
{
return
new
HystrixStreamEndpoint
();
}
}
@Override
public
void
setImportMetadata
(
AnnotationMetadata
importMetadata
)
{
this
.
enableHystrix
=
AnnotationAttributes
.
fromMap
(
importMetadata
...
...
@@ -88,7 +94,7 @@ public class HystrixConfiguration implements ImportAware {
private
static
Log
logger
=
LogFactory
.
getLog
(
HystrixMetricsPollerConfiguration
.
class
);
@Autowired
@Autowired
(
required
=
false
)
private
GaugeService
gauges
;
private
ObjectMapper
mapper
=
new
ObjectMapper
();
...
...
@@ -100,6 +106,9 @@ public class HystrixConfiguration implements ImportAware {
@Override
public
void
start
()
{
if
(
gauges
==
null
)
{
return
;
}
MetricsAsJsonPollerListener
listener
=
new
MetricsAsJsonPollerListener
()
{
@Override
public
void
handleJsonMetric
(
String
json
)
{
...
...
@@ -157,7 +166,7 @@ public class HystrixConfiguration implements ImportAware {
@Override
public
boolean
isRunning
()
{
return
poller
!=
null
?
poller
.
isRunning
()
:
false
;
return
poller
!=
null
?
poller
.
isRunning
()
:
false
;
}
@Override
...
...
@@ -181,8 +190,8 @@ public class HystrixConfiguration implements ImportAware {
}
/**
* {@link DisposableBean} that makes sure that Hystrix internal state is cleared
*
when
{@link ApplicationContext} shuts down.
* {@link DisposableBean} that makes sure that Hystrix internal state is cleared
when
* {@link ApplicationContext} shuts down.
*/
private
class
HystrixShutdownHook
implements
DisposableBean
{
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/hystrix/HystrixStreamEndpoint.java
View file @
5ef304a4
...
...
@@ -25,6 +25,6 @@ import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServl
public
class
HystrixStreamEndpoint
extends
ServletWrappingEndpoint
{
public
HystrixStreamEndpoint
()
{
super
(
HystrixMetricsStreamServlet
.
class
,
"hystrixStream"
,
"hystrix.stream"
,
false
,
true
);
super
(
HystrixMetricsStreamServlet
.
class
,
"hystrixStream"
,
"
/
hystrix.stream"
,
false
,
true
);
}
}
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/hystrix/HystrixConfigurationTests.java
0 → 100644
View file @
5ef304a4
/*
* Copyright 2013-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
cloud
.
netflix
.
hystrix
;
import
org.junit.Test
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
/**
* @author Dave Syer
*
*/
public
class
HystrixConfigurationTests
{
@Test
public
void
nonWebAppStartsUp
()
{
new
SpringApplicationBuilder
(
HystrixConfiguration
.
class
).
web
(
false
).
run
().
close
();
}
}
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/hystrix/HystrixStreamEndpointTests.java
0 → 100644
View file @
5ef304a4
/*
* Copyright 2013-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
cloud
.
netflix
.
hystrix
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
org.junit.Test
;
/**
* @author Dave Syer
*
*/
public
class
HystrixStreamEndpointTests
{
@Test
public
void
pathStartsWithSlash
()
{
HystrixStreamEndpoint
endpoint
=
new
HystrixStreamEndpoint
();
assertEquals
(
"/hystrix.stream"
,
endpoint
.
getPath
());
}
}
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