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;
}
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;
}
}
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();
}
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);
}
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);
}
Aggregations