protected final void setOpType(byte opType, Object callbackArg) { this.op = opType; if (callbackArg != null) { setCallbackArgument(callbackArg); } }
@Override @Retained public Object getValue(RegionEntryContext context) { return super.getRetainedValueInTXOrRegion(); }
public final boolean execute(final Object obj) { if(obj instanceof TXEntryState) { if(((TXEntryState)obj).wasCreatedByTX()) { keys.add(((TXEntryState)obj).getUnderlyingRegionEntry()); } } return true; } });
void getEvents(LocalRegion r, ArrayList events, TXState txs) { { Iterator it = this.entryMods.entrySet().iterator(); while (it.hasNext()) { Map.Entry me = (Map.Entry)it.next(); Object eKey = me.getKey(); TXEntryState txes = (TXEntryState)me.getValue(); if (txes.isDirty() && txes.isOpAnyEvent(r)) { events.add(txes.getEvent(r, eKey, txs)); } } } }
entry.op = entry.advisePutOp(ifNew ? TXEntryState.OP_CREATE : TXEntryState.OP_PUT, op); if (event.hasDeltaPut()) { entry.setCallbackArgument(event.getCallbackArgument()); txr.addPendingTXOpAndUnlockGII(entry, AbstractRegionEntry.ALLOW_ONE_READ_ONLY_WITH_EX_SH); lockAcquired = true; if(txEntry instanceof TXEntryState) { val = ((TXEntryState)txEntry).getValueInTXOrRegion(); }else { val = dataRegion.getREValueForTXRead(entry); val = tx.getValueInTXOrRegion(); if (expectedOldValue != null) { checkExpectedOldValue(val, expectedOldValue, txr, region); if (event.hasDeltaPut() && tx.isOpDestroy()) { throw new EntryNotFoundException( "No previously created entry to be updated for event: " + event); if (tx.isOpReadOnly()) { entry = tx.getUnderlyingRegionEntry(); lockPolicy.acquireLock(entry, lockPolicy.getWriteLockMode(), AbstractRegionEntry.ALLOW_ONE_READ_ONLY_WITH_EX_SH, this.txId, if (tx.existsLocally()) {
entry.op = entry.adviseDestroyOp(op); entry.setCallbackArgument(event.getCallbackArgument()); txr.addPendingTXOpAndUnlockGII(entry, AbstractRegionEntry.ALLOW_ONE_READ_ONLY_WITH_EX_SH); else if (entry.checkAndClearGIIEntry()) { if (markPending) { markPending(entry, entry.op, event.getCallbackArgument()); txEntryCreated = entry.isOpNull(); if ((lockedForRead = entry.isOpFlaggedForRead())) { entry.op = TXEntryState.OP_NULL; txEntryCreated = true; isReadOnly = entry.isOpReadOnly(); entry.destroyPart1(event, cacheWrite); if (markPending) { this.headLock.lock(); try { entry.destroyPart2(event); entry.updateForCommitNoLock(this, true); } finally { this.headLock.unlock(); entry.destroyPart2(event); entry.updateForCommit(this); entry.destroyPart3(dataRegion, event);
entry.op = entry.adviseInvalidateOp(event, op); entry.setCallbackArgument(event.getCallbackArgument()); txr.addPendingTXOpAndUnlockGII(entry, AbstractRegionEntry.ALLOW_ONE_READ_ONLY_WITH_EX_SH); if ((entry = txWriteExistingEntry(event, region, dataRegion, txr, markPending, null)) != null) { if (entry.checkAndClearGIIEntry()) { if (markPending) { markPending(entry, entry.op, event.getCallbackArgument()); txEntryCreated = entry.isOpNull(); if ((lockedForRead = entry.isOpFlaggedForRead())) { entry.op = TXEntryState.OP_NULL; txEntryCreated = true; isReadOnly = entry.isOpReadOnly(); this.headLock.lock(); try { if ((success = entry.invalidate(event, op))) { entry.updateForCommitNoLock(this, true); if ((success = entry.invalidate(event, op))) { entry.updateForCommit(this); final RegionEntry re = entry.getUnderlyingRegionEntry(); lockPolicy.releaseLock(re, lockPolicy.getReadLockMode(), this.txId, false, dataRegion);
try { txes = tx.lockEntry(null, key, callbackArg, region, dataRegion, true, queryHDFS, TXEntryState.getLockForUpdateOp(), TXState.LOCK_ENTRY_NOT_FOUND); } catch (EntryNotFoundException enfe) { observer.lockingRowForTX(tx.getProxy(), (GemFireContainer)region.getUserAttribute(), txs.getUnderlyingRegionEntry(), true); return txs.getRetainedValueInTXOrRegion();
return; final LocalRegion region = getBaseRegion(dataRegion); final boolean checkValid = checkForTXFinish.booleanValue(); txrs.lock(); final LockingPolicy lockPolicy = txState.getLockingPolicy(); final RegionEntry entry; if (isDirty() || this.op == OP_LOCK_FOR_UPDATE) { entry = region.lockRegionEntryForWrite(dataRegion, this.regionKey, lockPolicy, lockPolicy.getWriteLockMode(), txState.txId, if (!isOpReadOnly()) { throw new IllegalStateException( LocalizedStrings.TXEntryState_OPCODE_0_SHOULD_NEVER_BE_REQUESTED .toLocalizedString(opToString(this.op))); release(); this.originalVersionId = val; this.regionEntry = entry; applyBatchOperationOnNewEntry(txState, lockPolicy, txrs, region, dataRegion, val, entry, lockedForRead, checkValid, eventTemplate); applyBatchOperationOnExistingEntry(txState, txrs, region, dataRegion, (TXEntryState)currentEntry, eventTemplate, lockFlags, msg);
tx.setOpFlagForRead(); val = tx.getValueInTXOrRegion(); if (expectedOldValue != null) { checkExpectedOldValue(val, expectedOldValue, txr, region); if (tx.isOpReadOnly()) { entry = tx.getUnderlyingRegionEntry(); lockPolicy.acquireLock(entry, lockPolicy.getWriteLockMode(), AbstractRegionEntry.ALLOW_ONE_READ_ONLY_WITH_EX_SH, this.txId, if (tx.existsLocally(true)) { event.setTXOldValue(val); final boolean invalidatingInvalidEntry = event.getOperation() else if (region.isProxy() && !op.isLocal() && !tx.isDirty()) { txr.getEntryMap().remove(eventKey); if(tx != null) { tx.release();
/** * {@inheritDoc} */ @Override public boolean isValueNull() { return super.getValueInTXOrRegion() == null; }
final RegionEntry entry = txes.getUnderlyingRegionEntry(); if (entry != null && txes.entryCreatedForLock() && (rollback || (!txes.hasPendingValue() && entry .isDestroyedOrRemoved()))) { rgn.entries.removeEntry(entry.getKey(), entry, false); if (txes.isDirty()) { numChanges++; txes.cleanup(tx, rgn, lockPolicy, writeMode, removeFromList, false, forCommit); } catch (Throwable t) {
public Object call() throws Exception { TXManagerImpl mgr = getGemfireCache().getTxManager(); assertTrue(mgr.isHostedTxInProgress(txId)); TXStateInterface tx = mgr.getHostedTXState(txId); // 2 buckets for the two puts we did in the accessor one dist. region, // and one more bucket if Cust1 and Cust10 resolve to different buckets assertEquals("unexpected regions: " + tx.getRegions(), 2, tx.getRegions().size()); for (LocalRegion r : tx.getRegions()) { assertTrue(r instanceof BucketRegion || r instanceof DistributedRegion); TXRegionState rs = tx.readRegion(r); for (Object key : rs.getEntryKeys()) { TXEntryState es = (TXEntryState)rs.readEntry(key); assertNotNull(es.getValue(r)); assertTrue("key:"+key+" r:"+r.getFullPath(), es.isDirty()); } } return null; } });
if (txEntry instanceof TXEntryState) { final TXEntryState txes = (TXEntryState)txEntry; if (txes.existsLocally()) { if (txes.isDirty()) { return new TXEntry(localRegion, dataRegion, key, txes, this); return localRegion.new NonTXEntry(txes.getUnderlyingRegionEntry());
void putValueTXEntry(final TXEntryState tx) { Object v = basicGetNewValue(); if (v == null) { if (deltaBytes != null) { // since newValue is null, and we have deltaBytes // there must be a nearSidePendingValue processDeltaBytes(tx.getNearSidePendingValue()); v = basicGetNewValue(); } else if (this.delta != null) { v = this.delta; } else { v = isLocalInvalid() ? Token.LOCAL_INVALID : Token.INVALID; } } if (this.op != Operation.LOCAL_INVALIDATE && this.op != Operation.LOCAL_DESTROY) { // fix for bug 34387 tx.setPendingValue(OffHeapHelper.copyIfNeeded(v)); // TODO OFFHEAP optimize } tx.setCallbackArgument(getCallbackArgument()); }
void cleanup(LocalRegion r) { if (this.cleanedUp) return; this.cleanedUp = true; Iterator it = this.entryMods.values().iterator(); while (it.hasNext()) { TXEntryState es = (TXEntryState)it.next(); es.cleanup(r); } this.region.setInUseByTransaction(false); } int getChanges() {
key, null, rl.getBucketID(), Operation.GET_ENTRY); if (tx.lockEntry(re, key, callbackArg, lr, dataRegion, false, false, TXEntryState.getReadOnlyOp(), TXState.LOCK_ENTRY_NOT_FOUND) == null) { containsKey = false;
@Override public final void upgradeCurrentRowLocationLockToWrite() throws StandardException { if (this.currentRowLocation != null && this.currentDataRegion != null) { final RegionEntry entry = this.currentRowLocation .getUnderlyingRegionEntry(); final TXStateProxy txProxy = this.localTXState.getProxy(); if (this.observer != null) { this.observer.lockingRowForTX(txProxy, this.baseContainer, entry, true); } try { // upgrade the lock since the entry has been qualified txProxy.lockEntry(entry, entry.getKey(), GemFireXDUtils .getRoutingObject(this.currentRowLocation.getBucketID()), this.baseContainer.getRegion(), this.currentDataRegion, true, TXEntryState.getLockForUpdateOp()); } finally { // now release the SH lock after the atomic lock upgrade, or as // cleanup in case of lock upgrade failure GemFireXDUtils.releaseLockForReadOnPreviousEntry(entry, this.localTXState, this.txId, this.lockPolicy, this.readLockMode, this.baseContainer, this.currentDataRegion, this.lockContext); } this.currentDataRegion = null; } }
@Retained public final Object getValueInVM(Object key) throws EntryNotFoundException { if (!existsLocally()) { throw new EntryNotFoundException(String.valueOf(key)); } return getRetainedValueInTXOrRegion(); }