@Override public void onSuccess(SubTaskCompleteEvent<ParallelIndexSubTask> completeEvent) { // this callback is called if a task completed wheter it succeeded or not. taskCompleteEvents.offer(completeEvent); }
@Override public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException { return delegate().offer(e, timeout, unit); }
public boolean audit(String appId, String clusterName, String dataCenter, String ip, String configAppId, String configClusterName, String configNamespace, String releaseKey) { return this.audits.offer(new InstanceConfigAuditModel(appId, clusterName, dataCenter, ip, configAppId, configClusterName, configNamespace, releaseKey)); }
@Override public void onNext(Notification<T> args) { if (waiting.getAndSet(0) == 1 || !args.isOnNext()) { Notification<T> toOffer = args; while (!buf.offer(toOffer)) { Notification<T> concurrentItem = buf.poll(); // in case if we won race condition with onComplete/onError method if (concurrentItem != null && !concurrentItem.isOnNext()) { toOffer = concurrentItem; } } } }
@Override public void onNext(Notification<T> args) { if (waiting.getAndSet(0) == 1 || !args.isOnNext()) { Notification<T> toOffer = args; while (!buf.offer(toOffer)) { Notification<T> concurrentItem = buf.poll(); // in case if we won race condition with onComplete/onError method if (concurrentItem != null && !concurrentItem.isOnNext()) { toOffer = concurrentItem; } } } }
public void enqueue(OpentsdbEvent event) { if (!eventQueue.offer(event)) { if (countLostEvents.getAndIncrement() % 1000 == 0) { log.error( "Lost total of [%s] events because of emitter queue is full. Please increase the capacity.", countLostEvents.get() ); } } }
@Override public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException { return delegate().offer(e, timeout, unit); }
@Override protected void doAction() { assertTrue(queue.offer(EXPECTED_TAKE)); } }
@Override public void onNext(Notification<T> args) { if (waiting.getAndSet(0) == 1 || !args.isOnNext()) { Notification<T> toOffer = args; while (!buf.offer(toOffer)) { Notification<T> concurrentItem = buf.poll(); // in case if we won race condition with onComplete/onError method if (concurrentItem != null && !concurrentItem.isOnNext()) { toOffer = concurrentItem; } } } }
@Override public void onNext(Notification<T> args) { if (waiting.getAndSet(0) == 1 || !args.isOnNext()) { Notification<T> toOffer = args; while (!buf.offer(toOffer)) { Notification<T> concurrentItem = buf.poll(); // in case if we won race condition with onComplete/onError method if (concurrentItem != null && !concurrentItem.isOnNext()) { toOffer = concurrentItem; } } } }
@Override public void onFailure(Throwable t) { // this callback is called only when there were some problems in TaskMonitor. log.error(t, "Error while running a task for subTaskSpec[%s]", spec); taskCompleteEvents.offer(SubTaskCompleteEvent.fail(spec, t)); } }
private TimedPutQueue(long countdownInMillis) { this.queue = new ArrayBlockingQueue<>(1); assertTrue(queue.offer("blocksPutCallsUntilRemoved")); this.completed = new Completion(countdownInMillis); scheduleEnableWrites(this.queue, countdownInMillis); }
@Override public Boolean call() throws InterruptedException { while (!stopTest.get()) { q.poll(100, TimeUnit.MILLISECONDS); q.offer(new TestObject(2)); } return true; } }
public EnableWrites(BlockingQueue<String> queue, long tMinus) { super(tMinus); assertFalse(queue.isEmpty()); assertFalse(queue.offer("shouldBeRejected")); this.queue = queue; }
@Override public Boolean call() throws Exception { barrier.await(); Assert.assertTrue(q.offer(obj, delayMS, TimeUnit.MILLISECONDS)); Assert.assertEquals(q.remainingCapacity(), 0); barrier.await(); q.put(obj); return true; } }
public void testTakeWithNoWait() { Stopwatch stopwatch = Stopwatch.createStarted(); BlockingQueue<String> queue = new ArrayBlockingQueue<>(1); assertTrue(queue.offer("")); assertEquals("", takeUninterruptibly(queue)); assertTimeNotPassed(stopwatch, LONG_DELAY_MS); }
@Test public void testAddBiggerElementThanCapacityFails() { BlockingQueue<TestObject> q = getQueue(5); try { q.offer(new TestObject(10)); Assert.fail(); } catch (IllegalArgumentException success) { } }