/** * Fails on the 1001st time. */ @Test public void testMultipleExecutionsWithoutListeners() { checkLoop(1001); }
/** * Works fine. */ @Test public void testDifferentListeners() { Ignite ignite = G.ignite(getTestIgniteInstanceName()); for (int i = 0; i < 2000; i++) { P2<UUID, Object> l = new P2<UUID, Object>() { @Override public boolean apply(UUID uuid, Object o) { return false; } }; ignite.message().localListen(null, l); } info(getName() + ": worked without exceptions."); }
/** * This is the workaround- as long as we keep a message listener in * the stack, our FIFO bug isn't exposed. Comment above out to see. */ @Test public void testOneListener() { Ignite ignite = G.ignite(getTestIgniteInstanceName()); final AtomicBoolean stop = new AtomicBoolean(); P2<UUID, Object> l = new P2<UUID, Object>() { @Override public boolean apply(UUID uuid, Object o) { return stop.get(); } }; try { ignite.message().localListen(null, l); checkLoop(2000); } finally { stop.set(true); } }
/** * @param cnt Iteration count. */ private void checkLoop(int cnt) { for (int i = 1; i <= cnt; i++) { MessageListeningTask t = new MessageListeningTask(); try { G.ignite(getTestIgniteInstanceName()).compute().execute(t.getClass(), null); } catch (IgniteException e) { assert false : "Failed to execute task [iteration=" + i + ", err=" + e.getMessage() + ']'; } if (i % 100 == 0) info(getName() + ": through " + i); } }
/** * Now, our test will fail on the first message added after our safety * message listener has been removed. */ @Test public void testSingleExecutionWithoutListeners() { checkLoop(1); }