Package com.hazelcast.transaction

Examples of com.hazelcast.transaction.TransactionContext.commitTransaction()


    public <T> T executeTransaction(TransactionOptions options, TransactionalTask<T> task) throws TransactionException {
        final TransactionContext context = newTransactionContext(options);
        context.beginTransaction();
        try {
            final T value = task.execute(context);
            context.commitTransaction();
            return value;
        } catch (Throwable e) {
            context.rollbackTransaction();
            if (e instanceof TransactionException) {
                throw (TransactionException) e;
View Full Code Here


    @Override
    public Object innerCall() throws Exception {
        ClientEndpoint endpoint = getEndpoint();
        TransactionContext transactionContext = endpoint.getTransactionContext(txnId);
        if (prepareAndCommit) {
            transactionContext.commitTransaction();
        } else {
            Transaction transaction = TransactionAccessor.getTransaction(transactionContext);
            transaction.commit();
        }
        endpoint.removeTransactionContext(txnId);
View Full Code Here

                    }
                }
                // It's OK, I commit
                if (exchange.getException() == null && transactionCtx != null) {
                    log.trace("Commit transaction: {}", transactionCtx.getTxnId());
                    transactionCtx.commitTransaction();
                }
            } catch (InterruptedException e) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Hzlq Consumer Interrupted: " + e, e);
                }
View Full Code Here

                    DefaultExchangeHolder removedHolder = tCache.remove(key);
                    LOG.trace("Putting an exchange with ID {} for key {} into a recoverable storage in a thread-safe manner.",
                            exchange.getExchangeId(), key);
                    tPersistentCache.put(exchange.getExchangeId(), removedHolder);

                    tCtx.commitTransaction();
                    LOG.trace("Removed an exchange with ID {} for key {} in a thread-safe manner.", exchange.getExchangeId(), key);
                    LOG.trace("Put an exchange with ID {} for key {} into a recoverable storage in a thread-safe manner.",
                            exchange.getExchangeId(), key);
                } catch (Throwable throwable) {
                    tCtx.rollbackTransaction();
View Full Code Here

    public <T> T executeTransaction(TransactionOptions options, TransactionalTask<T> task) throws TransactionException {
        final TransactionContext context = newTransactionContext(options);
        context.beginTransaction();
        try {
            final T value = task.execute(context);
            context.commitTransaction();
            return value;
        } catch (Throwable e) {
            context.rollbackTransaction();
            if (e instanceof TransactionException) {
                throw (TransactionException) e;
View Full Code Here

            context.beginTransaction();

            TransactionalQueue<String> queue = context.getQueue("test");
            String queue_data = queue.poll();
            assertNotNull(queue_data);
            context.commitTransaction();
        }
    }

    static class MyQueueStore implements QueueStore, Serializable {
View Full Code Here

                        tx.beginTransaction();
                        TransactionalMultiMap<Object, Object> multiMap = tx.getMultiMap(name);
                        Collection<Object> values = multiMap.get(id);
                        assertFalse(values.isEmpty());
                        multiMap.remove(id);
                        tx.commitTransaction();
                    } catch (TransactionException e) {
                        tx.rollbackTransaction();
                        e.printStackTrace();
                    }
                } else {
View Full Code Here

                    try {
                        tx.beginTransaction();
                        TransactionalMultiMap<Object, Object> multiMap = tx.getMultiMap(name);
                        assertEquals(1, multiMap.valueCount(id));
                        multiMap.remove(id);
                        tx.commitTransaction();
                    } catch (TransactionException e) {
                        tx.rollbackTransaction();
                        e.printStackTrace();
                    }
                } else {
View Full Code Here

        final TransactionContext context = instance.newTransactionContext();
        context.beginTransaction();
        final TransactionalSet<Object> txnSet = context.getSet(setName);
        assertTrue(txnSet.add(ELEMENT));
        assertEquals(1, txnSet.size());
        context.commitTransaction();
        assertEquals(1, set.size());
    }

    @Test
    public void testSetSizeAfterAdd_withinTxn() throws Exception {
View Full Code Here

        final TransactionContext context = instance.newTransactionContext();
        context.beginTransaction();
        final TransactionalSet<Object> txnSet = context.getSet(setName);
        txnSet.add(ELEMENT);
        context.commitTransaction();
        assertEquals(1, set.size());
    }

    @Test
    public void testRemove_withinTxn() throws Exception {
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.