Package com.hazelcast.core

Examples of com.hazelcast.core.IQueue.offer()


    @Test
    public void testOtherOperationCount() {
        IQueue queue = newQueue();
        for (int i = 0; i < 30; i++) {
            queue.offer("item" + i);
        }
        ArrayList<String> list = new ArrayList<String>();
        queue.drainTo(list);
        queue.addAll(list);
        queue.removeAll(list);
View Full Code Here


    }

    @Test
    public void testAge() {
        IQueue queue = newQueue();
        queue.offer("maxAgeItem");
        queue.offer("minAgeItem");

        LocalQueueStats stats = queue.getLocalQueueStats();
        long maxAge = stats.getMaxAge();
        long minAge = stats.getMinAge();
View Full Code Here

    @Test
    public void testAge() {
        IQueue queue = newQueue();
        queue.offer("maxAgeItem");
        queue.offer("minAgeItem");

        LocalQueueStats stats = queue.getLocalQueueStats();
        long maxAge = stats.getMaxAge();
        long minAge = stats.getMinAge();
        long testAge = (maxAge + minAge) / 2;
View Full Code Here

    public void testEventOperationCount() {
        IQueue queue = newQueue();
        TestListener listener = new TestListener(30);
        queue.addItemListener(listener, true);
        for (int i = 0; i < 30; i++) {
            queue.offer("item" + i);
        }
        for (int i = 0; i < 30; i++) {
            queue.poll();
        }
        LocalQueueStats stats = queue.getLocalQueueStats();
View Full Code Here

                        if(random > 65){
                            q.poll();
                            totalPoll.incrementAndGet();
                        }
                        else if(random > 30){
                            q.offer("item");
                            totalOffer.incrementAndGet();
                        }
                        else {
                            q.peek();
                            totalPeek.incrementAndGet();
View Full Code Here

        new Thread() {
            public void run() {
                try {
                    justBeforeBlocked.await();
                    sleepSeconds(1);
                    queue1.offer(item);
                } catch (InterruptedException e) {
                    fail("failed"+e);
                }
            }
        }.start();
View Full Code Here

    public void testTransactionalQueueSize() {
        final String item = "offered";
        final String name = randomString();
        final IQueue queue = client.getQueue(name);

        queue.offer(item);

        final TransactionContext context = client.newTransactionContext();
        context.beginTransaction();
        TransactionalQueue<String> txnQueue = context.getQueue(name);
View Full Code Here

        final DummyListener dummyListener = new DummyListener();
        final ItemListenerConfig itemListenerConfig = new ItemListenerConfig(dummyListener, true);
        queueConfig.addItemListenerConfig(itemListenerConfig);
        final HazelcastInstance instance = createHazelcastInstance(config);
        final IQueue queue = instance.getQueue(name);
        queue.offer("item");
        queue.poll();
        assertTrue(dummyListener.latch.await(10, TimeUnit.SECONDS));
    }

    private static class DummyListener implements ItemListener, Serializable {
View Full Code Here

        IQueue queue = instance.getQueue(name);
        TestItemListener listener = new TestItemListener(latch, notCalled);
        final String id = queue.addItemListener(listener, true);
        for (int i = 0; i < 10; i++) {
            queue.offer("item" + i);
        }
        for (int i = 0; i < 10; i++) {
            queue.poll();
        }
View Full Code Here

            queue.poll();
        }

        assertTrue(latch.await(5, TimeUnit.SECONDS));
        queue.removeItemListener(id);
        queue.offer("item-a");
        queue.poll();
        assertTrue(notCalled.get());
    }

    private static class TestItemListener implements ItemListener {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.