use of org.mule.runtime.core.internal.processor.strategy.ProactorStreamProcessingStrategyFactory.ProactorStreamProcessingStrategy in project mule by mulesoft.
the class ProactorStreamProcessingStrategyTestCase method cpuIntensiveRejectedExecution.
@Test
@Description("If CPU INTENSIVE pool is busy OVERLOAD error is thrown")
public void cpuIntensiveRejectedExecution() throws Exception {
Scheduler cpuIntensiveSchedulerSpy = spy(cpuIntensive);
Scheduler rejectingSchedulerSpy = spy(new RejectingScheduler(cpuIntensiveSchedulerSpy));
flow = flowBuilder.get().processors(cpuIntensiveProcessor).processingStrategyFactory((context, prefix) -> new ProactorStreamProcessingStrategy(() -> ringBuffer, DEFAULT_BUFFER_SIZE, 1, DEFAULT_WAIT_STRATEGY, () -> cpuLight, () -> blocking, () -> rejectingSchedulerSpy, 1, 2)).build();
flow.initialise();
flow.start();
processFlow(testEvent());
verify(rejectingSchedulerSpy, times(11)).submit(any(Callable.class));
verify(cpuIntensiveSchedulerSpy, times(1)).submit(any(Callable.class));
assertThat(threads, hasSize(1));
assertThat(threads.stream().filter(name -> name.startsWith(CPU_INTENSIVE)).count(), equalTo(1l));
assertThat(threads, not(hasItem(startsWith(CPU_LIGHT))));
assertThat(threads, not(hasItem(startsWith(IO))));
assertThat(threads, not(hasItem(startsWith(CUSTOM))));
}
use of org.mule.runtime.core.internal.processor.strategy.ProactorStreamProcessingStrategyFactory.ProactorStreamProcessingStrategy in project mule by mulesoft.
the class ProactorStreamProcessingStrategyTestCase method blockingRejectedExecution.
@Test
@Description("If IO pool is busy OVERLOAD error is thrown")
public void blockingRejectedExecution() throws Exception {
Scheduler blockingSchedulerSpy = spy(blocking);
Scheduler rejectingSchedulerSpy = spy(new RejectingScheduler(blockingSchedulerSpy));
flow = flowBuilder.get().processors(blockingProcessor).processingStrategyFactory((context, prefix) -> new ProactorStreamProcessingStrategy(() -> ringBuffer, DEFAULT_BUFFER_SIZE, 1, DEFAULT_WAIT_STRATEGY, () -> cpuLight, () -> rejectingSchedulerSpy, () -> cpuIntensive, 1, 2)).build();
flow.initialise();
flow.start();
processFlow(testEvent());
verify(rejectingSchedulerSpy, times(11)).submit(any(Callable.class));
verify(blockingSchedulerSpy, times(1)).submit(any(Callable.class));
assertThat(threads, hasSize(1));
assertThat(threads.stream().filter(name -> name.startsWith(IO)).count(), equalTo(1l));
assertThat(threads, not(hasItem(startsWith(CPU_LIGHT))));
assertThat(threads, not(hasItem(startsWith(CPU_INTENSIVE))));
assertThat(threads, not(hasItem(startsWith(CUSTOM))));
}
Aggregations