Search in sources :

Example 6 with Transaction

use of org.apache.derby.iapi.store.raw.Transaction in project derby by apache.

the class MergeSort method createMergeRun.

/**
 *	Remove all the rows from the sort buffer and store them
 *	in a temporary conglomerate.  The temporary conglomerate
 *	is a "merge run".  Returns the container id of the
 *	merge run.
 */
long createMergeRun(TransactionManager tran, SortBuffer sortBuffer) throws StandardException {
    // this sort buffer is not a scan and is not tracked by any
    // TransactionManager.
    SortBufferRowSource rowSource = new SortBufferRowSource(sortBuffer, (TransactionManager) null, sortObserver, true, sortBufferMax);
    // Create a temporary stream conglomerate...
    // get raw transaction
    Transaction rawTran = tran.getRawStoreXact();
    int segmentId = StreamContainerHandle.TEMPORARY_SEGMENT;
    long id = rawTran.addAndLoadStreamContainer(segmentId, properties, rowSource);
    // Don't close the sortBuffer, we just emptied it, the caller may reuse
    // that sortBuffer for the next run.
    rowSource = null;
    return id;
}
Also used : Transaction(org.apache.derby.iapi.store.raw.Transaction)

Example 7 with Transaction

use of org.apache.derby.iapi.store.raw.Transaction in project derby by apache.

the class MergeSort method dropMergeRuns.

/**
 *	Get rid of the merge runs, if there are any.
 *	Must not cause any errors because it's called
 *	during error processing.
 */
void dropMergeRuns(TransactionManager tran) {
    if (mergeRuns != null) {
        Enumeration<Long> e = mergeRuns.elements();
        try {
            Transaction rawTran = tran.getRawStoreXact();
            long segmentId = StreamContainerHandle.TEMPORARY_SEGMENT;
            while (e.hasMoreElements()) {
                long containerId = (e.nextElement()).longValue();
                rawTran.dropStreamContainer(segmentId, containerId);
            }
        } catch (StandardException se) {
        // Ignore problems with dropping, worst case
        // the raw store will clean up at reboot.
        }
        mergeRuns = null;
    }
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) Transaction(org.apache.derby.iapi.store.raw.Transaction)

Example 8 with Transaction

use of org.apache.derby.iapi.store.raw.Transaction in project derby by apache.

the class XactXAResourceManager method rollback.

/**
 * rollback the transaction identified by Xid.
 * <p>
 * The given transaction is roll'ed back and it's history is not
 * maintained in the transaction table or long term log.
 * <p>
 *
 * @param cm       The ContextManager returned from the find() call.
 * @param xid      A global transaction identifier.
 *
 * @exception  StandardException  Standard exception policy.
 */
public void rollback(ContextManager cm, Xid xid) throws StandardException {
    Transaction rawtran = rsf.findUserTransaction(cm, AccessFactoryGlobals.USER_TRANS_NAME);
    // the find() call and now.
    if (rawtran == null) {
        throw StandardException.newException(SQLState.STORE_XA_PROTOCOL_VIOLATION);
    }
    if (SanityManager.DEBUG) {
        SanityManager.ASSERT(new GlobalXactId(xid.getFormatId(), xid.getGlobalTransactionId(), xid.getBranchQualifier()).equals(rawtran.getGlobalId()));
    }
    rawtran.xa_rollback();
}
Also used : Transaction(org.apache.derby.iapi.store.raw.Transaction)

Example 9 with Transaction

use of org.apache.derby.iapi.store.raw.Transaction in project derby by apache.

the class XactXAResourceManager method commit.

/**
 ************************************************************************
 * Private/Protected methods of This class:
 **************************************************************************
 */
/**
 ************************************************************************
 * Public Methods implementing XAResourceManager interface
 **************************************************************************
 */
/**
 * This method is called to commit the global transaction specified by xid.
 * <p>
 * RESOLVE - how do we map to the "right" XAExceptions.
 * <p>
 *
 * @param cm       The ContextManager returned from the find() call.
 * @param xid      A global transaction identifier.
 * @param onePhase If true, the resource manager should use a one-phase
 *                 commit protocol to commit the work done on behalf of
 *                 xid.
 *
 * @exception  StandardException  Standard exception policy.
 */
public void commit(ContextManager cm, Xid xid, boolean onePhase) throws StandardException {
    Transaction rawtran = rsf.findUserTransaction(cm, AccessFactoryGlobals.USER_TRANS_NAME);
    // the find() call and now.
    if (rawtran == null) {
        throw StandardException.newException(SQLState.STORE_XA_PROTOCOL_VIOLATION);
    }
    if (SanityManager.DEBUG) {
        SanityManager.ASSERT(rawtran != null);
        SanityManager.ASSERT((new GlobalXactId(xid.getFormatId(), xid.getGlobalTransactionId(), xid.getBranchQualifier())).equals(rawtran.getGlobalId()));
    }
    rawtran.xa_commit(onePhase);
}
Also used : Transaction(org.apache.derby.iapi.store.raw.Transaction)

Example 10 with Transaction

use of org.apache.derby.iapi.store.raw.Transaction in project derby by apache.

the class RAMTransaction method getInternalTransaction.

/**
 * Get an Internal transaction.
 * <p>
 * Start an internal transaction.  An internal transaction is a completely
 * separate transaction from the current user transaction.  All work done
 * in the internal transaction must be physical (ie. it can be undone
 * physically by the rawstore at the page level, rather than logically
 * undone like btree insert/delete operations).  The rawstore guarantee's
 * that in the case of a system failure all open Internal transactions are
 * first undone in reverse order, and then other transactions are undone
 * in reverse order.
 * <p>
 * Internal transactions are meant to implement operations which, if
 * interupted before completion will cause logical operations like tree
 * searches to fail.  This special undo order insures that the state of
 * the tree is restored to a consistent state before any logical undo
 * operation which may need to search the tree is performed.
 * <p>
 *
 * @return The new internal transaction.
 *
 * @exception  StandardException  Standard exception policy.
 */
public TransactionManager getInternalTransaction() throws StandardException {
    // Get the context manager.
    ContextManager cm = getContextManager();
    // Allocate a new transaction no matter what.
    // Create a transaction, make a context for it, and push the context.
    // Note this puts the raw store transaction context
    // above the access context, which is required for
    // error handling assumptions to be correct.
    Transaction rawtran = accessmanager.getRawStore().startInternalTransaction(cm);
    RAMTransaction rt = new RAMTransaction(accessmanager, rawtran, null);
    RAMTransactionContext rtc = new RAMTransactionContext(cm, AccessFactoryGlobals.RAMXACT_INTERNAL_CONTEXT_ID, rt, true);
    rawtran.setDefaultLockingPolicy(accessmanager.getDefaultLockingPolicy());
    return (rt);
}
Also used : Transaction(org.apache.derby.iapi.store.raw.Transaction) ContextManager(org.apache.derby.iapi.services.context.ContextManager)

Aggregations

Transaction (org.apache.derby.iapi.store.raw.Transaction)13 ContextManager (org.apache.derby.iapi.services.context.ContextManager)2 ContainerHandle (org.apache.derby.iapi.store.raw.ContainerHandle)2 Page (org.apache.derby.iapi.store.raw.Page)2 StandardException (org.apache.derby.shared.common.error.StandardException)2 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)1 TransactionController (org.apache.derby.iapi.store.access.TransactionController)1 ContainerKey (org.apache.derby.iapi.store.raw.ContainerKey)1 RawStoreFactory (org.apache.derby.iapi.store.raw.RawStoreFactory)1 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)1 RowLocation (org.apache.derby.iapi.types.RowLocation)1 BTreeLockingPolicy (org.apache.derby.impl.store.access.btree.BTreeLockingPolicy)1 OpenBTree (org.apache.derby.impl.store.access.btree.OpenBTree)1