List of usage examples for java.util.concurrent BlockingQueue add
boolean add(E e);
From source file:org.artifactory.rest.servlet.ArtifactoryRestServlet.java
@SuppressWarnings({ "unchecked" }) @Override//from w w w . j a va2s . c om public void init(ServletConfig config) throws ServletException { this.config = config; BlockingQueue<Filter> waiters = (BlockingQueue<Filter>) config.getServletContext() .getAttribute(APPLICATION_CONTEXT_LOCK_KEY); if (waiters != null) { waiters.add(this); } else { //Servlet 2.5 lazy filter initing delayedInit(); } // register the bean utils converter to fail if encounters a type mismatch between the destination // and the original, see RTFACT-3610 BeanUtilsBean instance = BeanUtilsBean2.getInstance(); instance.getConvertUtils().register(true, false, 0); }
From source file:fi.jumi.core.suite.SuiteFactoryTest.java
@Test public void reports_uncaught_exceptions_from_actors_as_internal_errors() throws InterruptedException { createSuiteFactory();/*from w w w . j a v a 2 s .c o m*/ BlockingQueue<String> spy = new LinkedBlockingQueue<>(); factory.start(new NullSuiteListener() { @Override public void onInternalError(String message, StackTrace cause) { spy.add(message); } }); ActorThread actorThread = factory.actors.startActorThread(); ActorRef<Runnable> dummyActor = actorThread.bindActor(Runnable.class, () -> { throw new RuntimeException("dummy exception"); }); dummyActor.tell().run(); assertThat(spy.take(), startsWith("Uncaught exception in thread jumi-actor-")); }
From source file:com.ricston.connectors.dataanalysis.DataAnalysisConnector.java
/** * Collect for Analysis processor. Accepts a map of key performance indicators (KPIs) and stores * the data in a MapDb backed persisted queue. Data is enhanced with current time, and message id. * * {@sample.xml ../../../doc/dataanalysis-connector.xml.sample dataanalysis:collect-for-analysis} * * @param kpiName name for the key performance indicator * @param data Key value pairs of data to collect * @param messageId the message id// w ww . j a v a2 s . co m */ @Processor public void collectForAnalysis(String kpiName, Map<String, Object> data, @Expr("#[message.id]") String messageId) { data.put("kpiName", kpiName); data.put("type", "KPI"); data.put("messageId", messageId); data.put("application", application); data.put("@timestamp", new Date()); BlockingQueue<Map<String, Object>> queue = db.getStack(kpiName); queue.add(data); }
From source file:com.kurento.kmf.media.AbstractAsyncBaseTest.java
@Before public void abstractSetup() throws InterruptedException { final BlockingQueue<MediaPipeline> events = new ArrayBlockingQueue<MediaPipeline>(1); pipelineFactory.create(new Continuation<MediaPipeline>() { @Override/*from w w w . j a va 2 s . c o m*/ public void onSuccess(MediaPipeline result) { events.add(result); } @Override public void onError(Throwable cause) { throw new KurentoMediaFrameworkException(cause); } }); pipeline = events.poll(500, MILLISECONDS); if (pipeline == null) { Assert.fail(); } }
From source file:org.openscore.lang.systemtests.TriggerFlows.java
public ScoreEvent runSync(CompilationArtifact compilationArtifact, Map<String, ? extends Serializable> userInputs, Map<String, ? extends Serializable> systemProperties) { final BlockingQueue<ScoreEvent> finishEvent = new LinkedBlockingQueue<>(); ScoreEventListener finishListener = new ScoreEventListener() { @Override/*from w w w. ja va 2s.c om*/ public void onEvent(ScoreEvent event) throws InterruptedException { finishEvent.add(event); } }; slang.subscribeOnEvents(finishListener, FINISHED_EVENT); slang.run(compilationArtifact, userInputs, systemProperties); try { ScoreEvent event = finishEvent.take(); if (event.getEventType().equals(SLANG_EXECUTION_EXCEPTION)) { LanguageEventData languageEvent = (LanguageEventData) event.getData(); throw new RuntimeException((String) languageEvent.get(LanguageEventData.EXCEPTION)); } slang.unSubscribeOnEvents(finishListener); return event; } catch (InterruptedException e) { throw new RuntimeException(e); } }
From source file:org.libreplan.business.hibernate.notification.HibernateDatabaseModificationsListener.java
@Override public <T> IAutoUpdatedSnapshot<T> takeSnapshot(String name, Callable<T> callable, ReloadOn reloadOn) { if (!hibernateListenersRegistered) { throw new IllegalStateException( "The hibernate listeners has not been registered. There is some configuration problem."); }//from w w w .j a v a2 s. c om final NotBlockingAutoUpdatedSnapshot<T> result; result = new NotBlockingAutoUpdatedSnapshot<>(name, callable); for (Class<?> each : reloadOn.getClassesOnWhichToReload()) { interested.putIfAbsent(each, emptyQueue()); BlockingQueue<NotBlockingAutoUpdatedSnapshot<?>> queue = interested.get(each); boolean success = queue.add(result); assert success : "the type of queue used must not have restricted capacity"; } result.ensureFirstLoad(executor); return result; }
From source file:com.kurento.kmf.media.ZBarFilterTest.java
@Test public void testCodeFoundEvent() throws InterruptedException { PlayerEndpoint player = pipeline.newPlayerEndpoint(URL_BARCODES).build(); player.connect(zbar);/*w ww.j a va 2 s . com*/ final BlockingQueue<CodeFoundEvent> events = new ArrayBlockingQueue<CodeFoundEvent>(1); zbar.addCodeFoundListener(new MediaEventListener<CodeFoundEvent>() { @Override public void onEvent(CodeFoundEvent event) { events.add(event); } }); player.play(); Assert.assertNotNull(events.poll(7, TimeUnit.SECONDS)); player.stop(); player.release(); }
From source file:com.kurento.kmf.media.GStreamerFilterTest.java
@Test public void testInstantiation() throws InterruptedException { filter = pipeline.newGStreamerFilter("videoflip method=horizontal-flip").build(); Assert.assertNotNull(filter);/*from w w w . j av a 2 s . co m*/ player.connect(filter); final BlockingQueue<EndOfStreamEvent> eosEvents = new ArrayBlockingQueue<EndOfStreamEvent>(1); player.addEndOfStreamListener(new MediaEventListener<EndOfStreamEvent>() { @Override public void onEvent(EndOfStreamEvent event) { eosEvents.add(event); } }); player.play(); Assert.assertNotNull(eosEvents.poll(7, SECONDS)); filter.release(); }
From source file:com.kurento.kmf.media.FaceOverlayFilterTest.java
/** * Test if a {@link JackVaderFilter} can be created in the KMS. The filter * is pipelined with a {@link PlayerEndpoint}, which feeds video to the * filter. This test depends on the correct behaviour of the player and its * events./* ww w . java 2s .co m*/ * * @throws InterruptedException */ @Test public void testFaceOverlayFilter() throws InterruptedException { PlayerEndpoint player = pipeline.newPlayerEndpoint(URL_POINTER_DETECTOR).build(); player.connect(overlayFilter); final BlockingQueue<EndOfStreamEvent> events = new ArrayBlockingQueue<EndOfStreamEvent>(1); player.addEndOfStreamListener(new MediaEventListener<EndOfStreamEvent>() { @Override public void onEvent(EndOfStreamEvent event) { events.add(event); } }); player.play(); Assert.assertNotNull(events.poll(20, SECONDS)); player.stop(); player.release(); }
From source file:com.kurento.kmf.media.JackVaderFilterTest.java
/** * Test if a {@link JackVaderFilter} can be created in the KMS. The filter * is pipelined with a {@link PlayerEndpoint}, which feeds video to the * filter. This test depends on the correct behaviour of the player and its * events./* ww w . j a v a2 s . c o m*/ * * @throws InterruptedException */ @Test public void testJackVaderFilter() throws InterruptedException { PlayerEndpoint player = pipeline.newPlayerEndpoint(URL_SMALL).build(); player.connect(jackVader); final BlockingQueue<EndOfStreamEvent> events = new ArrayBlockingQueue<EndOfStreamEvent>(1); player.addEndOfStreamListener(new MediaEventListener<EndOfStreamEvent>() { @Override public void onEvent(EndOfStreamEvent event) { events.add(event); } }); player.play(); Assert.assertNotNull(events.poll(10, SECONDS)); player.stop(); player.release(); }