Package org.infinispan.container.entries

Examples of org.infinispan.container.entries.MVCCEntry


      ctx.putLookedUpEntry(key, mvccEntry);
      return mvccEntry;
   }

   private MVCCEntry wrapMvccEntryForRemove(InvocationContext ctx, Object key, CacheEntry cacheEntry) {
      MVCCEntry mvccEntry = createWrappedEntry(key, cacheEntry.getValue(), cacheEntry.getVersion(), false, true, cacheEntry.getLifespan());
      // If the original entry has changeable state, copy state flags to the new MVCC entry.
      if (cacheEntry instanceof StateChangingEntry)
         mvccEntry.copyStateFlagsFrom((StateChangingEntry) cacheEntry);

      ctx.putLookedUpEntry(key, mvccEntry);
      return mvccEntry;
   }
View Full Code Here


      return mvccEntry;
   }

   private MVCCEntry wrapEntry(InvocationContext ctx, Object key) {
      CacheEntry cacheEntry = getFromContext(ctx, key);
      MVCCEntry mvccEntry = null;
      if (cacheEntry != null) {
         mvccEntry = wrapMvccEntryForPut(ctx, key, cacheEntry);
      } else {
         InternalCacheEntry ice = getFromContainer(key);
         if (ice != null) {
            mvccEntry = wrapInternalCacheEntryForPut(ctx, ice.getKey(), ice);
         }
      }
      if (mvccEntry != null)
         mvccEntry.copyForUpdate(container, localModeWriteSkewCheck);
      return mvccEntry;
   }
View Full Code Here

         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

   }

   @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, entryValue == null, true, ctx, this);

         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

   @Override
   public Object perform(InvocationContext ctx) throws Throwable {
      for (CacheEntry e : ctx.getLookedUpEntries().values()) {
         if (e instanceof MVCCEntry) {
            MVCCEntry me = (MVCCEntry) e;
            Object k = me.getKey(), v = me.getValue();
            notifier.notifyCacheEntryRemoved(k, v, v, true, ctx, this);
            me.setRemoved(true);
            me.setValid(false);
         }
      }
      return null;
   }
View Full Code Here

   @Override
   public Object perform(InvocationContext ctx) throws Throwable {
      for (Entry<Object, Object> e : map.entrySet()) {
         Object key = e.getKey();
         MVCCEntry me = lookupMvccEntry(ctx, key);
         if (me != null) {
            Object value = me.getValue();
            notifier.notifyCacheEntryModified(
                  key, value, value == null, true, ctx, this);
            me.setValue(e.getValue());
            me.setLifespan(lifespanMillis);
            me.setMaxIdle(maxIdleTimeMillis);
         }
      }
      return null;
   }
View Full Code Here

      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()) || ignorePreviousValue) {
            e.setChanged(true);
            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

   public Object perform(InvocationContext ctx) throws Throwable {
      // Perform the regular put
      Object r = super.perform(ctx);

      // Apply the version to the entry
      MVCCEntry e = (MVCCEntry) ctx.lookupEntry(key);
      if (e != null && !(value instanceof Delta)) {
         e.setVersion(version);
      }

      return r;
   }
View Full Code Here

   public Object perform(InvocationContext ctx) throws Throwable {
      // Perform the regular replace
      Object r = super.perform(ctx);

      // Apply the version to the entry, if conditional operation succeded
      MVCCEntry e = (MVCCEntry) ctx.lookupEntry(key);
      if (e.isChanged())
         e.setVersion(version);

      return r;
   }
View Full Code Here

      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) return returnValue(null, false);   

            if (oldValue == null || oldValue.equals(e.getValue())) {
               Object old = e.setValue(newValue);
               e.setLifespan(lifespanMillis);
               e.setMaxIdle(maxIdleTimeMillis);
               return returnValue(old, true);
            }
            return returnValue(null, false);
         } else {
            // for remotely originating calls, this doesn't check the status of what is under the key at the moment
            Object old = e.setValue(newValue);
            e.setLifespan(lifespanMillis);
            e.setMaxIdle(maxIdleTimeMillis);
            return returnValue(old, true);
         }
      }

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

TOP

Related Classes of org.infinispan.container.entries.MVCCEntry

Copyright © 2018 www.massapicom. 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.