@Override public Record<T> read() throws Exception { return queue.take(); }
public void await() throws InterruptedException { if (done) return; while (next == null) { next = queue.take(); if (next == END_MARK) { next = null; // sentinel value to indicate the provider completed done = true; return; } } }
/** * Removes one envelope from the received messages queue or * blocks until one is available. */ public Envelope read() throws InterruptedException { return envelopes.take(); }
private void drainQueue() throws Exception { for (HttpUrl url; (url = queue.take()) != null; ) { if (!fetchedUrls.add(url)) { continue; } Thread currentThread = Thread.currentThread(); String originalName = currentThread.getName(); currentThread.setName("Crawler " + url.toString()); try { fetch(url); } catch (IOException e) { System.out.printf("XXX: %s %s%n", url, e); } finally { currentThread.setName(originalName); } } }
@Override public void run() { while (!mStopped) { try { AuditContext headContext = mAuditLogEntries.take(); AUDIT_LOG.info(headContext.toString()); } catch (InterruptedException e) { Thread.currentThread().interrupt(); break; } } } }
protected ReaderEvent getReaderEvent() throws IOException { try { ReaderEvent event = readerEvents.take(); Preconditions.checkNotNull(event); return event; } catch (InterruptedException ie) { throw new RuntimeException("Interrupted while getting readerEvents, not expected: " + ie.getMessage(), ie); } }
public ObjectContainer<T> take() throws InterruptedException { final ObjectContainer<T> ret = queue.take(); currentMemory.addAndGet(-ret.getSize()); return ret; }
public void run() { while (true) { try { ToSend m = sendqueue.take(); process(m); } catch (InterruptedException e) { break; } } }
public void assertEvent(Predicate<GobblinTrackingEvent> predicate, long timeout, TimeUnit timeUnit) throws TimeoutException, InterruptedException { GobblinTrackingEvent gte = timeout > 0 ? _events.poll(timeout, timeUnit) : _events.take(); if (null == gte) { throw new TimeoutException(); } if (!predicate.apply(gte)) { throw new AssertionError("Event predicate mismatch: " + gte); } }
public static Object takeMessage(int port) throws InterruptedException { return getQueue(port).take(); }
@Override public void doRun() { while (serverStatus.getLifecycle() != Lifecycle.HALTING) { try { messages.getIndexFailureQueue() .take() .forEach(indexFailureService::saveWithoutValidation); } catch (Exception e) { LOG.error("Could not persist index failure.", e); } } }
@Override public E take() throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); E result = super.take(); postRemove(result); this.stats.remove(); return result; }
public static Object takeMessage(int port) throws InterruptedException { readerArrived(port); return getQueue(port).take(); }
@Override public synchronized T take() throws InterruptedException { if (isEmpty()) { return super.take(); } else { T ret = Collections.min(this, (Comparator<? super T>) comparator); remove(ret); return ret; } }
@Override public void run() { try { RunnableCallback r = queue.take(); if (r == null) { return; } r.run(); e = r.error(); processInc(); } catch (InterruptedException e) { LOG.info("Interrupted when processing event."); } } }
@Override public void run() { Random rand = new Random(Thread.currentThread().getId()); try { while(true) { // If it is a read-only test, there will be no proposals.. if (!proposals.isEmpty()){ Request request = proposals.take(); Thread.sleep(5 + rand.nextInt(95)); commitProcessor.commit(request); } } } catch (InterruptedException e) { // ignore } }
public void realRun() throws InterruptedException { threadsStarted.await(); assertSame(one, q.take()); }}); }
/** * take retrieves elements in FIFO order */ public void testTake() throws InterruptedException { LinkedBlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { assertEquals(i, q.take()); } }
/** * An add following remove(x) succeeds */ public void testRemoveElementAndAdd() throws InterruptedException { LinkedBlockingQueue q = new LinkedBlockingQueue(); assertTrue(q.add(new Integer(1))); assertTrue(q.add(new Integer(2))); assertTrue(q.remove(new Integer(1))); assertTrue(q.remove(new Integer(2))); assertTrue(q.add(new Integer(3))); assertNotNull(q.take()); }
@Override public void run() { log.info(this.getServiceName() + " service started"); while (!this.isStopped()) { try { PullRequest pullRequest = this.pullRequestQueue.take(); this.pullMessage(pullRequest); } catch (InterruptedException ignored) { } catch (Exception e) { log.error("Pull Message Service Run Method exception", e); } } log.info(this.getServiceName() + " service end"); }