private void addToStream(PartialResultSet results) { // We assume that nothing from the user will interrupt gRPC event threads. Uninterruptibles.putUninterruptibly(stream, results); }
private void put(PooledSession session) { Uninterruptibles.putUninterruptibly(waiter, new SessionOrError(session)); }
private void put(SpannerException e) { Uninterruptibles.putUninterruptibly(waiter, new SessionOrError(e)); }
/** Perform a {@code put} and assert that operation completed in the expected timeframe. */ void putSuccessfully() { putUninterruptibly(queue, ""); completed.assertCompletionExpected(); assertEquals("", queue.peek()); }
public void testPutWithNoWait() { Stopwatch stopwatch = Stopwatch.createStarted(); BlockingQueue<String> queue = new ArrayBlockingQueue<>(999); putUninterruptibly(queue, ""); assertTimeNotPassed(stopwatch, LONG_DELAY_MS); assertEquals("", queue.peek()); }
@Override protected void triggerShutdown() { // Force the thread to wake up. Uninterruptibles.putUninterruptibly(jobQueue, new Runnable() { public void run() { } }); }
private void pushQueue(int queueNum, Bundle item) { BlockingQueue<Bundle> queue = queues[queueNum]; Uninterruptibles.putUninterruptibly(queue, item); }
private void addToStream(PartialResultSet results) { // We assume that nothing from the user will interrupt gRPC event threads. Uninterruptibles.putUninterruptibly(stream, results); }
private void triggerConnections() { // Run on a background thread due to the need to potentially retry and back off in the background. Uninterruptibles.putUninterruptibly(jobQueue, triggerConnectionsJob); }
private void queueRecalc(boolean andTransmit) { if (andTransmit) { log.info("Queuing recalc of the Bloom filter due to new keys or scripts becoming available"); Uninterruptibles.putUninterruptibly(jobQueue, bloomSendIfChanged); } else { log.info("Queuing recalc of the Bloom filter due to observing a pay to pubkey output on a relevant tx"); Uninterruptibles.putUninterruptibly(jobQueue, bloomDontSend); } }
@Override public void execute(Runnable command) { final int size = tasks.size(); if (size == WARNING_THRESHOLD) { log.warn( "User thread has {} pending tasks, memory exhaustion may occur.\n" + "If you see this message, check your memory consumption and see if it's problematic or excessively spikey.\n" + "If it is, check for deadlocked or slow event handlers. If it isn't, try adjusting the constant \n" + "Threading.UserThread.WARNING_THRESHOLD upwards until it's a suitable level for your app, or Integer.MAX_VALUE to disable." , size); } Uninterruptibles.putUninterruptibly(tasks, command); } }
@Override public void execute(Runnable command) { final int size = tasks.size(); if (size == WARNING_THRESHOLD) { log.warn( "User thread has {} pending tasks, memory exhaustion may occur.\n" + "If you see this message, check your memory consumption and see if it's problematic or excessively spikey.\n" + "If it is, check for deadlocked or slow event handlers. If it isn't, try adjusting the constant \n" + "Threading.UserThread.WARNING_THRESHOLD upwards until it's a suitable level for your app, or Integer.MAX_VALUE to disable." , size); } Uninterruptibles.putUninterruptibly(tasks, command); } }
@Override public void execute(Runnable command) { final int size = tasks.size(); if (size == WARNING_THRESHOLD) { log.warn( "User thread has {} pending tasks, memory exhaustion may occur.\n" + "If you see this message, check your memory consumption and see if it's problematic or excessively spikey.\n" + "If it is, check for deadlocked or slow event handlers. If it isn't, try adjusting the constant \n" + "Threading.UserThread.WARNING_THRESHOLD upwards until it's a suitable level for your app, or Integer.MAX_VALUE to disable." , size); } Uninterruptibles.putUninterruptibly(tasks, command); } }
@Override public void execute(Runnable command) { final int size = tasks.size(); if (size == WARNING_THRESHOLD) { log.warn( "User thread has {} pending tasks, memory exhaustion may occur.\n" + "If you see this message, check your memory consumption and see if it's problematic or excessively spikey.\n" + "If it is, check for deadlocked or slow event handlers. If it isn't, try adjusting the constant \n" + "Threading.UserThread.WARNING_THRESHOLD upwards until it's a suitable level for your app, or Integer.MAX_VALUE to disable." , size); } Uninterruptibles.putUninterruptibly(tasks, command); } }
@Override public void execute(Runnable command) { if (tasks.size() > 100) { log.warn("User thread saturated, memory exhaustion may occur."); log.warn("Check for deadlocked or slow event handlers. Sample tasks:"); for (Object task : tasks.toArray()) log.warn(task.toString()); } Uninterruptibles.putUninterruptibly(tasks, command); } }
@VisibleForTesting void waitForJobQueue() { final CountDownLatch latch = new CountDownLatch(1); Uninterruptibles.putUninterruptibly(jobQueue, new Runnable() { @Override public void run() { latch.countDown(); } }); Uninterruptibles.awaitUninterruptibly(latch); }
private void put(PooledSession session) { Uninterruptibles.putUninterruptibly(waiter, new SessionOrError(session)); }
private void put(SpannerException e) { Uninterruptibles.putUninterruptibly(waiter, new SessionOrError(e)); }
/** * Perform a {@code put} and assert that operation completed in the expected * timeframe. */ void putSuccessfully() { putUninterruptibly(queue, ""); completed.assertCompletionExpected(); assertEquals("", queue.peek()); }
public void testPutWithNoWait() { Stopwatch stopwatch = Stopwatch.createStarted(); BlockingQueue<String> queue = new ArrayBlockingQueue<>(999); putUninterruptibly(queue, ""); assertTimeNotPassed(stopwatch, LONG_DELAY_MS); assertEquals("", queue.peek()); }