Package org.infinispan.container.entries

Examples of org.infinispan.container.entries.CacheEntry


   }

   @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);
View Full Code Here


      return mvccEntry;
   }
  
   @Override
   public CacheEntry wrapEntryForDelta(InvocationContext ctx, Object deltaKey, Delta delta ) throws InterruptedException {
      CacheEntry cacheEntry = getFromContext(ctx, deltaKey);
      DeltaAwareCacheEntry deltaAwareEntry = null;
      if (cacheEntry != null) {       
         deltaAwareEntry = wrapEntryForDelta(ctx, deltaKey, cacheEntry);
      } else {                    
         InternalCacheEntry ice = getFromContainer(deltaKey);
View Full Code Here

      return e;

   }

   private CacheEntry getFromContext(InvocationContext ctx, Object key) {
      final CacheEntry cacheEntry = ctx.lookupEntry(key);
      if (trace) log.tracef("Exists in context? %s ", cacheEntry);
      return cacheEntry;
   }
View Full Code Here

      ctx.putLookedUpEntry(key, mvccEntry);
      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);
View Full Code Here

         performLocalWriteSkewCheck(ctx, key);
      }
   }

   private void performLocalWriteSkewCheck(TxInvocationContext ctx, Object key) {
      CacheEntry ce = ctx.lookupEntry(key);
      if (ce instanceof RepeatableReadEntry && ctx.getCacheTransaction().keyRead(key)) {
         ((RepeatableReadEntry) ce).performLocalWriteSkewCheck(dataContainer, true);
      }
   }
View Full Code Here

   public boolean isFlagsUninitialized() {
      return flags == null;
   }

   public boolean hasLockedKey(Object key) {
      CacheEntry e = lookupEntry(key);
      if (e == null) {
         return getLookedUpEntries().containsKey(key); // this will chk if the key is present even if the value is null
      } else {
         return e.isChanged();
      }
   }
View Full Code Here

   private AtomicHashMap<K, V> getDeltaMapForRead() {
      return toMap(cache.get(deltaMapKey));
   }

   private AtomicHashMap<K, V> getDeltaMapForWrite(InvocationContext ctx) {
      CacheEntry lookedUpEntry = ctx.lookupEntry(deltaMapKey);
      boolean lockedAndCopied = lookedUpEntry != null && lookedUpEntry.isChanged() &&
            toMap(lookedUpEntry.getValue()).copied;

      if (lockedAndCopied) {
         return getDeltaMapForRead();
      } else {
         // acquire WL
View Full Code Here

   public void setReturnCacheEntry(boolean returnCacheEntry) {
      this.returnCacheEntry = returnCacheEntry;
   }

   public Object perform(InvocationContext ctx) throws Throwable {
      CacheEntry entry = ctx.lookupEntry(key);
      if (entry == null || entry.isNull()) {
         if (trace) log.trace("Entry not found");
         return null;
      }
      if (entry.isRemoved()) {
         if (trace) log.trace("Entry has been deleted and is of type " + entry.getClass().getSimpleName());
         return null;
      }
      notifier.notifyCacheEntryVisited(key, true, ctx);
      Object result = returnCacheEntry ? entry : entry.getValue();
      if (trace) log.trace("Found value " + result);
      notifier.notifyCacheEntryVisited(key, false, ctx);
      return result;
   }
View Full Code Here

      return useRepeatableRead ? new RepeatableReadEntry(key, value, lifespan) : new ReadCommittedEntry(key, value, lifespan);
   }

   public final CacheEntry wrapEntryForReading(InvocationContext ctx, Object key) throws InterruptedException {
      CacheEntry cacheEntry;
      if (ctx.hasFlag(Flag.FORCE_WRITE_LOCK)) {
         if (trace) log.trace("Forcing lock on reading");
         return wrapEntryForWriting(ctx, key, false, false, false, false, false);
      } else if ((cacheEntry = ctx.lookupEntry(key)) == null) {
         if (trace) log.trace("Key {0} is not in context, fetching from container.", key);
         // simple implementation.  Peek the entry, wrap it, put wrapped entry in the context.
         cacheEntry = container.get(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 && ctx.isInTxScope()) {
            MVCCEntry mvccEntry = cacheEntry == null ?
                  createWrappedEntry(key, null, false, false, -1) :
                  createWrappedEntry(key, cacheEntry.getValue(), false, false, cacheEntry.getLifespan());
            if (mvccEntry != null) ctx.putLookedUpEntry(key, mvccEntry);
            return mvccEntry;
         }
         // if not in transaction and repeatable read, or simply read committed (regardless of whether in TX or not), do not wrap
         if (cacheEntry != null) ctx.putLookedUpEntry(key, cacheEntry);
View Full Code Here

   public MVCCEntry wrapEntryForWriting(InvocationContext ctx, InternalCacheEntry entry, boolean createIfAbsent, boolean forceLockIfAbsent, boolean alreadyLocked, boolean forRemoval, boolean undeleteIfNeeded) throws InterruptedException {
      return wrapEntryForWriting(ctx, entry.getKey(), entry, createIfAbsent, forceLockIfAbsent, alreadyLocked, forRemoval, undeleteIfNeeded);
   }

   private MVCCEntry wrapEntryForWriting(InvocationContext ctx, Object key, InternalCacheEntry entry, boolean createIfAbsent, boolean forceLockIfAbsent, boolean alreadyLocked, boolean forRemoval, boolean undeleteIfNeeded) throws InterruptedException {
      CacheEntry cacheEntry = ctx.lookupEntry(key);
      MVCCEntry mvccEntry = null;
      if (createIfAbsent && cacheEntry != null && cacheEntry.isNull()) cacheEntry = null;
      if (cacheEntry != null) // exists in context!  Just acquire lock if needed, and wrap.
      {
         if (trace) log.trace("Exists in context.");
         // Acquire lock if needed. Add necessary check for skip locking in advance in order to avoid marshalled value issues
         if (alreadyLocked || ctx.hasFlag(Flag.SKIP_LOCKING) || acquireLock(ctx, key)) {

            if (cacheEntry instanceof MVCCEntry && (!forRemoval || !(cacheEntry instanceof NullMarkerEntry))) {
               mvccEntry = (MVCCEntry) cacheEntry;
            } else {
               // this is a read-only entry that needs to be copied to a proper read-write entry!!
               mvccEntry = createWrappedEntry(key, cacheEntry.getValue(), false, forRemoval, cacheEntry.getLifespan());
               cacheEntry = mvccEntry;
               ctx.putLookedUpEntry(key, cacheEntry);
            }

            // create a copy of the underlying entry
            mvccEntry.copyForUpdate(container, writeSkewCheck);
         } else if (ctx.hasFlag(Flag.FORCE_WRITE_LOCK)) {
            // If lock was already held and force write lock is on, just wrap
            if (cacheEntry instanceof MVCCEntry && (!forRemoval || !(cacheEntry instanceof NullMarkerEntry))) {
               mvccEntry = (MVCCEntry) cacheEntry;
            }
         }

         if (cacheEntry.isRemoved() && createIfAbsent && undeleteIfNeeded) {
            if (trace) log.trace("Entry is deleted in current scope.  Need to un-delete.");
            if (mvccEntry != cacheEntry) mvccEntry = (MVCCEntry) cacheEntry;
            mvccEntry.setRemoved(false);
            mvccEntry.setValid(true);
         }

         return mvccEntry;

      } else {
         boolean lockAcquired = false;
         if (!alreadyLocked) {
            lockAcquired = acquireLock(ctx, key);
         }
         // else, fetch from dataContainer or used passed entry.
         cacheEntry = entry != null ? entry : container.get(key);
         if (cacheEntry != null) {
            if (trace) log.trace("Retrieved from container.");
            // exists in cache!  Just acquire lock if needed, and wrap.
            // do we need a lock?
            boolean needToCopy = alreadyLocked || lockAcquired || ctx.hasFlag(Flag.SKIP_LOCKING); // even if we do not acquire a lock, if skip-locking is enabled we should copy
            mvccEntry = createWrappedEntry(key, cacheEntry.getValue(), false, false, cacheEntry.getLifespan());
            ctx.putLookedUpEntry(key, mvccEntry);
            if (needToCopy) mvccEntry.copyForUpdate(container, writeSkewCheck);
         } else if (createIfAbsent) {
            // this is the *only* point where new entries can be created!!
            if (trace) log.trace("Creating new entry.");
View Full Code Here

TOP

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

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.