/** * Return true if this transaction has completely invalidated or destroyed the * value of this entry in the entire distributed system. Return false if a * netsearch should be done. */ public final boolean noValueInSystem() { if (this.op == OP_D_DESTROY || this.op == OP_D_INVALIDATE_LD || this.op == OP_D_INVALIDATE) { return true; } else if (getNearSidePendingValue() == Token.INVALID) { // Note that we are not interested in LOCAL_INVALID return (this.op >= OP_CREATE_LD && this.op != OP_L_INVALIDATE && this.op != OP_SEARCH_CREATE && this.op != OP_LOCAL_CREATE && this.op != OP_SEARCH_PUT); } return false; }
/** * Return true if this transaction has completely invalidated or destroyed the * value of this entry in the entire distributed system. Return false if a * netsearch should be done. */ public boolean noValueInSystem() { if (this.op == OP_D_DESTROY || this.op == OP_D_INVALIDATE_LD || this.op == OP_D_INVALIDATE) { return true; } else if (getNearSidePendingValue() == Token.INVALID) { // Note that we are not interested in LOCAL_INVALID return (this.op >= OP_CREATE_LD && this.op != OP_L_INVALIDATE && this.op != OP_SEARCH_CREATE && this.op != OP_LOCAL_CREATE && this.op != OP_SEARCH_PUT); } else { return false; } }
@Retained public Object getValueInVM(Object key) throws EntryNotFoundException { if (!existsLocally()) { throw new EntryNotFoundException(String.valueOf(key)); } return getNearSidePendingValue(); }
/** * Creates a local tx entry event */ TxEntryEventImpl(LocalRegion r, Object key) { //TODO:ASIF :Check if the eventID should be created. Currently not // creating it super(r, getNearSideOperation(), key, getNearSidePendingValue(),TXEntryState.this.getCallbackArgument(), false, r.getMyId() , true/* generateCallbacks */, true /*initializeId*/); }
/** * Returns true if the transaction state has this entry existing locally and * has a valid local value. Returns false if the transaction is going to * remove this entry or its local value is invalid. */ public final boolean isLocallyValid(boolean isProxy) { if (this.op <= OP_NULL) { if (isProxy) { // If it is a proxy that consider it locally valid // since we don't have any local committed state return true; } else { return !Token.isInvalidOrRemoved(this.originalVersionId); } } else { return this.op >= OP_CREATE && !Token.isInvalid(getNearSidePendingValue()); } }
/** * @param key * @return the value, or null if the value does not exist in the cache, * Token.INVALID or Token.LOCAL_INVALID if the value is invalid */ public Object getValue(Object key, Region r, boolean preferCD) { if (!existsLocally()) { return null; } Object v = getNearSidePendingValue(); if (v instanceof CachedDeserializable && !preferCD) { // The only reason we would is if we do a read // in a transaction and the initial op that created the TXEntryState // did not call getDeserializedValue. // If a write op is done then the pendingValue does not belong to // the cache yet so we do not need the RegionEntry. // If we do need the RegionEntry then TXEntryState // will need to be changed to remember the RegionEntry it is created with. v = ((CachedDeserializable)v).getDeserializedValue(r, this.refCountEntry); } return v; }
/** * @return the value, or null if the value does not exist in the cache, * Token.INVALID or Token.LOCAL_INVALID if the value is invalid */ public final Object getValue(Region<?, ?> r) { if (!existsLocally()) { return null; } Object v = getNearSidePendingValue(); if (v != null && v instanceof CachedDeserializable) { // The only reason we would is if we do a read // in a transaction and the initial op that created the TXEntryState // did not call getDeserializedValue. // If a write op is done then the pendingValue does not belong to // the cache yet so we do not need the RegionEntry. // If we do need the RegionEntry then TXEntryState // will need to be changed to remember the RegionEntry it is created with. // [sumedh] now we do remember the RegionEntry since it is obtained at // the initial lock if (r == null) { r = this.txRegionState.region; } v = ((CachedDeserializable)v).getDeserializedValue(r, this.regionEntry); } return v; }
/** * Returns true if the transaction state has this entry existing locally and * has a valid local value. Returns false if the transaction is going to * remove this entry or its local value is invalid. */ public boolean isLocallyValid(boolean isProxy) { if (this.op == OP_NULL) { if (isProxy) { // If it is a proxy that consider it locally valid // since we don't have any local committed state return true; } else { return !Token.isInvalidOrRemoved(getOriginalValue()); } } else { return this.op >= OP_CREATE && !Token.isInvalid(getNearSidePendingValue()); } }
/** * Get the value in TX if dirty else get the value in region. Returns null for * destroyed entry and relevant Token object for invalidated entry. */ @Unretained protected final Object getValueInTXOrRegion() { if (isDirty()) { return getNearSidePendingValue(); } else { @Unretained final Object oldVal = this.originalVersionId; if (!Token.isRemoved(oldVal)) { return oldVal; } return null; } }
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()); }
protected final EntryEventImpl getEvent(final TXState txs, final boolean isCohort, final InternalDistributedMember myId) { // dumpOp(); //TODO:ASIF : Should we generate EventID ? At this point not generating final LocalRegion eventRegion = getBaseRegion(); final EntryEventImpl result = EntryEventImpl.create(eventRegion, getNearSideOperation(), this.regionKey, getNearSidePendingValue(), getCallbackArgument(), false, myId); // OFFHEAP: freeOffHeapResources on this event is called from TXEvent.freeOffHeapResources. if (this.destroy == DESTROY_NONE || isOpDestroy()) { result.setOldValue(this.originalVersionId); } // Use coordinator to determine if the originRemote flag should be set. // The event can come to coordinator from itself in nested function // execution so this flag is more reliable -- see bug #41498. result.setOriginRemote(isCohort); result.setTXState(txs); return result; }
final void putValueTXEntry(final TXEntryState txEntry, final byte op) { // !!!:ezoerner:20080611 Deltas do not yet work with transactions // [sumedh] 20101215: GemFireXD deltas now work correctly with transactions Object v = basicGetNewValue(); if (v == null) { if (deltaBytes != null) { // since newValue is null, and we have deltaBytes // there must be a nearSidePendingValue processDeltaBytes(txEntry.getNearSidePendingValue()); v = basicGetNewValue(); } else if (delta == null) { if (this.op.isInvalidate()) { v = isLocalInvalid() ? Token.LOCAL_INVALID : Token.INVALID; } } } if (this.op != Operation.LOCAL_INVALIDATE && this.op != Operation.LOCAL_DESTROY) { // fix for bug 34387 txEntry.setPendingValue(OffHeapHelper.copyIfNeeded(v), this.delta, this.region, op); // TODO OFFHEAP optimize } putTXEntryCallbackArg(txEntry); }
if (tx != null) { if (requireOldValue && tx.existsLocally()) { event.setOldValue(tx.getNearSidePendingValue(), true);
Object val = result.getNearSidePendingValue(); if (!AbstractRegionEntry.checkExpectedOldValue(expectedOldValue, val, localRegion)) { txr.cleanupNonDirtyEntries(localRegion);