Package com.hazelcast.core

Examples of com.hazelcast.core.TransactionalQueue


        final String queueName = randomString();
        final IQueue queue = client.getQueue(queueName);

        final TransactionContext context = client.newTransactionContext();
        context.beginTransaction();
        TransactionalQueue txnQueue = context.getQueue(queueName);
        txnQueue.offer(item);
        assertEquals(item, txnQueue.poll());
        context.commitTransaction();
    }
View Full Code Here


        final String queueName = randomString();
        final IQueue queue = client.getQueue(queueName);

        final TransactionContext context = client.newTransactionContext();
        context.beginTransaction();
        TransactionalQueue txnQueue = context.getQueue(queueName);
        txnQueue.offer(item);
        txnQueue.poll();
        context.commitTransaction();

        assertEquals(0, queue.size());
    }
View Full Code Here

        }.start();


        final TransactionContext context = client.newTransactionContext();
        context.beginTransaction();
        TransactionalQueue txnQueue1 = context.getQueue(queueName);

        justBeforeBlocked.countDown();
        Object result = txnQueue1.poll(5, TimeUnit.SECONDS);

        assertEquals("TransactionalQueue while blocked in pol should get item offered from client queue", item, result);

        context.commitTransaction();
    }
View Full Code Here

        final String queunName = randomString();
        final IQueue queue = client.getQueue(queunName);

        final TransactionContext context = client.newTransactionContext();
        context.beginTransaction();
        TransactionalQueue txnQueue = context.getQueue(queunName);

        txnQueue.offer(item);
        assertEquals(item, txnQueue.peek());
        assertEquals(item, txnQueue.peek());

        context.commitTransaction();
    }
View Full Code Here

    @Override
    public Object innerCall() throws Exception {
        final ClientEndpoint endpoint = getEndpoint();
        final TransactionContext context = endpoint.getTransactionContext(txnId);
        final TransactionalQueue queue = context.getQueue(name);
        return queue.peek(timeout, TimeUnit.MILLISECONDS);
    }
View Full Code Here

    @Override
    public Object innerCall() throws Exception {
        final ClientEndpoint endpoint = getEndpoint();
        final TransactionContext context = endpoint.getTransactionContext(txnId);
        final TransactionalQueue queue = context.getQueue(name);
        return queue.offer(data, timeout, TimeUnit.MILLISECONDS);
    }
View Full Code Here

    @Override
    public Object innerCall() throws Exception {
        final ClientEndpoint endpoint = getEndpoint();
        final TransactionContext context = endpoint.getTransactionContext(txnId);
        final TransactionalQueue queue = context.getQueue(name);
        return queue.size();
    }
View Full Code Here

         Config config = new Config();
        config.getQueueConfig("default").setMaxSize(100);
        HazelcastInstance h = createHazelcastInstance(config);
        final TransactionContext transactionContext = h.newTransactionContext();
        transactionContext.beginTransaction();
        final TransactionalQueue q = transactionContext.getQueue("default");
        for (int i = 0; i < 100; i++) {
            q.offer(i);
        }
        boolean result = q.offer(100);
        assertEquals(100, q.size());
        transactionContext.commitTransaction();

        assertEquals(100, h.getQueue("default").size());
        assertFalse(result);
        h.shutdown();
View Full Code Here

        final HazelcastInstance instance1 = factory.newHazelcastInstance();
        final HazelcastInstance instance2 = factory.newHazelcastInstance();
        final TransactionContext context = instance1.newTransactionContext();
        context.beginTransaction();

        TransactionalQueue txnQ1 = context.getQueue("testQueueOfferCommitSize");
        TransactionalQueue txnQ2 = context.getQueue("testQueueOfferCommitSize");
        txnQ1.offer("item");
        assertEquals(1, txnQ1.size());
        assertEquals(1, txnQ2.size());
        context.commitTransaction();

        assertEquals(1, instance1.getQueue("testQueueOfferCommitSize").size());
        assertEquals(1, instance2.getQueue("testQueueOfferCommitSize").size());
        assertEquals("item", instance2.getQueue("testQueueOfferCommitSize").poll());
View Full Code Here

        final HazelcastInstance instance1 = factory.newHazelcastInstance();
        final HazelcastInstance instance2 = factory.newHazelcastInstance();
        final TransactionContext context = instance1.newTransactionContext();
        context.beginTransaction();

        TransactionalQueue txnQ1 = context.getQueue("testQueueOfferRollbackSize");
        TransactionalQueue txnQ2 = context.getQueue("testQueueOfferRollbackSize");

        txnQ1.offer("item");
        assertEquals(1, txnQ1.size());
        assertEquals(1, txnQ2.size());
        context.rollbackTransaction();
        assertEquals(0, instance1.getQueue("testQueueOfferRollbackSize").size());
        assertEquals(0, instance2.getQueue("testQueueOfferRollbackSize").size());
    }
View Full Code Here

TOP

Related Classes of com.hazelcast.core.TransactionalQueue

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.