List of usage examples for java.util.concurrent BlockingQueue clear
void clear();
From source file:com.espertech.esper.core.thread.ThreadingServiceImpl.java
private void stopPool(ThreadPoolExecutor threadPool, BlockingQueue<Runnable> queue, String name) { if (log.isInfoEnabled()) { log.info("Shutting down pool " + name); }//from w w w . ja v a 2s. c o m queue.clear(); threadPool.shutdown(); try { threadPool.awaitTermination(10, TimeUnit.SECONDS); } catch (InterruptedException e) { log.error("Interruped awaiting termination", e); } }
From source file:org.jboss.as.test.integration.logging.syslog.SyslogHandlerTestCase.java
/** * Tests that only messages on specific level or higher level are logged to syslog. *///from ww w . j a v a 2 s . co m @Test public void testLogOnSpecificLevel() throws Exception { final BlockingQueue<SyslogServerEventIF> queue = BlockedSyslogServerEventHandler.getQueue(); executeOperation(Operations.createWriteAttributeOperation(SYSLOG_HANDLER_ADDR, "level", "ERROR")); queue.clear(); makeLogs(); testLog(queue, Level.ERROR); testLog(queue, Level.FATAL); Assert.assertTrue("No other message was expected in syslog.", queue.isEmpty()); }
From source file:org.jboss.as.test.integration.logging.syslog.SyslogHandlerTestCase.java
/** * Tests that messages on all levels are logged, when level="TRACE" in syslog handler. */// w w w .j a va 2s. com @Test public void testAllLevelLogs() throws Exception { final BlockingQueue<SyslogServerEventIF> queue = BlockedSyslogServerEventHandler.getQueue(); executeOperation(Operations.createWriteAttributeOperation(SYSLOG_HANDLER_ADDR, "level", "TRACE")); queue.clear(); makeLogs(); for (Level level : LoggingServiceActivator.LOG_LEVELS) { testLog(queue, level); } Assert.assertTrue("No other message was expected in syslog.", queue.isEmpty()); }
From source file:org.apache.camel.impl.DefaultServicePool.java
protected void doStop() throws Exception { if (log.isDebugEnabled()) { log.debug("Stopping service pool: " + this); }//from w ww . j a v a2 s. co m for (BlockingQueue<Service> entry : pool.values()) { Collection<Service> values = new ArrayList<Service>(); entry.drainTo(values); ServiceHelper.stopServices(values); entry.clear(); } pool.clear(); }
From source file:org.opencastproject.videosegmenter.impl.VideoSegmenterServiceImpl.java
/** * Fills the look ahead buffer with the next <code>STABILITY_THRESHOLD</code> images. * // w w w. j a va 2 s .c om * @param queue * the buffer * @param currentBuffer * the current buffer * @param dsh * the data source handler * @throws IOException * if reading from the data source fails */ private void fillLookAheadBuffer(BlockingQueue<Buffer> queue, Buffer currentBuffer, FrameGrabber dsh) throws IOException { queue.clear(); queue.add(currentBuffer); for (int i = 0; i < stabilityThreshold - 1; i++) { Buffer b = dsh.getBuffer(); if (b != null && !b.isEOM()) queue.add(b); else return; } }