Example usage for java.util.concurrent LinkedBlockingQueue LinkedBlockingQueue

List of usage examples for java.util.concurrent LinkedBlockingQueue LinkedBlockingQueue

Introduction

In this page you can find the example usage for java.util.concurrent LinkedBlockingQueue LinkedBlockingQueue.

Prototype

public LinkedBlockingQueue() 

Source Link

Document

Creates a LinkedBlockingQueue with a capacity of Integer#MAX_VALUE .

Usage

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  ava  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.ushahidi.swiftriver.core.dropqueue.MetadataResponseHandlerTest.java

@Before
public void setup() {
    dropsMap = new HashMap<String, RawDrop>();
    publishQueue = new LinkedBlockingQueue<RawDrop>();
    dropFilterQueue = new LinkedBlockingQueue<String>();
    deliveryFramesMap = new ConcurrentHashMap<String, DeliveryFrame>();

    metadataResponseHandler = new MetadataResponseHandler();
    metadataResponseHandler.setDropsMap(dropsMap);
    metadataResponseHandler.setObjectMapper(objectMapper);
    metadataResponseHandler.setPublishQueue(publishQueue);
    metadataResponseHandler.setDropFilterQueue(dropFilterQueue);
    metadataResponseHandler.setDeliveryFramesMap(deliveryFramesMap);
}

From source file:com.aboveware.common.crouton.Manager.java

private Manager() {
    croutonQueue = new LinkedBlockingQueue<Crouton>();
}

From source file:dk.statsbiblioteket.doms.radiotv.extractor.transcoder.ProcessorChainThreadPool.java

/**
 * Singleton./*from w w w. j  a  v  a2 s .c  om*/
 */
private ProcessorChainThreadPool(ServletConfig config) {
    theQueue = new LinkedBlockingQueue<ProcessorChainThread>();
    //theQueue = new PriorityBlockingQueue(1000, new ThreadComparator());
    maxActiveProcesses = Integer.parseInt(Util.getInitParameter(config, Constants.MAX_ACTIVE_PROCESSING));
    log.info("Creating thread pool with max active processes = " + maxActiveProcesses);
    thePool = new GenericObjectPool(new BasePoolableObjectFactory() {
        @Override
        public Object makeObject() throws Exception {
            return new Object();
        }
    }, maxActiveProcesses);
}

From source file:com.cloudera.flume.handlers.endtoend.AckDistributor.java

public AckDistributor() {
    this.ackQueue = new LinkedBlockingQueue<EventAck>();
    this.clients = new HashMap<String, ServiceClient>();
}

From source file:se.vgregion.pubsub.push.impl.PushTest.java

@Test
@Transactional // TODO remove
public void test() throws InterruptedException {
    final URI testUri = URI.create("http://feeds.feedburner.com/protocol7/main");

    PubSubEngine pubSubEngine = applicationContext.getBean(PubSubEngine.class);

    final LinkedBlockingQueue<Feed> publishedFeeds = new LinkedBlockingQueue<Feed>();

    pubSubEngine.subscribe(new Subscriber() {

        @Override//w  w w  . j  av a2s . c om
        public void timedOut() {
        }

        @Override
        public void publish(Feed feed, PushJms pushJms) throws PublicationFailedException {
            publishedFeeds.add(feed);
        }

        @Override
        public URI getTopic() {
            return testUri;
        }

        @Override
        public DateTime getTimeout() {
            return null;
        }

        @Override
        public DateTime getLastUpdated() {
            return null;
        }
    });

    //        pubSubEngine.getOrCreateTopic(testUri).addSubscriber(new DefaultPushSubscriber(
    //                applicationContext.getBean(PushSubscriberRepository.class),
    //                testUri, URI.create("http://localhost:9000"), 100, "verify"));

    PushSubscriberManager pushSubscriberManager = applicationContext.getBean(PushSubscriberManager.class);
    pushSubscriberManager.retrive(testUri);

    Feed feed = publishedFeeds.poll(10000, TimeUnit.MILLISECONDS);

    //        Thread.sleep(200000);
}

From source file:com.heartbuffer.pipette.input.FileInput.java

public FileInput(FileInputConfig inputConfig, PipetteConfig config) throws IOException, GrokException {
    super(config, inputConfig.getGrokPattern());
    outputQueue = new LinkedBlockingQueue<String>();
    fileTailer = Tailer.create(new File(inputConfig.getFilepath()), this, inputConfig.getCheckDelayInMillis(),
            !inputConfig.isFromBeginning());
}

From source file:org.zenoss.app.consumer.metric.impl.MetricsQueue.java

MetricsQueue() {
    this.queue = new LinkedBlockingQueue<>();
    this.perClientBacklog = AtomicLongMap.create();
    this.totalErrorsMetric = Metrics.newCounter(errorsMetricName());
    this.totalInFlightMetric = Metrics.newCounter(inFlightMetricName());
    this.totalClientCountMetric = Metrics.newGauge(clientCountMetricName(), new Gauge<Long>() {
        @Override// w  w w .java 2s.  com
        public Long value() {
            return clientCount();
        }
    });
    this.totalIncomingMetric = registerIncoming();
    this.totalOutGoingMetric = registerOutgoing();
    this.totalReceivedMetric = registerReceived();
    this.totalRejectedMetric = registerRejected();
    this.totalLostMetric = registerLost();
    this.totalHighCollisionMetric = registerHighCollision();
    this.totalLowCollisionMetric = registerLowCollision();
    this.totalClientCollisionMetric = registerClientCollision();
    this.totalBroadcastHighCollisionMetric = registerBroadcastHighCollision();
    this.totalBroadcastLowCollisionMetric = registerBroadcastLowCollision();
    this.totalSentClientCollisionMetric = registerSentClientCollision();
    this.recentClientIds = CacheBuilder.newBuilder().expireAfterAccess(60, TimeUnit.SECONDS)
            .build(CacheLoader.from(YEPYEP));
}

From source file:cc.osint.graphd.server.GraphCommandExecutor.java

public GraphCommandExecutor(String graphName, WeakReference<Graph> graphRef) {
    this.graphName = graphName;
    this.graphRef = graphRef;
    graphCommandQueue = new LinkedBlockingQueue<GraphCommand>();
    log.info("start: GraphCommandExecutor(" + this.graphName + ")");
}

From source file:com.cloudera.branchreduce.impl.distributed.Worker.java

public Worker(int workerId, TaskMasterProxy<T, G> taskMaster, BranchReduceJob<T, G> job) {
    this.workerId = workerId;
    this.taskMaster = taskMaster;
    this.job = job;
    this.processor = job.constructProcessor();
    this.tasks = new LinkedBlockingQueue<T>();
}