@Test public void testTupleSource() throws TeiidComponentException, TeiidProcessingException { AsyncTupleSource ats = new AsyncTupleSource(new Callable<TupleSource>() { @Override public TupleSource call() throws Exception { return new CollectionTupleSource(Arrays.asList(Arrays.asList(1), Arrays.asList(2)).iterator()); } }, new CommandContext()); for (int i = 0; i < 20; i++) { try { assertEquals(Arrays.asList(1), ats.nextTuple()); break; } catch (BlockedException e) { try { Thread.sleep(500); } catch (InterruptedException e1) { } } } assertEquals(Arrays.asList(2), ats.nextTuple()); assertNull(ats.nextTuple()); }
@Override public List<?> nextTuple() throws TeiidComponentException, TeiidProcessingException { if (future != null) { if (!future.isDone()) { throw BlockedException.block("waiting for AsyncTupleSource results"); } result = clearFuture(); } Assertion.isNotNull(result); synchronized (callable) { return result.nextTuple(); } }
AsyncTupleSource implements TupleSource { @Override public List<?> nextTuple() throws TeiidComponentException, TeiidProcessingException { if (future != null) { if (!future.isDone()) { throw BlockedException.block("waiting for AsyncTupleSource results"); } result = clearFuture(); } Assertion.isNotNull(result); synchronized (callable) { return result.nextTuple(); } } }
AsyncTupleSource implements TupleSource { @Override public List<?> nextTuple() throws TeiidComponentException, TeiidProcessingException { if (future != null) { if (!future.isDone()) { throw BlockedException.block("waiting for AsyncTupleSource results"); } result = clearFuture(); } Assertion.isNotNull(result); synchronized (callable) { return result.nextTuple(); } } AsyncTupleSource(Callable<TupleSource> callable, CommandContext context); }
AsyncTupleSource implements TupleSource { @Override public List<?> nextTuple() throws TeiidComponentException, TeiidProcessingException { if (future != null) { if (!future.isDone()) { throw BlockedException.block("waiting for AsyncTupleSource results"); } result = clearFuture(); } Assertion.isNotNull(result); synchronized (callable) { return result.nextTuple(); } } AsyncTupleSource(Callable<TupleSource> callable, CommandContext context); @Override List<?> nextTuple(); @Override void closeSource(); }
AsyncTupleSource implements TupleSource { @Override public List<?> nextTuple() throws TeiidComponentException, TeiidProcessingException { if (future != null) { if (!future.isDone()) { throw BlockedException.block("waiting for AsyncTupleSource results"); } result = clearFuture(); } Assertion.isNotNull(result); synchronized (callable) { return result.nextTuple(); } } AsyncTupleSource(Callable<TupleSource> callable, CommandContext context); @Override List<?> nextTuple(); @Override void closeSource();  }