@Override @Description("Regardless of processor type, when the BlockingProcessingStrategy is configured, the pipeline is executed " + "synchronously in a caller thread and the pipeline will block caller thread until any async processors complete " + "before continuing in the caller thread.") public void asyncCpuLight() throws Exception { super.asyncCpuLight(); }
@Override @Description("Concurrent stream with concurrency of 8 only uses two CPU_LIGHT threads.") public void concurrentStream() throws Exception { super.concurrentStream(); assertThat(threads, hasSize(2)); assertThat(threads.stream().filter(name -> name.startsWith(CPU_LIGHT)).count(), equalTo(2l)); }
@Override @Description("With the ProactorProcessingStrategy, when there is a mix of processor processing types, each processor is " + "scheduled on the correct scheduler.") public void mix() throws Exception { super.mix(); assertThat(threads, hasSize(equalTo(3))); assertThat(threads.stream().filter(name -> name.startsWith(CPU_INTENSIVE)).count(), equalTo(1l)); assertThat(threads.stream().filter(name -> name.startsWith(IO)).count(), equalTo(1l)); assertThat(threads.stream().filter(name -> name.startsWith(CPU_LIGHT)).count(), equalTo(1l)); assertThat(threads, not(hasItem(startsWith(CUSTOM)))); }
@Test @Description("Regardless of back-pressure strategy this processing strategy blocks and processes all events") public void sourceBackPressureDrop() throws Exception { testBackPressure(DROP, equalTo(STREAM_ITERATIONS), equalTo(0), equalTo(STREAM_ITERATIONS)); }
@Override @Test @Description("When back-pressure strategy is 'WAIT' the source thread blocks and all requests are processed.") public void sourceBackPressureWait() throws Exception { testBackPressure(WAIT, equalTo(STREAM_ITERATIONS), equalTo(0), equalTo(STREAM_ITERATIONS)); }
@Test @Description("When back-pressure strategy is 'WAIT' the source thread blocks and all requests are processed.") public void sourceBackPressureWait() throws Exception { testBackPressure(WAIT, equalTo(STREAM_ITERATIONS), equalTo(0), equalTo(STREAM_ITERATIONS)); }
@Test @Description("Number of CPU Light threads is limited to number of cores when max concurrency is MAX_VALUE.") public void cpuLightCountUnlimitedConcurrency() { assertThat(processingStrategy.resolveParallelism(), equalTo(max(CORES / DEFAULT_SUBSCRIBER_COUNT, 1))); }
@Test @Description("Regardless of back-pressure strategy this processing strategy blocks and processes all events") public void sourceBackPressureWait() throws Exception { testBackPressure(WAIT, equalTo(STREAM_ITERATIONS), equalTo(0), equalTo(STREAM_ITERATIONS)); }
@Test @Description("Number of CPU Light threads is limited to number of cores when max concurrency is MAX_VALUE.") public void cpuLightCountUnlimitedConcurrency() { assertThat(processingStrategy.resolveParallelism(), equalTo(max(CORES / DEFAULT_SUBSCRIBER_COUNT, 1))); }
@Test @Description("When back-pressure strategy is 'WAIT' the source thread blocks and all requests are processed.") public void sourceBackPressureWait() throws Exception { testBackPressure(WAIT, equalTo(STREAM_ITERATIONS), equalTo(0), equalTo(STREAM_ITERATIONS)); }
@Test @Description("Checks that an operation disposes the resources after terminated") public void disposeAfterExecution() throws Throwable { executeSimpleOperation(); assertThat(HeisenbergOperations.disposed, is(true)); }
@Test @Description("Notifications are invoked on CPU_LITE thread") public void asyncProcessorNotificationExecutionThreads() throws Exception { AtomicReference<Thread> beforeThread = new AtomicReference<>(); AtomicReference<Thread> afterThread = new AtomicReference<>(); testAsyncCpuLightNotificationThreads(beforeThread, afterThread); assertThat(beforeThread.get().getName(), startsWith(CPU_LIGHT)); assertThat(afterThread.get().getName(), startsWith(CPU_LIGHT)); }
@Override @Description("With the ProactorProcessingStrategy, when there is a mix of processor processing types, each processor is " + "scheduled on the correct scheduler.") public void mix2() throws Exception { super.mix2(); assertThat(threads, hasSize(between(3, 7))); assertThat(threads.stream().filter(name -> name.startsWith(CPU_INTENSIVE)).count(), between(1l, 2l)); assertThat(threads.stream().filter(name -> name.startsWith(IO)).count(), between(1l, 2l)); assertThat(threads.stream().filter(name -> name.startsWith(CPU_LIGHT)).count(), between(1l, 3l)); assertThat(threads, not(hasItem(startsWith(CUSTOM)))); }
@Test @Description("Notifications are invoked on CPU_LITE thread") public void asyncProcessorNotificationExecutionThreads() throws Exception { AtomicReference<Thread> beforeThread = new AtomicReference<>(); AtomicReference<Thread> afterThread = new AtomicReference<>(); testAsyncCpuLightNotificationThreads(beforeThread, afterThread); assertThat(beforeThread.get().getName(), startsWith(CPU_LIGHT)); assertThat(afterThread.get().getName(), startsWith(CPU_LIGHT)); }
@Override @Description("With the ProactorProcessingStrategy, when all processor are CPU_LIGHT then they are all exectured in a single " + " cpu light thread.") public void singleCpuLight() throws Exception { super.singleCpuLight(); assertThat(threads, hasSize(equalTo(1))); assertThat(threads.stream().filter(name -> name.startsWith(CPU_LIGHT)).count(), equalTo(1l)); assertThat(threads, not(hasItem(startsWith(IO)))); assertThat(threads, not(hasItem(startsWith(CPU_INTENSIVE)))); assertThat(threads, not(hasItem(startsWith(CUSTOM)))); }
@Override @Description("With the ProactorProcessingStrategy, a CPU_INTENSIVE message processor is scheduled on a CPU intensive thread.") public void singleCpuIntensive() throws Exception { super.singleCpuIntensive(); assertThat(threads, hasSize(equalTo(1))); assertThat(threads.stream().filter(name -> name.startsWith(CPU_INTENSIVE)).count(), equalTo(1l)); assertThat(threads, not(hasItem(startsWith(IO)))); assertThat(threads, not(hasItem(startsWith(CPU_LIGHT)))); assertThat(threads, not(hasItem(startsWith(CUSTOM)))); }
@Override @Description("With the ProactorProcessingStrategy, when all processor are CPU_LIGHT then they are all exectured in a single " + " cpu light thread.") public void multipleCpuLight() throws Exception { super.multipleCpuLight(); assertThat(threads, hasSize(equalTo(1))); assertThat(threads.stream().filter(name -> name.startsWith(CPU_LIGHT)).count(), equalTo(1l)); assertThat(threads, not(hasItem(startsWith(IO)))); assertThat(threads, not(hasItem(startsWith(CPU_INTENSIVE)))); assertThat(threads, not(hasItem(startsWith(CUSTOM)))); }
@Override @Description("With the ProactorProcessingStrategy, when all processor are CPU_LIGHT then they are all exectured in a single " + " cpu light thread.") public void multipleCpuLight() throws Exception { super.multipleCpuLight(); assertThat(threads, hasSize(equalTo(1))); assertThat(threads.stream().filter(name -> name.startsWith(CPU_LIGHT)).count(), equalTo(1l)); assertThat(threads, not(hasItem(startsWith(IO)))); assertThat(threads, not(hasItem(startsWith(CPU_INTENSIVE)))); assertThat(threads, not(hasItem(startsWith(CUSTOM)))); }
@Override @Description("With the ProactorProcessingStrategy, a BLOCKING message processor is scheduled on a IO thread.") public void singleBlocking() throws Exception { super.singleBlocking(); assertThat(threads, hasSize(equalTo(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)))); }
@Override @Description("With the ProactorProcessingStrategy, when all processor are CPU_LIGHT then they are all exectured in a single " + " cpu light thread.") public void singleCpuLight() throws Exception { super.singleCpuLight(); assertThat(threads, hasSize(equalTo(1))); assertThat(threads.stream().filter(name -> name.startsWith(CPU_LIGHT)).count(), equalTo(1l)); assertThat(threads, not(hasItem(startsWith(IO)))); assertThat(threads, not(hasItem(startsWith(CPU_INTENSIVE)))); assertThat(threads, not(hasItem(startsWith(CUSTOM)))); }