Skip to content

Commit

Permalink
Made HystrixCollapserMetrics resettable
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Jacobs committed Feb 6, 2015
1 parent 5ab3d91 commit 519b6ad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ private static void _reset() {
// clear metrics
HystrixCommandMetrics.reset();
HystrixThreadPoolMetrics.reset();
HystrixCollapserMetrics.reset();
// clear collapsers
HystrixCollapser.reset();
// clear circuit breakers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class HystrixObservableCollapserTest {
public void init() {
// since we're going to modify properties of the same class between tests, wipe the cache each time
HystrixCollapser.reset();
Hystrix.reset();
/* we must call this to simulate a new request lifecycle running and clearing caches */
HystrixRequestContext.initializeContext();
}
Expand Down Expand Up @@ -80,6 +81,15 @@ public void testTwoRequests() throws Exception {
assertEquals(0L, metrics.getRollingCount(HystrixRollingNumberEvent.RESPONSE_FROM_CACHE));
}

@Test
public void stressTestRequestCollapser() throws Exception {
for(int i = 0; i < 1000; i++) {
init();
testTwoRequests();
cleanup();
}
}

private static class TestRequestCollapser extends HystrixObservableCollapser<String, String, String, String> {

private final String value;
Expand Down

0 comments on commit 519b6ad

Please sign in to comment.