/** * @see TXEntryId#getTXId() */ public TXId getTXId() { return this.myTX.getTransactionId(); } }
/** * Get the key to {@link TXEntryState} map. */ final THashMapWithCreate getEntryMap() { if (this.isValid) { return this.entryMods; } else { throw new IllegalTransactionStateException( LocalizedStrings.TRANSACTION_0_IS_NO_LONGER_ACTIVE .toLocalizedString(this.txState.getTransactionId())); } }
public TXEvent getEvent() { return new TXEvent(this, getTransactionId(), getCache()); }
/** * This is a fix for bug #42228 where a client fails over from one server to * another but gets a conflict on completion because completion had already * been initiated and had not yet completed * @return true if a previous completion was in progress */ public boolean waitForPreviousCompletion() { synchronized(this.completionGuard) {// should have already been done, but just to be sure if (!this.completionStarted) { return false; } while (this.commitMessage == null && !this.closed) { if (logger.isDebugEnabled()) { logger.debug("Waiting for previous completion for transaction {}", getTransactionId()); } try { this.completionGuard.wait(); } catch (InterruptedException e) { this.proxy.getCache().getCancelCriterion().checkCancelInProgress(e); Thread.currentThread().interrupt(); return true; } } // while } return true; }
/** * {@inheritDoc} */ @Override public void setTXOrderForFinish(TXRegionState txrs) { if (this.pendingTXRegionStatesLock != null) { TObjectIntHashMap finishedOrders; // assume read lock on pendingTXRegionStates is already held Assert.assertTrue(this.pendingTXRegionStatesLock.numReaders() > 0); if ((finishedOrders = this.finishedTXIdOrders) != null) { int order = finishedOrders.get(txrs.getTXState().getTransactionId()); if (order != 0) { txrs.finishOrder = Math.abs(order); return; } } } txrs.finishOrder = this.pendingTXOrder.incrementAndGet(); }
protected void checkTX() { // Protect against the case where this instance was handed to a different // thread w/ or w/o a transaction // Protect against the case where the transaction associated with this entry // is not in progress // [sumedh] avoiding checking for LocalRegion's current TX since it involves // an expensive ThreadLocal lookup and it is okay to live with switching to // different thread as long as original transaction is alive //if (!this.myTX.isInProgressAndSameAs(this.localRegion.getTXState())) { if (!this.myTX.isInProgress()) { throw new IllegalTransactionStateException(LocalizedStrings .LocalRegion_REGIONENTRY_WAS_CREATED_WITH_TRANSACTION_THAT_IS_NO_LONGER_ACTIVE .toLocalizedString(this.myTX.getTransactionId())); } }
protected final void releaseRowLocationLock(final RowLocation rl, final GemFireContainer container) { if (rl != null) { // assumes that local TXState is non-null assert this.localTXStateSet && this.localTXState != null : "unexpected localTXState=" + this.localTXState; final TXState tx = this.localTXState; final LockingPolicy lockPolicy = tx.getLockingPolicy(); GemFireXDUtils.releaseLockForReadOnPreviousEntry( rl.getUnderlyingRegionEntry(), tx, tx.getTransactionId(), lockPolicy, lockPolicy.getReadLockMode(), container, null, this.lockContext); } }
protected final void releaseRowLocationLock(final RowLocation rl, final GemFireContainer container) { if (rl != null) { // assumes that local TXState is non-null assert this.localTXStateSet && this.localTXState != null : "unexpected localTXState=" + this.localTXState; final TXState tx = this.localTXState; final LockingPolicy lockPolicy = tx.getLockingPolicy(); GemFireXDUtils.releaseLockForReadOnPreviousEntry( rl.getUnderlyingRegionEntry(), tx, tx.getTransactionId(), lockPolicy, lockPolicy.getReadLockMode(), container, null, this.lockContext); } }
protected final void releaseRowLocationLock(final RowLocation rl, final GemFireContainer container) { if (rl != null) { // assumes that local TXState is non-null assert this.localTXStateSet && this.localTXState != null : "unexpected localTXState=" + this.localTXState; final TXState tx = this.localTXState; final LockingPolicy lockPolicy = tx.getLockingPolicy(); GemFireXDUtils.releaseLockForReadOnPreviousEntry( rl.getUnderlyingRegionEntry(), tx, tx.getTransactionId(), lockPolicy, lockPolicy.getReadLockMode(), container, null, this.lockContext); } }
private final void txApplyPutLocally(LocalRegion r, Operation putOp, Object key, Object newValue, boolean didDestroy, TXState txState) { try { r.txApplyPut(putOp, key, newValue, didDestroy, txState.getTransactionId(), null, getNearSideEventId(txState), callBackArgument,txState.getPendingCallbacks(), getFilterRoutingInfo(), txState.bridgeContext, this, null, -1); } catch (RegionDestroyedException ignore) { } catch (EntryDestroyedException ignore) { } }
private final void txApplyInvalidateLocally(LocalRegion r, Object key, Object newValue, boolean didDestroy, TXState txState) { try { r.txApplyInvalidate(key, newValue, didDestroy, txState.getTransactionId(), null, isOpLocalInvalidate() ? true : false, getNearSideEventId(txState), callBackArgument,txState.getPendingCallbacks(), getFilterRoutingInfo(), txState.bridgeContext, this, null, -1); } catch (RegionDestroyedException ignore) { } catch (EntryDestroyedException ignore) { } }
private final void txApplyDestroyLocally(LocalRegion r, Object key, TXState txState) { boolean invokeCallbacks = isOpDestroyEvent(r); List<EntryEventImpl> pendingCallbacks = invokeCallbacks ? txState.getPendingCallbacks() : new ArrayList<EntryEventImpl>(); try { r.txApplyDestroy(key, txState.getTransactionId(), null, false/*inTokenMode*/, getDestroyOperation(), getNearSideEventId(txState), callBackArgument, pendingCallbacks ,getFilterRoutingInfo(), txState.bridgeContext, false, this, null, -1); } catch (RegionDestroyedException ignore) { } catch (EntryDestroyedException ignore) { } // if !isOpDestroyEvent then // this destroy, to local committed state, becomes a noop // since nothing needed to be done locally. // We don't want to actually do the destroy since we told the // transaction listener that no destroy was done. }
/** * Acquire lock on an entry for reading. For updates the read lock will be * upgraded to write once the row is qualified. */ public static boolean lockForRead(final TXState tx, final LockingPolicy lockPolicy, final LockMode mode, final int lockFlags, final RegionEntry entry, final GemFireContainer container, final LocalRegion dataRegion, final GemFireXDQueryObserver observer) { assert dataRegion != null: "unexpected null data region for " + entry + " in container " + container; final TXId txId = tx.getTransactionId(); if (observer != null) { observer.lockingRowForTX(tx.getProxy(), container, entry, false); } lockPolicy.acquireLock(entry, mode, lockFlags, txId, dataRegion, null); if (!entry.isDestroyedOrRemoved()) { return true; } unlockEntryAfterRead(txId, lockPolicy, mode, entry, container, dataRegion); return false; }
/** * Acquire lock on an entry for reading. For updates the read lock will be * upgraded to write once the row is qualified. */ public static boolean lockForRead(final TXState tx, final LockingPolicy lockPolicy, final LockMode mode, final int lockFlags, final RegionEntry entry, final GemFireContainer container, final LocalRegion dataRegion, final GemFireXDQueryObserver observer) { assert dataRegion != null: "unexpected null data region for " + entry + " in container " + container; final TXId txId = tx.getTransactionId(); if (observer != null) { observer.lockingRowForTX(tx.getProxy(), container, entry, false); } lockPolicy.acquireLock(entry, mode, lockFlags, txId, dataRegion, null); if (!entry.isDestroyedOrRemoved()) { return true; } unlockEntryAfterRead(txId, lockPolicy, mode, entry, container, dataRegion); return false; }
/** * Acquire lock on an entry for reading. For updates the read lock will be * upgraded to write once the row is qualified. */ public static boolean lockForRead(final TXState tx, final LockingPolicy lockPolicy, final LockMode mode, final int lockFlags, final RegionEntry entry, final GemFireContainer container, final LocalRegion dataRegion, final GemFireXDQueryObserver observer) { assert dataRegion != null: "unexpected null data region for " + entry + " in container " + container; final TXId txId = tx.getTransactionId(); if (observer != null) { observer.lockingRowForTX(tx.getProxy(), container, entry, false); } lockPolicy.acquireLock(entry, mode, lockFlags, txId, dataRegion, null); if (!entry.isDestroyedOrRemoved()) { return true; } unlockEntryAfterRead(txId, lockPolicy, mode, entry, container, dataRegion); return false; }
throw new IllegalTransactionStateException( LocalizedStrings.TRANSACTION_0_IS_NO_LONGER_ACTIVE .toLocalizedString(this.txState.getTransactionId()));
/** * {@inheritDoc} */ @Override public boolean addPendingTXRegionState(TXRegionState txrs) { if (this.pendingTXRegionStates != null) { // don't add if the advisor has not been initialized yet, that is the // initial CreateRegionMessage replies are still on the wire so all // operations on TXRegionState are essentially ignored final LocalRegion region = txrs.region; if (region.isProfileExchanged()) { Object old; if ((old = this.pendingTXRegionStates.putIfAbsent(txrs.getTXState() .getTransactionId(), txrs)) != null) { Assert.fail("ImageState#addPendingTXRegionState: failed to add " + txrs + ", existing=" + old); } if (TXStateProxy.LOG_FINE) { final LogWriterI18n logger = region.getLogWriterI18n(); logger.info(LocalizedStrings.DEBUG, "ImageState#addPendingTXRegionState: adding " + txrs); } } return true; } else { return false; } }
EntryEvent getEvent(LocalRegion r, Object key, TXState txs) { // dumpOp(); //TODO:ASIF : Shopuld we generate EventID ? At this point not generating LocalRegion eventRegion = r; if (r.isUsedForPartitionedRegionBucket()) { eventRegion = r.getPartitionedRegion(); } EntryEventImpl result = new TxEntryEventImpl(eventRegion, key); // OFFHEAP: freeOffHeapResources on this event is called from TXEvent.freeOffHeapResources. boolean returnedResult = false; try { if (this.destroy == DESTROY_NONE || isOpDestroy()) { result.setOldValue(getOriginalValue()); } if(txs.isOriginRemoteForEvents()) { result.setOriginRemote(true); } else { result.setOriginRemote(false); } result.setTransactionId(txs.getTransactionId()); returnedResult = true; return result; } finally { if (!returnedResult) result.release(); } }
final int size = tssLocks[0].size(); if (size > 0) { final TXId owner = getTransactionId(); for (int index = 0; index < size; index++) { final Object lockObj = tssLocks[0].get(index);
commit(); } catch (CommitConflictException error) { Assert.assertTrue(false, "Gemfire Transaction " + getTransactionId() + " afterCompletion failed.due to CommitConflictException: " + error);