Java Code Examples for reactor.core.publisher.Hooks#resetOnLastOperator()

The following examples show how to use reactor.core.publisher.Hooks#resetOnLastOperator() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReactorTestExecutionListener.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
public static void reset() {
	Hooks.resetOnOperatorDebug();

	Hooks.resetOnEachOperator();
	Hooks.resetOnLastOperator();

	Hooks.resetOnErrorDropped();
	Hooks.resetOnNextDropped();

	Hooks.resetOnNextError();
	Hooks.resetOnOperatorError();

	Schedulers.resetOnHandleError();
	Schedulers.resetFactory();
	Schedulers.resetOnScheduleHooks();

	// TODO capture non-default schedulers and shutdown them
}
 
Example 2
Source File: TraceReactorAutoConfiguration.java    From spring-cloud-sleuth with Apache License 2.0 6 votes vote down vote up
@PreDestroy
public void cleanupHooks() {
	if (log.isTraceEnabled()) {
		log.trace("Cleaning up hooks");
	}
	SleuthReactorProperties reactorProperties = this.springContext
			.getBean(SleuthReactorProperties.class);
	if (reactorProperties.isDecorateOnEach()) {
		if (log.isTraceEnabled()) {
			log.trace("Resetting onEach operator instrumentation");
		}
		Hooks.resetOnEachOperator(SLEUTH_TRACE_REACTOR_KEY);
	}
	else {
		if (log.isTraceEnabled()) {
			log.trace("Resetting onLast operator instrumentation");
		}
		Hooks.resetOnLastOperator(SLEUTH_TRACE_REACTOR_KEY);
	}
	Schedulers
			.removeExecutorServiceDecorator(SLEUTH_REACTOR_EXECUTOR_SERVICE_KEY);
}
 
Example 3
Source File: TraceReactorAutoConfiguration.java    From spring-cloud-sleuth with Apache License 2.0 6 votes vote down vote up
@Override
public void onApplicationEvent(RefreshScopeRefreshedEvent event) {
	if (log.isDebugEnabled()) {
		log.debug("Context refreshed, will reset hooks and then re-register them");
	}
	Hooks.resetOnEachOperator(SLEUTH_TRACE_REACTOR_KEY);
	Hooks.resetOnLastOperator(SLEUTH_TRACE_REACTOR_KEY);
	if (this.reactorProperties.isDecorateOnEach()) {
		if (log.isTraceEnabled()) {
			log.trace("Decorating onEach operator instrumentation");
		}
		Hooks.onEachOperator(SLEUTH_TRACE_REACTOR_KEY,
				scopePassingSpanOperator(this.context));
	}
	else {
		if (log.isTraceEnabled()) {
			log.trace("Decorating onLast operator instrumentation");
		}
		Hooks.onLastOperator(SLEUTH_TRACE_REACTOR_KEY,
				scopePassingSpanOperator(this.context));
	}
}
 
Example 4
Source File: TraceReactorAutoConfigurationAccessorConfiguration.java    From spring-cloud-sleuth with Apache License 2.0 5 votes vote down vote up
public static void close() {
	if (log.isTraceEnabled()) {
		log.trace("Cleaning up hooks");
	}
	Hooks.resetOnEachOperator(SLEUTH_TRACE_REACTOR_KEY);
	Hooks.resetOnLastOperator(SLEUTH_TRACE_REACTOR_KEY);
	Schedulers.removeExecutorServiceDecorator(SLEUTH_REACTOR_EXECUTOR_SERVICE_KEY);
}
 
Example 5
Source File: ScopePassingSpanSubscriberTests.java    From spring-cloud-sleuth with Apache License 2.0 5 votes vote down vote up
@Before
public void resetHooks() {
	// There's an assumption some other test is leaking hooks, so we clear them all to
	// prevent should_not_scope_scalar_subscribe from being interfered with.
	Hooks.resetOnEachOperator(SLEUTH_TRACE_REACTOR_KEY);
	Hooks.resetOnLastOperator(SLEUTH_TRACE_REACTOR_KEY);
	Schedulers.removeExecutorServiceDecorator(SLEUTH_REACTOR_EXECUTOR_SERVICE_KEY);
}
 
Example 6
Source File: TraceReactorAutoConfigurationAccessorConfiguration.java    From spring-cloud-sleuth with Apache License 2.0 5 votes vote down vote up
public static void close() {
	if (log.isTraceEnabled()) {
		log.trace("Cleaning up hooks");
	}
	Hooks.resetOnEachOperator(SLEUTH_TRACE_REACTOR_KEY);
	Hooks.resetOnLastOperator(SLEUTH_TRACE_REACTOR_KEY);
	Schedulers.removeExecutorServiceDecorator(SLEUTH_REACTOR_EXECUTOR_SERVICE_KEY);
}
 
Example 7
Source File: HooksTraceTest.java    From reactor-core with Apache License 2.0 4 votes vote down vote up
@Test
public void lastOperatorTest() {
	Hooks.onLastOperator(Operators.lift((sc, sub) ->
			new CoreSubscriber<Object>(){
				@Override
				public void onSubscribe(Subscription s) {
					sub.onSubscribe(s);
				}

				@Override
				public void onNext(Object o) {
					sub.onNext(((Integer)o) + 1);
				}

				@Override
				public void onError(Throwable t) {
					sub.onError(t);
				}

				@Override
				public void onComplete() {
					sub.onComplete();
				}
			}));

	StepVerifier.create(Flux.just(1, 2, 3)
	                        .log()
	                        .log())
	            .expectNext(2, 3, 4)
	            .verifyComplete();

	StepVerifier.create(Mono.just(1)
	                        .log()
	                        .log())
	            .expectNext(2)
	            .verifyComplete();

	StepVerifier.create(ParallelFlux.from(Mono.just(1), Mono.just(1))
	                        .log()
	                        .log())
	            .expectNext(2, 2)
	            .verifyComplete();

	Hooks.resetOnLastOperator();
}
 
Example 8
Source File: MonoTests.java    From reactor-core with Apache License 2.0 4 votes vote down vote up
@After
public void resetHooks() {
	Hooks.resetOnEachOperator();
	Hooks.resetOnLastOperator();
}
 
Example 9
Source File: HttpClientBeanPostProcessorTest.java    From spring-cloud-sleuth with Apache License 2.0 4 votes vote down vote up
@BeforeEach
public void setup() {
	Hooks.resetOnEachOperator();
	Hooks.resetOnLastOperator();
	Schedulers.resetOnScheduleHooks();
}
 
Example 10
Source File: FlowsScopePassingSpanSubscriberTests.java    From spring-cloud-sleuth with Apache License 2.0 4 votes vote down vote up
@BeforeEach
public void setup() {
	Hooks.resetOnEachOperator(SLEUTH_TRACE_REACTOR_KEY);
	Hooks.resetOnLastOperator(SLEUTH_TRACE_REACTOR_KEY);
	Schedulers.resetOnScheduleHooks();
}