Examples of DbTxn


Examples of com.sleepycat.db.DbTxn

    public void testNested()
        throws Exception {

        assertNull(currentTxn.getTxn());

        DbTxn txn1 = currentTxn.beginTxn();
        assertNotNull(txn1);
        assertTrue(txn1 == currentTxn.getTxn());

        assertNull(map.get(ONE));
        assertNull(map.put(ONE, ONE));
        assertEquals(ONE, map.get(ONE));

        DbTxn txn2 = currentTxn.beginTxn();
        assertNotNull(txn2);
        assertTrue(txn2 == currentTxn.getTxn());
        assertTrue(txn1 != txn2);

        assertNull(map.put(TWO, TWO));
        assertEquals(TWO, map.get(TWO));

        DbTxn txn3 = currentTxn.beginTxn();
        assertNotNull(txn3);
        assertTrue(txn3 == currentTxn.getTxn());
        assertTrue(txn1 != txn2);
        assertTrue(txn1 != txn3);
        assertTrue(txn2 != txn3);

        assertNull(map.put(THREE, THREE));
        assertEquals(THREE, map.get(THREE));

        DbTxn txn = currentTxn.abortTxn();
        assertTrue(txn == txn2);
        assertTrue(txn == currentTxn.getTxn());
        assertNull(map.get(THREE));
        assertEquals(TWO, map.get(TWO));
View Full Code Here

Examples of com.sleepycat.db.DbTxn

        assertNull(currentTxn.getTxn());

        runner.run(new TransactionWorker() {
            public void doWork() throws Exception {
                final DbTxn txn1 = currentTxn.getTxn();
                assertNotNull(txn1);
                assertNull(map.put(ONE, ONE));
                assertEquals(ONE, map.get(ONE));

                runner.run(new TransactionWorker() {
                    public void doWork() throws Exception {
                        final DbTxn txn2 = currentTxn.getTxn();
                        assertNotNull(txn2);
                        assertTrue(txn1 != txn2);
                        assertNull(map.put(TWO, TWO));
                        assertEquals(TWO, map.get(TWO));
                        assertEquals(ONE, map.get(ONE));
                        if (explicit) currentTxn.commitTxn();
                    }
                });

                DbTxn txn3 = currentTxn.getTxn();
                assertSame(txn1, txn3);

                assertEquals(TWO, map.get(TWO));
                assertEquals(ONE, map.get(ONE));
            }
View Full Code Here

Examples of com.sleepycat.db.DbTxn

        assertNull(currentTxn.getTxn());

        runner.run(new TransactionWorker() {
            public void doWork() throws Exception {
                final DbTxn txn1 = currentTxn.getTxn();
                assertNotNull(txn1);
                assertNull(map.put(ONE, ONE));
                assertEquals(ONE, map.get(ONE));

                try {
                    runner.run(new TransactionWorker() {
                        public void doWork() throws Exception {
                            final DbTxn txn2 = currentTxn.getTxn();
                            assertNotNull(txn2);
                            assertTrue(txn1 != txn2);
                            assertNull(map.put(TWO, TWO));
                            assertEquals(TWO, map.get(TWO));
                            if (explicit)
                                currentTxn.abortTxn();
                            else
                                throw new IllegalArgumentException(
                                                                "test-abort");
                        }
                    });
                    assertTrue(explicit);
                } catch (IllegalArgumentException e) {
                    assertTrue(!explicit);
                    assertEquals("test-abort", e.getMessage());
                }

                DbTxn txn3 = currentTxn.getTxn();
                assertSame(txn1, txn3);

                assertEquals(ONE, map.get(ONE));
                assertNull(map.get(TWO));
            }
View Full Code Here

Examples of com.sleepycat.db.DbTxn

        if (currentTxn != null) { // if environment is transactional
            boolean dr = dirtyRead; // these values should not be changed
            boolean nw = noWait;    // until this method returns
            for (int i = 0;; i += 1) {
                DbTxn txn = null;
                try {
                    txn = currentTxn.beginTxn(dr, nw);
                    worker.doWork();
                    if (txn != null && txn == currentTxn.getTxn())
                        currentTxn.commitTxn();
View Full Code Here

Examples of com.sleepycat.db.DbTxn

                } else {
                    pos = Db.DB_NOOVERWRITE;
                }
                flags = pos | (flags & DataDb.FLAGS_MOD_MASK);
            }
            DbTxn txn = currentTxn();
            if (txn != null || !transactional)
                flags &= ~Db.DB_AUTO_COMMIT;
            int err = db.put(txn, key, data, flags);
            return err;
        }
View Full Code Here

Examples of com.sleepycat.db.DbTxn

            String database, int openFlags)
        throws FileNotFoundException, DbException {

        this.env = DataEnvironment.getEnvironment(env);

        DbTxn txn = this.env.getTxn();
        if (txn != null)
            openFlags &= ~Db.DB_AUTO_COMMIT;

        // open the catalog database
View Full Code Here

Examples of com.sleepycat.db.DbTxn

        if (noWait) flags |= Db.DB_TXN_NOWAIT;

        Trans trans = (Trans) currentTrans.get();
        if (trans != null) {
            if (trans.txn != null) {
                DbTxn parentTxn = trans.txn;
                trans = new Trans(trans, dirtyRead, noWait);
                trans.txn = dbEnv.txnBegin(parentTxn, flags);
                currentTrans.set(trans);
            } else {
                trans.txn = dbEnv.txnBegin(null, flags);
View Full Code Here

Examples of com.sleepycat.db.DbTxn

    public final DbTxn commitTxn()
        throws DbException, IllegalStateException {

        Trans trans = (Trans) currentTrans.get();
        if (trans != null && trans.txn != null) {
            DbTxn parent = closeTxn(trans);
            trans.txn.commit(0);
            return parent;
        } else {
            throw new IllegalStateException("No transaction is active");
        }
View Full Code Here

Examples of com.sleepycat.db.DbTxn

    public final DbTxn abortTxn()
        throws DbException, IllegalStateException {

        Trans trans = (Trans) currentTrans.get();
        if (trans != null && trans.txn != null) {
            DbTxn parent = closeTxn(trans);
            trans.txn.abort();
            return parent;
        } else {
            throw new IllegalStateException("No transaction is active");
        }
View Full Code Here

Examples of com.sleepycat.db.DbTxn

        }
    }


    public void removeMessage(MessageAck ack) throws JMSException {
        DbTxn transaction = null;
        String messageID = ack.getMessageID();
        try {
            database.delete(BDbHelper.getTransaction(), createKey(messageID), 0);
        }
        catch (DbException e) {
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.