Package com.persistit

Examples of com.persistit.Transaction


        }
    }

    @Override
    public void rollbackTransactionIfOpen(Session session) {
        Transaction txn = getTransaction(session);
        if((txn != null) && txn.isActive()) {
            rollbackTransaction(session);
        }
    }
View Full Code Here


        return false;
    }

    @Override
    public boolean shouldPeriodicallyCommit(Session session) {
        Transaction txn = getTransaction(session);
        requireActive(txn);
        if(commitAfterMillis != NO_START_MILLIS) {
            long startMillis = session.get(START_MILLIS_KEY);
            long dt = System.currentTimeMillis() - startMillis;
            if(dt > commitAfterMillis) {
View Full Code Here

        });
    }

    @Override
    public <T> T run(Session session, Callable<T> callable) {
        Transaction oldTransaction = getTransaction(session);
        SessionId oldSessionId = null;
        Long oldStartMillis = null;
        if ((oldTransaction != null) &&
            // Anything that would prevent begin() from working.
            (oldTransaction.isActive() ||
             oldTransaction.isRollbackPending() ||
             oldTransaction.isCommitted())) {
            oldSessionId = treeService.getDb().getSessionId();
            treeService.getDb().setSessionId(new SessionId());
            session.remove(TXN_KEY);
            oldStartMillis = session.remove(START_MILLIS_KEY);
        }
View Full Code Here

    public void crash() {
        // None
    }

    private Transaction getTransaction(Session session) {
        Transaction txn = session.get(TXN_KEY); // Note: Assumes 1 session per thread
        if(txn == null) {
            txn = treeService.getDb().getTransaction();
            session.put(TXN_KEY, txn);
        }
        return txn;
View Full Code Here

    private void rollbackIfNeeded(Exception e) {
        if((e instanceof DuplicateKeyException) ||
           (e instanceof PersistitException) ||
           (e instanceof PersistitAdapterException) ||
           isFromInterruption(e)) {
            Transaction txn = transaction();
            if(txn.isActive()) {
                txn.rollback();
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.persistit.Transaction

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.