public Object call() throws Exception { TXManagerImpl mgr = getGemfireCache().getTxManager(); TXStateInterface tx = mgr.internalSuspend(); assertNotNull(tx); mgr.resume(tx); mgr.commit(); TXManagerImpl.waitForPendingCommitForTest(); return null; } });
public Object call() throws Exception { Region<Object, Object> custRegion = getCache().getRegion(CUSTOMER); TXManagerImpl mgr = getGemfireCache().getTxManager(); TXStateInterface tx = mgr.getHostedTXState(txId2); // force expected transaction TXStateInterface txOrig = mgr.getTXState(); mgr.setTXState(tx); tx = mgr.internalSuspend(); assertNull(custRegion.get(expectedCustId)); mgr.resume(tx); assertEquals(expectedCustomer, custRegion.get(expectedCustId)); mgr.setTXState(txOrig); return null; } });
final TXContext setTXState(final TXStateInterface tx) { // the thread that created the TXStateInterface may be different from the // current thread so cannot rely on the context inside the TXStateProxy final TXContext context = getOrCreateTXContext(); setTXState(tx, context); return context; }
/** Roll back the transaction associated with the current * thread. When this method completes, the thread is no longer * associated with a transaction. */ public final void rollback() { rollback(getTXState(), null, false); }
public boolean tryResume(TransactionId transactionId) { if (transactionId == null || getTXState() != null) { return false; } TXStateProxy txProxy = this.suspendedTXs.remove(transactionId); if (txProxy != null) { resume(txProxy); return true; } return false; }
public Object call() throws Exception { Region custRegion = getCache().getRegion(CUSTOMER); TXManagerImpl mgr = getGemfireCache().getTxManager(); mgr.begin(); FunctionService.onRegion(custRegion).execute(TXFunction.id).getResult(); assertNotNull(mgr.getTXState()); TXStateInterface tx= mgr.internalSuspend(); assertNull(mgr.getTXState()); getGemfireCache().getLogger().fine("SWAP:callingget"); assertNull("expected null but was:" + custRegion.get(expectedCustId), custRegion.get(expectedCustId)); mgr.resume(tx); mgr.commit(); assertEquals(expectedCustomer, custRegion.get(expectedCustId)); return null; } });
public Object call() throws Exception { TXManagerImpl mgr = getGemfireCache().getTxManager(); TXStateInterface tx = mgr.internalSuspend(); assertNotNull(tx); mgr.resume(tx); mgr.commit(); return null; } });
public Object call() throws Exception { LocalRegion custRegion = (LocalRegion)getCache().getRegion(CUSTOMER); LocalRegion orderRegion = (LocalRegion)getCache().getRegion(ORDER); TXManagerImpl mgr = getGemfireCache().getTxManager(); TXState txState = mgr.getHostedTXState(txId2).getLocalTXState(); final TXStateInterface currentTX = mgr.getTXState(); mgr.masqueradeAs(txState); for (int index = 0; index < 10; ++index) { final CustId custId = new CustId(index); assertEquals(new Customer("customer" + index, "address" + index), txState.getEntry(new KeyInfo(custId, null, null), custRegion, false, false).getValue()); assertEquals(new Order("order" + index), txState.getEntry( new KeyInfo(new OrderId(index, custId), null, null), orderRegion, false, false).getValue()); } mgr.masqueradeAs(currentTX); return null; } });
SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_EXECUTION, "in procedure ROLLBACK_SNAPSHOT_TXID() " + txId + " for connid " + tc.getConnectionID() + " TxManager " + TXManagerImpl.getCurrentTXId() + " snapshot tx : " + TXManagerImpl.getCurrentSnapshotTXState()); TXId txId1 = TXId.valueOf(memberId, uniqId); txState = txManager.getHostedTXState(txId1); txManager.masqueradeAs(txState); txManager.rollback(); } else if ((context = TXManagerImpl.currentTXContext()) != null) { context.clearTXStateAll(); SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_EXECUTION, "in procedure ROLLBACK_SNAPSHOT_TXID() afer commit" + txId + " for connid " + tc.getConnectionID() + " TxManager " + TXManagerImpl.getCurrentTXId() + " snapshot tx : " + TXManagerImpl.getCurrentSnapshotTXState());
final TXStateProxy txState = txMgr.getTXState(); boolean rollbackSuccessful = false; try { if (txMgr.isHostedTxRecentlyCompleted(txId)) { if (logger.isDebugEnabled()) { logger txMgr.rollback(); rollbackSuccessful = true; txMgr.removeHostedTXState(txId);
/** Roll back the transaction associated with the current * thread. When this method completes, the thread is no longer * associated with a transaction. */ public void rollback() { checkClosed(); TXStateProxy tx = getTXState(); if (tx == null) { throw new IllegalStateException(LocalizedStrings.TXManagerImpl_THREAD_DOES_NOT_HAVE_AN_ACTIVE_TRANSACTION.toLocalizedString()); } tx.checkJTA(LocalizedStrings.TXManagerImpl_CAN_NOT_ROLLBACK_THIS_TRANSACTION_IS_ENLISTED_WITH_A_JTA_TRANSACTION_USE_THE_JTA_MANAGER_TO_PERFORM_THE_ROLLBACK.toLocalizedString()); final long opStart = CachePerfStats.getStatTime(); final long lifeTime = opStart - tx.getBeginTime(); setTXState(null); tx.rollback(); saveTXStateForClientFailover(tx); cleanup(tx.getTransactionId()); noteRollbackSuccess(opStart, lifeTime, tx); }
public static void START_SNAPSHOT_TXID(Boolean delayRollover, String[] txid) throws SQLException, StandardException { TXManagerImpl txManager = Misc.getGemFireCache().getCacheTransactionManager(); TXManagerImpl.TXContext context = TXManagerImpl.getOrCreateTXContext(); txManager.rollback(oldTX, null, false); } catch (TransactionException ignored) { final TXStateInterface tx = txManager.beginTX(context, IsolationLevel.SNAPSHOT, null, null); LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC(); + " delayRollover=" + delayRollover + " tc id" + tc.getTransactionIdString() + " TxManager " + TXManagerImpl.getCurrentTXId() + " snapshot tx : " + tx);
public Object call() throws Exception { TXManagerImpl mgr = getGemfireCache().getTxManager(); PartitionedRegion pr = (PartitionedRegion)getCache().getRegion(CUSTOMER); mgr.begin(); Set filter = new HashSet(); filter.add(expectedCustId); FunctionService.onRegion(pr).withFilter(filter).execute(new NestedTxFunction()).getResult(); assertNotNull(getGemfireCache().getTxManager().getTXState()); mgr.commit(); assertEquals(expectedCustomer, pr.get(expectedCustId)); return null; } });
public Object call() throws Exception { TXManagerImpl mgr = getGemfireCache().getTxManager(); Region<Object, Object> custRegion = getCache().getRegion(CUSTOMER); assertEquals(expectedCustomerUpdate, custRegion.get(expectedCustId)); // check in the other active transaction // force other active transaction TXStateInterface tx = mgr.getHostedTXState(txId1); TXStateInterface txOrig = mgr.getTXState(); mgr.setTXState(tx); assertEquals(expectedCustomer, custRegion.get(expectedCustId)); mgr.setTXState(txOrig); return null; } });
public boolean tryResume(TransactionId transactionId, long time, TimeUnit unit) { if (transactionId == null || getTXState() != null || !exists(transactionId)) { return false; if (tryResume(transactionId)) { return true; } else if (!exists(transactionId)) { return false;
/** * Returns the TXStateInterface of the current thread; null if no transaction. */ public final TXStateInterface getTXState() { return getCurrentTXState(); }
private TXStateProxy prepForTransaction() throws InterruptedException { if (this.txUniqId == TXManagerImpl.NOTX) { return null; } else { GemFireCacheImpl cache = GemFireCacheImpl.getInstance(); if(cache==null) { // ignore and return, we are shutting down! return null; } TXManagerImpl mgr = cache.getTXMgr(); return mgr.masqueradeAs(this); } }
public Object call() throws Exception { TXManagerImpl mgr = getGemfireCache().getTxManager(); assertFalse(mgr.isHostedTxInProgress(txId)); TXStateInterface tx = mgr.getHostedTXState(txId); // no TXRegionStates for reads on store at READ_COMMITTED assertNull(tx); return null; } });