Package org.infinispan.container.entries

Examples of org.infinispan.container.entries.InternalCacheEntry


   @Override
   public InternalCacheEntry get(Object k) {
      int h = hash(k.hashCode());
      Segment s = segmentFor(h);
      LinkedEntry le = s.get(k, h);
      InternalCacheEntry ice = null;
      if (le != null) {
         ice = le.e;
         if (isMarkedForRemoval(le)) unlink(le);
      }
      if (ice != null) {
         if (ice.isExpired()) {
            remove(k);
            ice = null;
         } else {
            ice.touch();
            updateLinks(le);
         }
      }
      return ice;
   }
View Full Code Here


      s.lock();
      LinkedEntry le;
      boolean newEntry = false;
      try {
         le = s.get(k, h);
         InternalCacheEntry ice = le == null ? null : le.e;
         if (ice == null) {
            newEntry = true;
            ice = InternalEntryFactory.create(k, v, lifespan, maxIdle);
            le = new LinkedEntry(ice);
         } else {
            ice.setValue(v);
            ice = ice.setLifespan(lifespan).setMaxIdle(maxIdle);
            // need to do this anyway since the ICE impl may have changed
            le.e = ice;
         }

         s.locklessPut(k, h, le);
View Full Code Here

      @SuppressWarnings("unchecked")
      public boolean equals(Object o) {
         if (!(o instanceof InternalCacheEntry))
            return false;

         InternalCacheEntry entry = (InternalCacheEntry) o;
         return entry.equals(this.entry);
      }
View Full Code Here

            key = ((MarshalledValue) key).get();
         }
         if (value instanceof MarshalledValue) {
            value = ((MarshalledValue) value).get();
         }
         InternalCacheEntry newEntry = Immutables.immutableInternalCacheEntry(InternalEntryFactory.create(key, value,
                  entry.getCreated(), entry.getLifespan(), entry.getLastUsed(), entry.getMaxIdle()));
         copy.add(newEntry);
      }
      return Immutables.immutableSetWrap(copy);
   }
View Full Code Here

    * Loads an entry from loader
    */
   private MVCCEntry loadEntry(InvocationContext ctx, Object key, MVCCEntry entry) throws Exception {
      log.trace("Loading key {0}", key);

      InternalCacheEntry storedEntry = loader.load(key);
      boolean entryExists = (storedEntry != null);
      if (log.isTraceEnabled()) log.trace("Entry exists in loader? " + entryExists);

      if (getStatisticsEnabled()) {
         if (entryExists) {
            cacheLoads.incrementAndGet();
         } else {
            cacheMisses.incrementAndGet();
         }
      }

      if (entryExists) {
         sendNotification(key, true, ctx);
         entry.setValue(storedEntry.getValue());
         entry.setLifespan(storedEntry.getLifespan());
         entry.setValid(true);

         notifier.notifyCacheEntryLoaded(key, false, ctx);
         sendNotification(key, false, ctx);
      }
View Full Code Here

   }
     

   private InternalCacheValue loadValue(CacheStore cs, Object k) {
      try {
         InternalCacheEntry ice = cs.load(k);
         return ice == null ? null : ice.toInternalCacheValue();
      } catch (CacheLoaderException cle) {
         log.warn("Unable to load " + k + " from cache loader", cle);
      }
      return null;
   }
View Full Code Here

   }

   private Object realRemoteGet(InvocationContext ctx, Object key, boolean storeInL1) throws Throwable {
      if (trace) log.trace("Doing a remote get for key {0}", key);
      // attempt a remote lookup
      InternalCacheEntry ice = dm.retrieveFromRemoteSource(key);

      if (ice != null) {
         if (storeInL1 && isL1CacheEnabled) {
            if (trace) log.trace("Caching remotely retrieved entry for key {0} in L1", key);
            long lifespan = ice.getLifespan() < 0 ? configuration.getL1Lifespan() : Math.min(ice.getLifespan(), configuration.getL1Lifespan());
            PutKeyValueCommand put = cf.buildPutKeyValueCommand(ice.getKey(), ice.getValue(), lifespan, -1);
            entryFactory.wrapEntryForWriting(ctx, key, true, false, ctx.hasLockedKey(key), false, false);
            invokeNextInterceptor(ctx, put);
         } else {
            if (trace) log.trace("Not caching remotely retrieved entry for key {0} in L1", key);
         }
         return ice.getValue();
      }
      return null;
   }
View Full Code Here

   }
     

   private InternalCacheValue loadValue(CacheStore cs, Object k) {
      try {
         InternalCacheEntry ice = cs.load(k);
         return ice == null ? null : ice.toInternalCacheValue();
      } catch (CacheLoaderException cle) {
         log.warn("Unable to load " + k + " from cache loader", cle);
      }
      return null;
   }
View Full Code Here

   @Override
   public Object perform(InvocationContext ctx) throws Throwable {
      if (forRehash && config.isL1OnRehash()) {
         for (Object k : getKeys()) {
            InternalCacheEntry ice = dataContainer.get(k);
            if (ice != null) {
               if (log.isTraceEnabled()) log.trace("Not removing, instead putting entry into L1.");
               dataContainer.put(k, ice.getValue(), config.getL1Lifespan(), config.getExpirationMaxIdle());
            }
         }
      } else {
         for (Object k : getKeys()) {
            if (!dm.isLocal(k)) invalidate(ctx, k);
View Full Code Here

            key = ((MarshalledValue) key).get();
         }
         if (value instanceof MarshalledValue) {
            value = ((MarshalledValue) value).get();
         }
         InternalCacheEntry newEntry = Immutables.immutableInternalCacheEntry(InternalEntryFactory.create(key, value,
                 entry.getCreated(), entry.getLifespan(), entry.getLastUsed(), entry.getMaxIdle()));
         copy.add(newEntry);
      }
      return Immutables.immutableSetWrap(copy);
   }
View Full Code Here

TOP

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

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.