/** * Clears all state. If new requests come in instances will be recreated and metrics started from scratch. */ public static void reset() { globalScopedCollapsers.clear(); requestScopedCollapsers.clear(); HystrixTimer.reset(); }
@Before public void setUp() { HystrixTimer timer = HystrixTimer.getInstance(); HystrixTimer.reset(); HystrixPlugins.reset(); }
@Test public void testReset() { HystrixTimer timer = HystrixTimer.getInstance(); TestListener l1 = new TestListener(50, "A"); timer.addTimerListener(l1); ScheduledExecutor ex = timer.executor.get(); assertFalse(ex.executor.isShutdown()); // perform reset which should shut it down HystrixTimer.reset(); assertTrue(ex.executor.isShutdown()); assertNull(timer.executor.get()); // assert it starts up again on use TestListener l2 = new TestListener(50, "A"); timer.addTimerListener(l2); ScheduledExecutor ex2 = timer.executor.get(); assertFalse(ex2.executor.isShutdown()); // reset again to shutdown what we just started HystrixTimer.reset(); // try resetting again to make sure it's idempotent (ie. doesn't blow up on an NPE) HystrixTimer.reset(); }
/** * Clears all state. If new requests come in instances will be recreated and metrics started from scratch. */ public static void reset() { globalScopedCollapsers.clear(); requestScopedCollapsers.clear(); HystrixTimer.reset(); }