public final static TXStateProxy getCurrentTXState() { if(currentInstance==null) { return null; } return currentInstance.getTXState(); }
/** Reports the existance of a Transaction for this thread * */ public boolean exists() { return null != getTXState(); }
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 boolean tryResume(TransactionId transactionId) { if (transactionId == null || getTXState() != null) { return false; } TXStateInterface tx = this.suspendedTXs.remove(transactionId); if (tx != null) { resume(tx); return true; } return false; }
/** Gets the current transaction identifier or null if no transaction exists * */ public TransactionId getTransactionId() { TXStateProxy t = getTXState(); TransactionId ret = null; if (t!=null) { ret = t.getTransactionId(); } return ret; }
/** 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); }
/** * @return the node which a transaction is already is progress, null otherwise */ private DistributedMember getTransactionalNode() { if (cache.getTxManager().getTXState() != null) { return cache.getTxManager().getTXState().getTarget(); } return null; }
/** * prepare for transaction replay by assigning a new tx id to the current proxy */ private void _incrementTXUniqueIDForReplay() { TXStateProxyImpl tx = (TXStateProxyImpl)getTXState(); assert tx != null : "expected a transaction to be in progress"; TXId id = new TXId(this.distributionMgrId, this.uniqId.incrementAndGet()); tx.setTXIDForReplay(id); }
public void setDistributed(boolean flag) { checkClosed(); TXStateProxy tx = getTXState(); // Check whether given flag and current flag are different and whether a transaction is in progress if (tx != null && flag != isDistributed()) { // Cannot change mode in the middle of a transaction throw new java.lang.IllegalStateException( LocalizedStrings.TXManagerImpl_CANNOT_CHANGE_TRANSACTION_MODE_WHILE_TRANSACTIONS_ARE_IN_PROGRESS .toLocalizedString()); } else { isTXDistributed.set(new Boolean(flag)); } }
@Override protected boolean operateOnTx(TXId txId,DistributionManager dm) { GemFireCacheImpl cache = GemFireCacheImpl.getInstance(); TXManagerImpl txMgr = cache.getTXMgr(); if (logger.isDebugEnabled()) { logger.debug("JTA: Calling beforeCompletion for :{}", txId); } txMgr.getTXState().beforeCompletion(); return true; }
/** * If the current thread is in a transaction then suspend will * cause it to no longer be in a transaction. * @return the state of the transaction or null. Pass this value * to {@link TXManagerImpl#resume} to reactivate the suspended transaction. */ public final TXStateProxy internalSuspend() { TXStateProxy result = getTXState(); if (result != null) { result.suspend(); setTXState(null); } return result; } /**
@Override public void validateExecution(Function function, Set targetMembers) { GemFireCacheImpl cache = GemFireCacheImpl.getInstance(); if (cache != null && cache.getTxManager().getTXState() != null) { TXStateProxyImpl tx = (TXStateProxyImpl) cache.getTxManager().getTXState(); tx.getRealDeal(null, region); tx.incOperationCount(); } }
public void precommit() throws CommitConflictException { checkClosed(); final 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_COMMIT_THIS_TRANSACTION_BECAUSE_IT_IS_ENLISTED_WITH_A_JTA_TRANSACTION_USE_THE_JTA_MANAGER_TO_PERFORM_THE_COMMIT.toLocalizedString()); tx.precommit(); }
public TXEntryState createReadEntry(LocalRegion r, Object entryKey, RegionEntry re, Object vId, Object pendingValue) { GemFireCacheImpl cache = r.getCache(); boolean isDistributed = false; if (cache.getTxManager().getTXState() != null) { isDistributed = cache.getTxManager().getTXState().isDistTx(); } else { // TXCoordinator and datanode are same isDistributed = cache.getTxManager().isDistributed(); } TXEntryState result = cache.getTXEntryStateFactory().createEntry(re, vId, pendingValue, entryKey, this, isDistributed); this.entryMods.put(entryKey, result); return result; }
public Object call() throws Exception { Region custRegion = getCache().getRegion(CUSTOMER); TXManagerImpl mgr = getGemfireCache().getTxManager(); mgr.begin(); assertEquals(5, custRegion.size()); assertNotNull(mgr.getTXState()); 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; } });
@Override protected boolean operateOnTx(TXId txId,DistributionManager dm) throws RemoteOperationException { TXManagerImpl txMgr = GemFireCacheImpl.getInstance().getTXMgr(); if (logger.isDebugEnabled()) { logger.debug("JTA: Calling afterCompletion for :{}", txId); } TXStateProxy txState = txMgr.getTXState(); txState.setCommitOnBehalfOfRemoteStub(true); txState.afterCompletion(status); TXCommitMessage cmsg = txState.getCommitMessage(); TXRemoteCommitReplyMessage.send(getSender(), getProcessorId(), cmsg, getReplySender(dm)); txMgr.removeHostedTXState(txId); return false; }
public Object call() throws Exception { TXManagerImpl mgr = getGemfireCache().getTxManager(); assertNotNull(mgr.getTXState()); mgr.commit(); Region<String, CustomerNoDelta> r = getCache().getRegion(regionName); CustomerNoDelta cnd = r.get(keynd); Customer c = (Customer)r.get(key); assertEquals("cust11NoDelta", cnd.getName()); assertEquals("cust11", c.getName()); // wait for commit to finish before checking on vm2 TXManagerImpl.waitForPendingCommitForTest(); return null; } });
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 { 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; } });