Object mKey = em.getKey(); TXEntryState txes = em.getValue(); DistTxThinEntryState thinEntryState = txes.getDistTxEntryStates(); entryStateList.add(thinEntryState); if (logger.isDebugEnabled()) { logger.debug("TXRegionState.populateDistTxEntryStateList Added " + thinEntryState + " for key=" + mKey + " ,op=" + txes.opToString() + " ,region=" + regionFullPath);
/** * Creates a local tx entry event */ @Retained TxEntryEventImpl(InternalRegion r, Object key) { super(r, getNearSideOperation(), key, getNearSidePendingValue(), TXEntryState.this.getCallbackArgument(), false, r.getMyId(), true/* generateCallbacks */, true /* initializeId */); }
private void txHandleWANEvent(final LocalRegion owner, EntryEventImpl callbackEvent, TXEntryState txEntryState) { owner.handleWANEvent(callbackEvent); if (txEntryState != null) { txEntryState.setTailKey(callbackEvent.getTailKey()); } }
/** * @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; }
@Test public void doesNotAddCallbackEvent_ifExistingRegionEntryIsTombstone() throws Exception { givenLocalRegion(); givenExistingRegionEntry(); when(existingRegionEntry.isRemoved()).thenReturn(true); when(existingRegionEntry.isTombstone()).thenReturn(true); doTxApplyDestroy(); assertThat(pendingCallbacks).isEmpty(); verify(existingRegionEntry, never()).makeTombstone(any(), any()); verify(txEntryState, never()).setVersionTag(any()); }
oldVal = getOriginalValue(); } else { oldVal = getNearSidePendingValue(); throw new IllegalStateException( String.format("Unexpected current op %s for requested op %s", new Object[] {opToString(), opToString(requestedOpCode)})); case OP_L_INVALIDATE: advisedOpCode = requestedOpCode; default: throw new IllegalStateException( String.format("Unhandled %s", opToString())); Assert.assertTrue(!isOpDestroy(), "Transactional destroy assertion op=" + this.op); advisedOpCode = requestedOpCode; break; throw new IllegalStateException( String.format("Unexpected current op %s for requested op %s", new Object[] {opToString(), opToString(requestedOpCode)})); case OP_L_INVALIDATE: advisedOpCode = requestedOpCode; default: throw new IllegalStateException( String.format("Unhandled %s", opToString())); throw new IllegalStateException(
void checkForConflict(InternalRegion r, Object key) throws CommitConflictException { if (!isDirty()) { if (isOpSearch()) { if (!areIdentical(getOriginalVersionId(), curCmtVersionId)) { String fromString = calcConflictString(getOriginalVersionId()); String toString = calcConflictString(curCmtVersionId); if (!fromString.equals(toString)) { throw new CommitConflictException(
txReadEntry(event.getKeyInfo(), region, true, expectedOldValue, createIfAbsent); if (tx != null) { if (requireOldValue && tx.existsLocally()) { event.setOldValue(tx.getNearSidePendingValue(), true); boolean existsLocally = tx.existsLocally(); if (!existsLocally && event.getOperation() == Operation.REPLACE) { throw new EntryNotFoundException("No previously created Entry to be updated"); tx.updateForWrite(nextModSerialNum());
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 { v = isLocalInvalid() ? Token.LOCAL_INVALID : Token.INVALID; } } if (this.op != Operation.LOCAL_INVALIDATE && this.op != Operation.LOCAL_DESTROY) { // fix for bug 34387 Object pv = v; if (mayHaveOffHeapReferences()) { pv = OffHeapHelper.copyIfNeeded(v, getRegion().getCache()); } tx.setPendingValue(pv); } tx.setCallbackArgument(getCallbackArgument()); }
boolean doingCreate = true; if (!ifNew) { if (existsLocally()) { putOp = OP_PUT; doingCreate = false; byte advisedOp = adviseOp(putOp, event); performOp(advisedOp, event); fetchRemoteVersionTag(event);
/** * 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()); } }
if (shouldPerformConcurrencyChecks(owner, callbackEvent)) { try { if (txEntryState != null && txEntryState.getRemoteVersionTag() != null) { VersionTag remoteTag = txEntryState.getRemoteVersionTag(); if (re instanceof VersionStamp) { VersionStamp stamp = (VersionStamp) re; && txEntryState.getDistTxEntryStates() != null) { callbackEvent.setNextRegionVersion(txEntryState.getDistTxEntryStates().getRegionVersion());
long v = rvv.getNextVersion(); txes.getDistTxEntryStates().setRegionVersion(v); if (logger.isDebugEnabled()) { logger.debug("Set next region version to " + v + " for region=" + r.getName()
/** * 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; } }
o.es.serializePendingValue(); o.es.applyChanges(o.r, o.key, this); } catch (RegionDestroyedException ex) {
@Override public TXEntryState createEntry(RegionEntry re, Object vId, Object pendingValue, Object entryKey, TXRegionState txrs, boolean isDistributed) { return new TXEntryState(re, vId, pendingValue, txrs, isDistributed); }
void buildCompleteMessage(InternalRegion r, TXCommitMessage msg) { try { if (!this.entryMods.isEmpty()) { msg.startRegion(r, entryMods.size()); 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(); txes.buildCompleteMessage(r, eKey, msg, this.otherMembers); } msg.finishRegionComplete(); } } catch (RegionDestroyedException ex) { // region was destroyed out from under us; after conflict checking // passed. So act as if the region destroy happened right after the // commit. We act this way by doing nothing; including distribution // of this region's commit data. } catch (CancelException ex) { // cache was closed out from under us; after conflict checking // passed. So do nothing. } }
result = false; } else { result = tx.basicPut(event, ifNew, isOriginRemoteForEvents());
@Test public void putWithoutConcurrencyChecksEnabledDoesNotCallSetVersionTag() { createInstance(Operation.UPDATE, false, null, localTxEntryState); instance.put(); verify(localTxEntryState, never()).setVersionTag(any()); }