List of usage examples for java.util.concurrent ExecutorCompletionService poll
public Future<V> poll()
From source file:com.streamsets.pipeline.stage.origin.jdbc.AbstractTableJdbcSource.java
/** * Checks whether any of the {@link TableJdbcRunnable} workers completed * and whether there is any error that needs to be handled from them. * @param completionService {@link ExecutorCompletionService} used to detect completion * @throws StageException if {@link StageException} is thrown by the workers (if the error handling is stop pipeline) *///ww w. ja va 2 s.com private void checkWorkerStatus(ExecutorCompletionService<Future> completionService) throws StageException { Future future = completionService.poll(); if (future != null) { try { future.get(); } catch (InterruptedException e) { LOG.error("Thread interrupted", e); } catch (ExecutionException e) { Throwable cause = Throwables.getRootCause(e); if (cause != null && cause instanceof StageException) { throw (StageException) cause; } else { LOG.error("Internal Error", e); throw new StageException(JdbcErrors.JDBC_75, e.toString(), e); } } } }