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
5bd32c01
Commit
5bd32c01
authored
Oct 08, 2014
by
Christian Dupuis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add shutdown hook for Hystrix to reset internal state and thread pool.
Additionally added some license headers and @author tags. fixes #17
parent
2505b437
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
96 additions
and
4 deletions
+96
-4
EnableHystrix.java
.../springframework/cloud/netflix/hystrix/EnableHystrix.java
+16
-0
HystrixConfiguration.java
...framework/cloud/netflix/hystrix/HystrixConfiguration.java
+33
-1
HystrixConfigurationSelector.java
...k/cloud/netflix/hystrix/HystrixConfigurationSelector.java
+16
-0
HystrixConfigurer.java
...ingframework/cloud/netflix/hystrix/HystrixConfigurer.java
+15
-0
HystrixStreamEndpoint.java
...ramework/cloud/netflix/hystrix/HystrixStreamEndpoint.java
+16
-3
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/hystrix/EnableHystrix.java
View file @
5bd32c01
/*
* 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
;
package
org
.
springframework
.
cloud
.
netflix
.
hystrix
;
import
org.springframework.context.annotation.AdviceMode
;
import
org.springframework.context.annotation.AdviceMode
;
...
@@ -14,6 +29,7 @@ import java.lang.annotation.*;
...
@@ -14,6 +29,7 @@ import java.lang.annotation.*;
@Documented
@Documented
@Import
(
HystrixConfigurationSelector
.
class
)
@Import
(
HystrixConfigurationSelector
.
class
)
public
@interface
EnableHystrix
{
public
@interface
EnableHystrix
{
/**
/**
* Indicate whether subclass-based (CGLIB) proxies are to be created ({@code true}) as
* Indicate whether subclass-based (CGLIB) proxies are to be created ({@code true}) as
* opposed to standard Java interface-based proxies ({@code false}). The default is
* opposed to standard Java interface-based proxies ({@code false}). The default is
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/hystrix/HystrixConfiguration.java
View file @
5bd32c01
/*
* 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
;
package
org
.
springframework
.
cloud
.
netflix
.
hystrix
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -9,6 +24,7 @@ import java.util.Set;
...
@@ -9,6 +24,7 @@ import java.util.Set;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.beans.factory.DisposableBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.actuate.metrics.GaugeService
;
import
org.springframework.boot.actuate.metrics.GaugeService
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
...
@@ -23,12 +39,14 @@ import org.springframework.util.Assert;
...
@@ -23,12 +39,14 @@ import org.springframework.util.Assert;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.netflix.hystrix.Hystrix
;
import
com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect
;
import
com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect
;
import
com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsPoller
;
import
com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsPoller
;
import
com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsPoller.MetricsAsJsonPollerListener
;
import
com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsPoller.MetricsAsJsonPollerListener
;
/**
/**
* @author Spencer Gibb
* @author Spencer Gibb
* @author Christian Dupuis
*/
*/
@Configuration
@Configuration
public
class
HystrixConfiguration
implements
ImportAware
{
public
class
HystrixConfiguration
implements
ImportAware
{
...
@@ -36,11 +54,16 @@ public class HystrixConfiguration implements ImportAware {
...
@@ -36,11 +54,16 @@ public class HystrixConfiguration implements ImportAware {
private
AnnotationAttributes
enableHystrix
;
private
AnnotationAttributes
enableHystrix
;
@Bean
@Bean
HystrixCommandAspect
hystrixCommandAspect
()
{
public
HystrixCommandAspect
hystrixCommandAspect
()
{
return
new
HystrixCommandAspect
();
return
new
HystrixCommandAspect
();
}
}
@Bean
@Bean
public
HystrixShutdownHook
hystrixShutdownHook
()
{
return
new
HystrixShutdownHook
();
}
@Bean
// TODO: add enable/disable
// TODO: add enable/disable
// TODO: make it @ConditionalOnWebApp (need a nested class)
// TODO: make it @ConditionalOnWebApp (need a nested class)
public
HystrixStreamEndpoint
hystrixStreamEndpoint
()
{
public
HystrixStreamEndpoint
hystrixStreamEndpoint
()
{
...
@@ -169,4 +192,13 @@ public class HystrixConfiguration implements ImportAware {
...
@@ -169,4 +192,13 @@ public class HystrixConfiguration implements ImportAware {
}
}
}
}
private
class
HystrixShutdownHook
implements
DisposableBean
{
@Override
public
void
destroy
()
throws
Exception
{
Hystrix
.
reset
();
}
}
}
}
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/hystrix/HystrixConfigurationSelector.java
View file @
5bd32c01
/*
* 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
;
package
org
.
springframework
.
cloud
.
netflix
.
hystrix
;
import
org.springframework.context.annotation.AdviceMode
;
import
org.springframework.context.annotation.AdviceMode
;
...
@@ -8,6 +23,7 @@ import org.springframework.context.annotation.AutoProxyRegistrar;
...
@@ -8,6 +23,7 @@ import org.springframework.context.annotation.AutoProxyRegistrar;
* @author Spencer Gibb
* @author Spencer Gibb
*/
*/
public
class
HystrixConfigurationSelector
extends
AdviceModeImportSelector
<
EnableHystrix
>
{
public
class
HystrixConfigurationSelector
extends
AdviceModeImportSelector
<
EnableHystrix
>
{
/**
/**
* The name of the AspectJ transaction management @{@code Configuration} class.
* The name of the AspectJ transaction management @{@code Configuration} class.
*/
*/
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/hystrix/HystrixConfigurer.java
View file @
5bd32c01
/*
* 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
;
package
org
.
springframework
.
cloud
.
netflix
.
hystrix
;
/**
/**
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/hystrix/HystrixStreamEndpoint.java
View file @
5bd32c01
/*
* 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
;
package
org
.
springframework
.
cloud
.
netflix
.
hystrix
;
import
org.springframework.cloud.netflix.endpoint.ServletWrappingEndpoint
;
import
org.springframework.cloud.netflix.endpoint.ServletWrappingEndpoint
;
...
@@ -5,9 +20,7 @@ import org.springframework.cloud.netflix.endpoint.ServletWrappingEndpoint;
...
@@ -5,9 +20,7 @@ import org.springframework.cloud.netflix.endpoint.ServletWrappingEndpoint;
import
com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet
;
import
com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet
;
/**
/**
* User: spencergibb
* @author Spencer Gibb
* Date: 4/22/14
* Time: 3:16 PM
*/
*/
public
class
HystrixStreamEndpoint
extends
ServletWrappingEndpoint
{
public
class
HystrixStreamEndpoint
extends
ServletWrappingEndpoint
{
...
...
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