Package edu.emory.mathcs.backport.java.util.concurrent

Examples of edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch


            appendInProgress = true;
        }
       
       
        if( force && writeDoneCountDownLatch==null)
            writeDoneCountDownLatch = new CountDownLatch(1);
       
        record.read(packet);

        // if we fit the record in this batch
        if ( !record.hasRemaining() ) {
View Full Code Here


                new Property("operation", toAny(DRINKING_COFFEE_ID)),
                new Property("name", toAny("alphonse")), new Property("minutes", toAny(10)) });

        _event.setAny(_any);

        final CountDownLatch _hasReceived = new CountDownLatch(1);

        // setup mock
        MockCoffee _mockCoffee = new MockCoffee()
        {
            public void drinking_coffee(String name, int minutes)
            {
                super.drinking_coffee(name, minutes);

                assertEquals("alphonse", name);
                assertEquals(10, minutes);

                _hasReceived.countDown();
            }
        };

        _mockCoffee.drinking_coffee_expect = 1;

        // setup and connect consumer
        final Coffee _coffee = _mockCoffee._this(getClientORB());

        MockTypedPushConsumer _mockConsumer = new MockTypedPushConsumer()
        {
            public org.omg.CORBA.Object get_typed_consumer()
            {
                return _coffee;
            }
        };

        TypedPushConsumer _consumer = _mockConsumer._this(getClientORB());

        proxyPushSupplier_.connect_typed_push_consumer(_consumer);

        // run test
        objectUnderTest_.getMessageConsumer().queueMessage(_event.getHandle());

        assertTrue(_hasReceived.await(5000, TimeUnit.MILLISECONDS));

        // verify results
        _mockCoffee.verify();
    }
View Full Code Here

                _objectAsString));

        final StringHolder _name = new StringHolder();
        final IntHolder _minutes = new IntHolder();

        final CountDownLatch _latch = new CountDownLatch(1);

        new Thread()
        {
            public void run()
            {
                _pullCoffee.drinking_coffee(_name, _minutes);
                _latch.countDown();
            }
        }.start();

        objectUnderTest_.getMessageConsumer().queueMessage(_mesg.getHandle());

        assertTrue(_latch.await(1000, TimeUnit.MICROSECONDS));

        assertEquals("jacorb", _name.value);
        assertEquals(10, _minutes.value);
    }
View Full Code Here

            for (int x = 0; x < data.length; ++x)
            {
                data[x] = testUtils_.getStructuredEvent();
            }
           
            final CountDownLatch latch = new CountDownLatch(1);
            new Thread()
            {
                public void run()
                {
                    System.out.println("Begin to send");

                    try
                    {
                        sender.pushEvents(data);
                    } catch (Disconnected e)
                    {
                        active.set(false);
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                    System.out.println("Sent " + data.length);

                    latch.countDown();
                }
            }.start();

            latch.await();

            System.out.println(receiver);

            Thread.sleep(60000);
View Full Code Here

        structuredEvent_.header.variable_header[0] = new Property(StartTime.value, _startTimeAny);

        final Message _event = messageFactory_.newMessage(structuredEvent_, proxyConsumerMock_);

        final CountDownLatch _latch = new CountDownLatch(1);

        // TODO check if MockTaskProcessor can be used here
        final DefaultTaskFactory _defaultTaskFactory = new DefaultTaskFactory(getConfiguration());
        addDisposable(_defaultTaskFactory);
        DefaultTaskProcessor _taskProcessor = new DefaultTaskProcessor(getConfiguration(), _defaultTaskFactory)
        {
            public void processMessageInternal(Message event)
            {
                try
                {
                    long _recvTime = System.currentTimeMillis();
                    assertEquals(event, _event);
                    assertTrue(_recvTime >= _startTime.getTime());

                    failed.set(false);
                } finally
                {
                    _latch.countDown();
                }
            }
        };

        _taskProcessor.processMessage(_event);

        _latch.await();

        assertFalse(failed.get());

        _taskProcessor.dispose();
    }
View Full Code Here

    {
        final AnyMessage mesg = new AnyMessage();

        final AtomicBoolean received = new AtomicBoolean(false);
        final AtomicBoolean delivered = new AtomicBoolean(false);
        final CountDownLatch threadsDone = new CountDownLatch(1);
        final CountDownLatch getPutOrder = new CountDownLatch(1);
        final AtomicReference getException = new AtomicReference(null);
        final AtomicReference putException = new AtomicReference(null);

        final CyclicBarrier barrier = new CyclicBarrier(2, new Runnable()
        {
            public void run()
            {
                threadsDone.countDown();
            }
        });

        Runnable getCommand = new Runnable()
        {
            public void run()
            {
                try
                {
                    synchronized (lock_)
                    {
                        getPutOrder.countDown();
                        objectUnderTest_.getMessageBlocking();
                    }

                    received.set(true);
                } catch (Exception e)
                {
                    getException.set(e);
                }
                finally
                {
                    try
                    {
                        barrier.await();
                    } catch (InterruptedException e)
                    {
                        // ignored
                    } catch (BrokenBarrierException e)
                    {
                        // should not happen
                        e.printStackTrace();
                    }
                }
            }
        };

        Runnable putCommand = new Runnable()
        {
            public void run()
            {
                try
                {
                    getPutOrder.await();

                    objectUnderTest_.enqeue(mesg.getHandle());

                    delivered.set(true);
                } catch (Exception e)
View Full Code Here

    public void testSendPushPush_MisbehavingConsumer() throws Exception
    {
        StructuredPushSender _sender = getPushSender();

        final CountDownLatch disconnectedLatch = new CountDownLatch(1);
       
        StructuredPushReceiver _receiver = new StructuredPushReceiver(getClientORB())
        {
            public void push_structured_event(StructuredEvent event)
            {
                throw new TRANSIENT();
            }
           
            public void disconnect_structured_push_consumer()
            {
                super.disconnect_structured_push_consumer();
               
                disconnectedLatch.countDown();
            }
        };

        _sender.connect(channel_, false);
        _receiver.connect(channel_, false);

        _receiver.start();
        _sender.start();

        _sender.join();
        _receiver.join();

        assertTrue(disconnectedLatch.await(20000, TimeUnit.MILLISECONDS));

        assertFalse(_receiver.isConnected());
    }
View Full Code Here

                      }
                  }
                 
                    localBridgeStarted.set(false);
                    remoteBridgeStarted.set(false);
                    startedLatch = new CountDownLatch(2);
                }
               
            }
   
            public void transportResumed(){               
View Full Code Here

     * @param msgContext the message context
     * @return an object that implements the service
     * @throws AxisFault if fails
     */
    protected static Object makeNewServiceObject(MessageContext msgContext) throws AxisFault {
        CountDownLatch startLatch = new CountDownLatch(1);
        CountDownLatch stopLatch = new CountDownLatch(1);
        EJBClientWorker worker = new EJBClientWorker(msgContext, startLatch, stopLatch);
        workerPool.execute(worker);
        startLatch.countDown();
        try {
            stopLatch.await();
        } catch (InterruptedException e) {
            throw AxisFault.makeFault(e);
        }

        if (worker.getException() != null) {
View Full Code Here

TOP

Related Classes of edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.