Skip to content

Commit

Permalink
Merge pull request #452 from mattrjacobs/plugins-reset
Browse files Browse the repository at this point in the history
Add the capability to reset HystrixPlugins and make Hystrix.reset() invoke it
  • Loading branch information
mattrjacobs committed Jan 7, 2015
2 parents 8847054 + c93d319 commit 670a3bf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions hystrix-core/src/main/java/com/netflix/hystrix/Hystrix.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.NoSuchElementException;
import java.util.concurrent.TimeUnit;

import com.netflix.hystrix.strategy.HystrixPlugins;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -56,6 +57,7 @@ private static void _reset() {
HystrixCollapser.reset();
// clear circuit breakers
HystrixCircuitBreaker.Factory.reset();
HystrixPlugins.reset();
}

private static ThreadLocal<LinkedList<HystrixCommandKey>> currentCommand = new ThreadLocal<LinkedList<HystrixCommandKey>>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ public static HystrixPlugins getInstance() {
return INSTANCE;
}

/**
* Reset all of the HystrixPlugins to null. You may invoke this directly, or it also gets invoked via <code>Hystrix.reset()</code>
*/
public static void reset() {
getInstance().notifier.set(null);
getInstance().concurrencyStrategy.set(null);
getInstance().metricsPublisher.set(null);
getInstance().propertiesFactory.set(null);
getInstance().commandExecutionHook.set(null);
}

/**
* Retrieve instance of {@link HystrixEventNotifier} to use based on order of precedence as defined in {@link HystrixPlugins} class header.
* <p>
Expand Down Expand Up @@ -279,4 +290,5 @@ private static Object getPluginImplementationViaProperty(Class<?> pluginClass) {
}
}


}

0 comments on commit 670a3bf

Please sign in to comment.