Examples of MVCCEntry


Examples of org.infinispan.container.entries.MVCCEntry

      return visitor.visitReplaceCommand(ctx, this);
   }

   @Override
   public Object perform(InvocationContext ctx) throws Throwable {
      MVCCEntry e = (MVCCEntry) ctx.lookupEntry(key);
      if (e != null) {
         if (ctx.isOriginLocal()) {
            //ISPN-514
            if (e.isNull() || e.getValue() == null) {
               // Revert assumption that new value is to be committed
               e.setChanged(false);
               return returnValue(null, false, ctx);
            }
         }

         if (oldValue == null || oldValue.equals(e.getValue())) {
            Object old = e.setValue(newValue);
            e.setLifespan(lifespanMillis);
            e.setMaxIdle(maxIdleTimeMillis);
            return returnValue(old, true, ctx);
         }
         // Revert assumption that new value is to be committed
         e.setChanged(false);
      }

      return returnValue(null, false, ctx);
   }
View Full Code Here

Examples of org.infinispan.container.entries.MVCCEntry

   }

   @Override
   public Object perform(InvocationContext ctx) throws Throwable {
      Object o;
      MVCCEntry e = (MVCCEntry) ctx.lookupEntry(key);
      if (e == null && hasFlag(Flag.PUT_FOR_EXTERNAL_READ)) {
         successful = false;
         return null;
      }
      //possible as in certain situations (e.g. when locking delegation is used) we don't wrap
      if (e == null) return null;

      Object entryValue = e.getValue();
      if (entryValue != null && putIfAbsent && !e.isRemoved()) {
         // Revert assumption that new value is to be committed
         e.setChanged(false);
         successful = false;
         return entryValue;
      } else {
         notifier.notifyCacheEntryModified(key, entryValue, true, ctx);

         if (value instanceof Delta) {
            // magic
            Delta dv = (Delta) value;
            DeltaAware toMergeWith = null;
            if (entryValue instanceof DeltaAware) toMergeWith = (DeltaAware) entryValue;
            e.setValue(dv.merge(toMergeWith));
            o = entryValue;
            e.setLifespan(lifespanMillis);
            e.setMaxIdle(maxIdleTimeMillis);
         } else {
            o = e.setValue(value);
            if (e.isRemoved()) {
               e.setRemoved(false);
               e.setValid(true);
               o = null;
            }
            e.setLifespan(lifespanMillis);
            e.setMaxIdle(maxIdleTimeMillis);
         }
      }
      return o;
   }
View Full Code Here

Examples of org.infinispan.container.entries.MVCCEntry

      // first check if the container contains the key we need.  Try and load this into the context.
      CacheEntry e = ctx.lookupEntry(key);
      if (e == null || e.isNull() || e.getValue() == null) {
         InternalCacheEntry loaded = loader.load(key);
         if (loaded != null) {
            MVCCEntry mvccEntry = entryFactory.wrapEntryForPut(ctx, key, loaded, false, cmd);
            recordLoadedEntry(ctx, key, mvccEntry, loaded);
            return true;
         } else {
            return false;
         }
View Full Code Here

Examples of org.infinispan.container.entries.MVCCEntry

         return null;
      }
      //this might happen if the value was fetched from a cache loader
      if (cacheEntry instanceof MVCCEntry) {
         if (trace) log.trace("Handling an internal cache entry...");
         MVCCEntry mvccEntry = (MVCCEntry) cacheEntry;
         return entryFactory.createValue(mvccEntry);
      } else {
         InternalCacheEntry internalCacheEntry = (InternalCacheEntry) cacheEntry;
         return internalCacheEntry.toInternalCacheValue();
      }
View Full Code Here

Examples of org.infinispan.container.entries.MVCCEntry

      if (cacheEntry == null) {
         cacheEntry = getFromContainer(key);

         // do not bother wrapping though if this is not in a tx.  repeatable read etc are all meaningless unless there is a tx.
         if (useRepeatableRead) {
            MVCCEntry mvccEntry;
            if (cacheEntry == null) {
               mvccEntry = createWrappedEntry(key, null, null, false, false, -1);
            } else {
               mvccEntry = createWrappedEntry(key, cacheEntry.getValue(), cacheEntry.getVersion(), false, false, cacheEntry.getLifespan());
               // If the original entry has changeable state, copy state flags to the new MVCC entry.
               if (cacheEntry instanceof StateChangingEntry && mvccEntry != null)
                  mvccEntry.copyStateFlagsFrom((StateChangingEntry) cacheEntry);
            }

            if (mvccEntry != null) ctx.putLookedUpEntry(key, mvccEntry);
            return mvccEntry;
         } else if (cacheEntry != null) { // if not in transaction and repeatable read, or simply read committed (regardless of whether in TX or not), do not wrap
View Full Code Here

Examples of org.infinispan.container.entries.MVCCEntry

      return wrapEntry(ctx, key);
   }

   @Override
   public final  MVCCEntry wrapEntryForReplace(InvocationContext ctx, Object key) throws InterruptedException {
      MVCCEntry mvccEntry = wrapEntry(ctx, key);
      if (mvccEntry == null) {
         // make sure we record this! Null value since this is a forced lock on the key
         ctx.putLookedUpEntry(key, null);
      }
      return mvccEntry;
View Full Code Here

Examples of org.infinispan.container.entries.MVCCEntry

   }

   @Override
   public final  MVCCEntry wrapEntryForRemove(InvocationContext ctx, Object key) throws InterruptedException {
      CacheEntry cacheEntry = getFromContext(ctx, key);
      MVCCEntry mvccEntry = null;
      if (cacheEntry != null) {
         if (cacheEntry instanceof MVCCEntry && !(cacheEntry instanceof NullMarkerEntry)) {
            mvccEntry = (MVCCEntry) cacheEntry;
         } else {
            mvccEntry = wrapMvccEntryForRemove(ctx, key, cacheEntry);
         }
      } else {
         InternalCacheEntry ice = getFromContainer(key);
         if (ice != null) {
            mvccEntry = wrapInternalCacheEntryForPut(ctx, key, ice);
            mvccEntry.setRemoved(true);
         }
      }
      if (mvccEntry == null) {
         // make sure we record this! Null value since this is a forced lock on the key
         ctx.putLookedUpEntry(key, null);
      } else {
         mvccEntry.copyForUpdate(container, localModeWriteSkewCheck);
      }
      return mvccEntry;
   }
View Full Code Here

Examples of org.infinispan.container.entries.MVCCEntry

   @Override
   public final MVCCEntry wrapEntryForPut(InvocationContext ctx, Object key, InternalCacheEntry icEntry,
         boolean undeleteIfNeeded, FlagAffectedCommand cmd) throws InterruptedException {
      CacheEntry cacheEntry = getFromContext(ctx, key);
      MVCCEntry mvccEntry;
      if (cacheEntry != null && cacheEntry.isNull()) cacheEntry = null;
      if (cacheEntry != null) {
         mvccEntry = wrapMvccEntryForPut(ctx, key, cacheEntry);
         mvccEntry.undelete(undeleteIfNeeded);
      } else {
         InternalCacheEntry ice = (icEntry == null ? getFromContainer(key) : icEntry);
         // A putForExternalRead is putIfAbsent, so if key present, do nothing
         if (ice != null && cmd.hasFlag(Flag.PUT_FOR_EXTERNAL_READ)) {
            // make sure we record this! Null value since this is a forced lock on the key
            ctx.putLookedUpEntry(key, null);
            return null;
         }

         mvccEntry = ice != null ?
             wrapInternalCacheEntryForPut(ctx, key, ice) :
             newMvccEntryForPut(ctx, key);
      }
      mvccEntry.copyForUpdate(container, localModeWriteSkewCheck);
      return mvccEntry;
   }
View Full Code Here

Examples of org.infinispan.container.entries.MVCCEntry

      if (trace) log.tracef("Retrieved from container %s", ice);
      return ice;
   }

   private MVCCEntry newMvccEntryForPut(InvocationContext ctx, Object key) {
      MVCCEntry mvccEntry;
      if (trace) log.trace("Creating new entry.");
      notifier.notifyCacheEntryCreated(key, true, ctx);
      mvccEntry = createWrappedEntry(key, null, null, true, false, -1);
      mvccEntry.setCreated(true);
      ctx.putLookedUpEntry(key, mvccEntry);
      return mvccEntry;
   }
View Full Code Here

Examples of org.infinispan.container.entries.MVCCEntry

      if (cacheEntry instanceof MVCCEntry) return (MVCCEntry) cacheEntry;
      return wrapInternalCacheEntryForPut(ctx, key, (InternalCacheEntry) cacheEntry);
   }

   private MVCCEntry wrapInternalCacheEntryForPut(InvocationContext ctx, Object key, InternalCacheEntry cacheEntry) {
      MVCCEntry mvccEntry = createWrappedEntry(key, cacheEntry.getValue(), cacheEntry.getVersion(), false, false, cacheEntry.getLifespan());
      ctx.putLookedUpEntry(key, mvccEntry);
      return mvccEntry;
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.