Java Code Examples for java.util.concurrent.DelayQueue#poll()
The following examples show how to use
java.util.concurrent.DelayQueue#poll() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UGICache.java From pxf with Apache License 2.0 | 6 votes |
/** * Iterate through all the entries in the queue and close expired {@link UserGroupInformation}, * otherwise it resets the timer for every non-expired entry. * * @param expirationQueue */ private void cleanup(DelayQueue<Entry> expirationQueue) { Entry expiredUGI; while ((expiredUGI = expirationQueue.poll()) != null) { if (expiredUGI.isNotInUse()) { closeUGI(expiredUGI); } else { // The UGI object is still being used by another thread String fsMsg = "FileSystem for proxy user = " + expiredUGI.getSession().getUser(); LOG.debug("{} Skipping close of {}", expiredUGI.getSession().toString(), fsMsg); // Place it back in the queue if still in use and was not closed expiredUGI.resetTime(); expirationQueue.offer(expiredUGI); } LOG.debug("Delay Queue Size for segment {} = {}", expiredUGI.getSession().getSegmentId(), expirationQueue.size()); } }
Example 2
Source File: DelayQueueTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * element returns next element, or throws NSEE if empty */ public void testElement() { DelayQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { assertEquals(new PDelay(i), q.element()); q.poll(); } try { q.element(); shouldThrow(); } catch (NoSuchElementException success) {} }
Example 3
Source File: DelayQueueTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * contains(x) reports true when elements added but not yet removed */ public void testContains() { DelayQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { assertTrue(q.contains(new PDelay(i))); q.poll(); assertFalse(q.contains(new PDelay(i))); } }
Example 4
Source File: DelayQueueTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * element returns next element, or throws NSEE if empty */ public void testElement() { DelayQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { assertEquals(new PDelay(i), q.element()); q.poll(); } try { q.element(); shouldThrow(); } catch (NoSuchElementException success) {} }
Example 5
Source File: DelayQueueTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * contains(x) reports true when elements added but not yet removed */ public void testContains() { DelayQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { assertTrue(q.contains(new PDelay(i))); q.poll(); assertFalse(q.contains(new PDelay(i))); } }