/** * Construct a {@link HystrixObservableCollapser} with defined {@link Setter} that allows * injecting property and strategy overrides and other optional arguments. * <p> * Null values will result in the default being used. * * @param setter * Fluent interface for constructor arguments */ protected HystrixObservableCollapser(Setter setter) { this(setter.collapserKey, setter.scope, new RealCollapserTimer(), setter.propertiesSetter, null); }
/** * Construct a {@link HystrixCollapser} with defined {@link Setter} that allows * injecting property and strategy overrides and other optional arguments. * <p> * Null values will result in the default being used. * * @param setter * Fluent interface for constructor arguments */ protected HystrixCollapser(Setter setter) { this(setter.collapserKey, setter.scope, new RealCollapserTimer(), setter.propertiesSetter, null); }
/** * Test a Void response type with execute - response being set in mapResponseToRequest to null * * @throws Exception */ @Test public void testVoidResponseTypeFireAndForgetCollapsing3() throws Exception { CollapserTimer timer = new RealCollapserTimer(); TestCollapserWithVoidResponseType collapser1 = new TestCollapserWithVoidResponseType(timer, 1); assertNull(collapser1.execute()); assertEquals(1, HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().size()); Iterator<HystrixInvokableInfo<?>> cmdIterator = HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().iterator(); assertEquals(1, cmdIterator.next().getNumberCollapsed()); }
@Test public void testCollapserUnderConcurrency() throws InterruptedException { final CollapserTimer timer = new RealCollapserTimer();
@Test public void testTwoRequestsWhichShouldEachEmitTwice() throws Exception { //TestCollapserTimer timer = new TestCollapserTimer(); CollapserTimer timer = new RealCollapserTimer(); HystrixObservableCollapser<String, String, String, String> collapser1 = new TestCollapserWithMultipleResponses(timer, 1, 3, false, false, prefixMapper, onMissingComplete); HystrixObservableCollapser<String, String, String, String> collapser2 = new TestCollapserWithMultipleResponses(timer, 2, 3, false, false, prefixMapper, onMissingComplete); TestSubscriber<String> testSubscriber1 = new TestSubscriber<String>(); TestSubscriber<String> testSubscriber2 = new TestSubscriber<String>(); System.out.println(System.currentTimeMillis() + "Starting to observe collapser1"); collapser1.observe().subscribe(testSubscriber1); collapser2.observe().subscribe(testSubscriber2); System.out.println(System.currentTimeMillis() + "Done with collapser observe()s"); //Note that removing these awaits breaks the unit test. That implies that the above subscribe does not wait for a terminal event testSubscriber1.awaitTerminalEvent(); testSubscriber2.awaitTerminalEvent(); testSubscriber1.assertCompleted(); testSubscriber1.assertNoErrors(); testSubscriber1.assertValues("1:1", "1:2", "1:3"); testSubscriber2.assertCompleted(); testSubscriber2.assertNoErrors(); testSubscriber2.assertValues("2:2", "2:4", "2:6"); }
MyCollapser(String arg, boolean reqCacheEnabled) { super(HystrixCollapserKey.Factory.asKey("UNITTEST"), Scope.REQUEST, new RealCollapserTimer(), HystrixCollapserProperties.Setter().withRequestCacheEnabled(reqCacheEnabled), HystrixCollapserMetrics.getInstance(HystrixCollapserKey.Factory.asKey("UNITTEST"), new HystrixPropertiesCollapserDefault(HystrixCollapserKey.Factory.asKey("UNITTEST"), HystrixCollapserProperties.Setter()))); this.arg = arg; }
public MyCollapser(String arg, boolean requestCachingOn) { super(HystrixCollapserKey.Factory.asKey("UNITTEST"), HystrixObservableCollapser.Scope.REQUEST, new RealCollapserTimer(), HystrixCollapserProperties.Setter().withRequestCacheEnabled(requestCachingOn), HystrixCollapserMetrics.getInstance(HystrixCollapserKey.Factory.asKey("UNITTEST"), new HystrixPropertiesCollapserDefault(HystrixCollapserKey.Factory.asKey("UNITTEST"), HystrixCollapserProperties.Setter()))); this.arg = arg; }
/** * Construct a {@link HystrixCollapser} with defined {@link Setter} that allows * injecting property and strategy overrides and other optional arguments. * <p> * Null values will result in the default being used. * * @param setter * Fluent interface for constructor arguments */ protected HystrixCollapser(Setter setter) { this(setter.collapserKey, setter.scope, new RealCollapserTimer(), setter.propertiesSetter, null); }
/** * Construct a {@link HystrixObservableCollapser} with defined {@link Setter} that allows * injecting property and strategy overrides and other optional arguments. * <p> * Null values will result in the default being used. * * @param setter * Fluent interface for constructor arguments */ protected HystrixObservableCollapser(Setter setter) { this(setter.collapserKey, setter.scope, new RealCollapserTimer(), setter.propertiesSetter, null); }