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
27c41882
Commit
27c41882
authored
Feb 05, 2015
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "move /hystrix.stream from an endpoint to a servlet"
This reverts commit
29bee28d
.
parent
29383de8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
103 deletions
+72
-103
HystrixCircuitBreakerConfiguration.java
...d/netflix/hystrix/HystrixCircuitBreakerConfiguration.java
+5
-5
HystrixStreamEndpoint.java
...ramework/cloud/netflix/hystrix/HystrixStreamEndpoint.java
+33
-0
HystrixStreamEndpointTests.java
...ork/cloud/netflix/hystrix/HystrixStreamEndpointTests.java
+34
-0
HystrixStreamTests.java
...ngframework/cloud/netflix/hystrix/HystrixStreamTests.java
+0
-98
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/hystrix/HystrixCircuitBreakerConfiguration.java
View file @
27c41882
...
...
@@ -27,11 +27,11 @@ import org.apache.commons.logging.Log;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.beans.factory.DisposableBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.actuate.endpoint.Endpoint
;
import
org.springframework.boot.actuate.metrics.GaugeService
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication
;
import
org.springframework.boot.context.embedded.ServletRegistrationBean
;
import
org.springframework.context.SmartLifecycle
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -62,14 +62,14 @@ public class HystrixCircuitBreakerConfiguration {
}
@Configuration
@ConditionalOnProperty
(
value
=
"hystrix.stream.enabled"
,
matchIfMissing
=
true
)
@ConditionalOnProperty
(
value
=
"hystrix.stream.en
dpoint.en
abled"
,
matchIfMissing
=
true
)
@ConditionalOnWebApplication
@ConditionalOnClass
(
HystrixMetricsStreamServlet
.
class
)
@ConditionalOnClass
(
{
Endpoint
.
class
,
HystrixMetricsStreamServlet
.
class
}
)
protected
static
class
HystrixWebConfiguration
{
@Bean
public
ServletRegistrationBean
hystrixServe
t
()
{
return
new
ServletRegistrationBean
(
new
HystrixMetricsStreamServlet
(),
"/hystrix.stream"
);
public
HystrixStreamEndpoint
hystrixStreamEndpoin
t
()
{
return
new
HystrixStreamEndpoint
(
);
}
}
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/hystrix/HystrixStreamEndpoint.java
0 → 100644
View file @
27c41882
/*
* 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.springframework.cloud.netflix.endpoint.ServletWrappingEndpoint
;
import
com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet
;
/**
* @author Spencer Gibb
*/
public
class
HystrixStreamEndpoint
extends
ServletWrappingEndpoint
{
public
HystrixStreamEndpoint
()
{
super
(
HystrixMetricsStreamServlet
.
class
,
"hystrixStream"
,
"/hystrix.stream"
,
false
,
true
);
}
}
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/hystrix/HystrixStreamEndpointTests.java
0 → 100644
View file @
27c41882
/*
* 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
static
org
.
junit
.
Assert
.
assertEquals
;
/**
* @author Dave Syer
*/
public
class
HystrixStreamEndpointTests
{
@Test
public
void
pathStartsWithSlash
()
{
HystrixStreamEndpoint
endpoint
=
new
HystrixStreamEndpoint
();
assertEquals
(
"/hystrix.stream"
,
endpoint
.
getPath
());
}
}
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/hystrix/HystrixStreamTests.java
deleted
100644 → 0
View file @
29383de8
/*
* Copyright 2013-2015 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
com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.test.annotation.DirtiesContext
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.io.InputStream
;
import
java.net.URL
;
import
static
org
.
junit
.
Assert
.*;
/**
* @author Spencer Gibb
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
HystrixStreamTests
.
Application
.
class
)
@WebAppConfiguration
@IntegrationTest
({
"server.port=0"
,
"spring.application.name=hystrixstreamtest"
})
@DirtiesContext
public
class
HystrixStreamTests
{
@Value
(
"${local.server.port}"
)
private
int
port
=
0
;
@Test
public
void
hystrixStreamWorks
()
throws
Exception
{
String
url
=
"http://localhost:"
+
port
;
//you have to hit a Hystrix circuit breaker before the stream sends anything
ResponseEntity
<
String
>
response
=
new
TestRestTemplate
().
getForEntity
(
url
,
String
.
class
);
assertEquals
(
"bad response code"
,
HttpStatus
.
OK
,
response
.
getStatusCode
());
URL
hystrixUrl
=
new
URL
(
url
+
"/hystrix.stream"
);
InputStream
in
=
hystrixUrl
.
openStream
();
byte
[]
buffer
=
new
byte
[
1024
];
in
.
read
(
buffer
);
String
contents
=
new
String
(
buffer
);
assertTrue
(
contents
.
contains
(
"ping"
));
in
.
close
();
}
@Configuration
@EnableAutoConfiguration
@RestController
@EnableCircuitBreaker
protected
static
class
Application
{
@Autowired
Service
service
;
@Bean
Service
service
()
{
return
new
Service
();
}
@RequestMapping
(
"/"
)
public
String
hello
()
{
return
service
.
hello
();
}
}
protected
static
class
Service
{
@HystrixCommand
public
String
hello
()
{
return
"Hello World"
;
}
}
}
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