@Override public void await(long timeout, TimeUnit unit) throws InterruptedException { latch.await(timeout, unit); }
@Override public void await() throws InterruptedException { latch.await(); }
/** * Wait for the connector to complete processing. If the processor is not running, this method returns immediately; however, * if the processor is {@link #stop() stopped} and restarted before this method is called, this method will return only * when it completes the second time. * * @param timeout the maximum amount of time to wait before returning * @param unit the unit of time; may not be null * @return {@code true} if the connector completed within the timeout (or was not running), or {@code false} if it is still * running when the timeout occurred * @throws InterruptedException if this thread is interrupted while waiting for the completion of the connector */ public boolean await(long timeout, TimeUnit unit) throws InterruptedException { return latch.await(timeout, unit); }
/** * Stop the execution of this embedded connector. This method does not block until the connector is stopped; use * {@link #await(long, TimeUnit)} for this purpose. * * @return {@code true} if the connector was {@link #run() running} and will eventually stop, or {@code false} if it was not * running when this method is called * @see #await(long, TimeUnit) */ public boolean stop() { logger.debug("Stopping the embedded engine"); // Signal that the run() method should stop ... Thread thread = this.runningThread.getAndSet(null); if (thread != null) { try { latch.await(Long.valueOf(System.getProperty(WAIT_FOR_COMPLETION_BEFORE_INTERRUPT_PROP, Long.toString(WAIT_FOR_COMPLETION_BEFORE_INTERRUPT_DEFAULT.toMillis()))), TimeUnit.MILLISECONDS); } catch (InterruptedException e) { } logger.debug("Interruping the embedded engine's thread " + thread + " (already interrupted: " + thread.isInterrupted() + ")"); // Interrupt the thread in case it is blocked while polling the task for records ... thread.interrupt(); return true; } return false; }
protected void await(long timeout, TimeUnit unit) throws InterruptedException { if (!latch.await(timeout, unit)) { fail("Consumer is still expecting " + latch.getCount() + " records, as it received only " + records.size()); } } }
@Override public void await() throws InterruptedException { latch.await(); }
@Override public void await(long timeout, TimeUnit unit) throws InterruptedException { latch.await(timeout, unit); }
protected void await(long timeout, TimeUnit unit) throws InterruptedException { if (!latch.await(timeout, unit)) { fail("Consumer is still expecting " + latch.getCount() + " records, as it received only " + records.size()); } } }