Source:
public void activePickProcessTest() throws InjectionException, InterruptedException { final JavaConfigurationBuilder jcb = Tang.Factory.getTang().newConfigurationBuilder(); final Injector injector = Tang.Factory.getTang().newInjector(jcb.build()); final OperatorChainManager operatorChainManager = injector.getInstance(ActiveQueryPickManager.class); final StringIdentifierFactory idfac = injector.getInstance(StringIdentifierFactory.class); final int numTasks = 1000000; final List<MistEvent> list1 = new LinkedList<>(); final List<MistEvent> list2 = new LinkedList<>(); final List<MistEvent> result = new LinkedList<>(); final OperatorChain chain1 = new DefaultOperatorChainImpl(); final PhysicalOperator o1 = new DefaultPhysicalOperatorImpl("op1", null, new TestOperator(), chain1); chain1.insertToHead(o1); chain1.setOutputEmitter(new OutputBufferEmitter(list1)); chain1.setOperatorChainManager(operatorChainManager); final OperatorChain chain2 = new DefaultOperatorChainImpl(); final PhysicalOperator o2 = new DefaultPhysicalOperatorImpl("op2", null, new TestOperator(), chain2); chain2.insertToHead(o2); chain2.setOutputEmitter(new OutputBufferEmitter(list2)); chain2.setOperatorChainManager(operatorChainManager); for (int i = 0; i < numTasks; i++) { chain1.addNextEvent(new MistDataEvent(i, i), Direction.LEFT); chain2.addNextEvent(new MistDataEvent(i, i), Direction.LEFT); result.add(new MistDataEvent(i, i)); } final Thread processor = new Thread(new ConditionEventProcessor(operatorChainManager)); processor.start(); while (!(list1.size() == numTasks && list2.size() == numTasks)) { Thread.sleep(1000); } Assert.assertEquals(result, list1); Assert.assertEquals(result, list2); processor.interrupt(); }

Target:
public void activePickProcessTest() throws InjectionException, InterruptedException { final JavaConfigurationBuilder jcb = Tang.Factory.getTang().newConfigurationBuilder(); final Injector injector = Tang.Factory.getTang().newInjector(jcb.build()); final BlockingActiveOperatorChainPickManager operatorChainManager = injector.getInstance(BlockingActiveOperatorChainPickManager.class); final StringIdentifierFactory idfac = injector.getInstance(StringIdentifierFactory.class); final int numTasks = 1000000; final CountDownLatch countDownLatch1 = new CountDownLatch(numTasks); final CountDownLatch countDownLatch2 = new CountDownLatch(numTasks); final List<MistEvent> list1 = new LinkedList<>(); final List<MistEvent> list2 = new LinkedList<>(); final List<MistEvent> result = new LinkedList<>(); final OperatorChain chain1 = new DefaultOperatorChainImpl(); final PhysicalOperator o1 = new DefaultPhysicalOperatorImpl("op1", null, new TestOperator(countDownLatch1), chain1); chain1.insertToHead(o1); chain1.setOutputEmitter(new OutputBufferEmitter(list1)); chain1.setOperatorChainManager(operatorChainManager); final OperatorChain chain2 = new DefaultOperatorChainImpl(); final PhysicalOperator o2 = new DefaultPhysicalOperatorImpl("op2", null, new TestOperator(countDownLatch2), chain2); chain2.insertToHead(o2); chain2.setOutputEmitter(new OutputBufferEmitter(list2)); chain2.setOperatorChainManager(operatorChainManager); for (int i = 0; i < numTasks; i++) { chain1.addNextEvent(new MistDataEvent(i, i), Direction.LEFT); chain2.addNextEvent(new MistDataEvent(i, i), Direction.LEFT); result.add(new MistDataEvent(i, i)); } final Thread processor = new Thread(new ConditionEventProcessor(operatorChainManager)); processor.start(); countDownLatch1.await(); countDownLatch2.await(); Assert.assertEquals(result, list1); Assert.assertEquals(result, list2); processor.interrupt(); }