Package org.infinispan.container.entries

Examples of org.infinispan.container.entries.InternalCacheEntry


   }

   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) {
            if (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 {
               CacheEntry ce = ctx.lookupEntry(key);
               if (ce == null || ce.isNull() || ce.isLockPlaceholder()) {
                  if (ce != null && ce.isChanged())
                     ce.setValue(ice.getValue());
                  else
                     ctx.putLookedUpEntry(key, ice);
               }
            }
         } 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


               entryFactory.releaseLock(key);
            }
         }

         // we *may* need to load this.
         InternalCacheEntry loaded = loader.load(key);
         if (loaded == null) {
            if (log.isTraceEnabled()) {
               log.trace("No need to load.  Key doesn't exist in the loader.");
            }
            if (keyLocked) {
View Full Code Here

         }

         @Override
         public boolean fromStreamProcess(Object objFromStream, PreparedStatement ps, ObjectInput objectInput) throws SQLException, CacheLoaderException, InterruptedException {
            if (objFromStream instanceof InternalCacheEntry) {
               InternalCacheEntry se = (InternalCacheEntry) objFromStream;
               ByteBuffer buffer = JdbcUtil.marshall(getMarshaller(), se.toInternalCacheValue());
               ps.setBinaryStream(1, buffer.getStream(), buffer.getLength());
               ps.setLong(2, se.getExpiryTime());
               ps.setString(3, (String) se.getKey());
               return true;
            } else {
               return false;
            }
         }
View Full Code Here

      }
   }

   @Override
   protected InternalCacheEntry loadLockSafe(Object key, String lockingKey) throws CacheLoaderException {
      InternalCacheEntry storedEntry = readStoredEntry(key, lockingKey);
      if (storedEntry != null && storedEntry.isExpired(System.currentTimeMillis())) {
         if (log.isTraceEnabled()) {
            log.tracef("Not returning '%s' as it is expired. It will be removed from DB by purging thread!", storedEntry);
         }
         return null;
      }
View Full Code Here

   private InternalCacheEntry readStoredEntry(Object key, String lockingKey) throws CacheLoaderException {
      Connection conn = null;
      PreparedStatement ps = null;
      ResultSet rs = null;
      InternalCacheEntry storedEntry = null;
      try {
         String sql = tableManipulation.getSelectRowSql();
         conn = connectionFactory.getConnection();
         ps = conn.prepareStatement(sql);
         ps.setString(1, lockingKey);
View Full Code Here

    * {@inheritDoc} This implementation delegates to {@link StoredMap#get(Object)}.  If the object is expired, it will
    * not be returned.
    */
   public InternalCacheEntry load(Object key) throws CacheLoaderException {
      try {
         InternalCacheEntry s = cacheMap.get(key);
         if (s != null && s.isExpired()) {
            s = null;
         }
         return s;
      } catch (RuntimeException caught) {
         throw convertToCacheLoaderException("error loading key " + key, caught);
View Full Code Here

      super.start();
   }

   public InternalCacheEntry load(Object key) throws CacheLoaderException {
      try {
         InternalCacheEntry ice = unmarshall(tree.get(key), key);
         if (ice != null && ice.isExpired()) {
            remove(key);
            return null;
         }
         return ice;
      } catch (IOException e) {
View Full Code Here

      try {
         log.debug("fromStream()");
         int count = 0;
         while (true) {
            count++;
            InternalCacheEntry entry = (InternalCacheEntry) getMarshaller().objectFromObjectStream(in);
            if (entry == null)
               break;
            store(entry);
         }
         log.debug("read " + count + " entries");
View Full Code Here

    */
   private Object remoteGetAndStoreInL1(InvocationContext ctx, Object key) throws Throwable {
      if (ctx.isOriginLocal() && !dm.isLocal(key) && isNotInL1(key)) {
         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 (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);
               invokeNextInterceptor(ctx, put);
            } else {
               if (trace) log.trace("Not caching remotely retrieved entry for key {0} in L1", key);
            }
            return ice.getValue();
         }

      } else {
         if (trace)
            log.trace("Not doing a remote get for key {0} since entry is mapped to current node, or is in L1", key);
View Full Code Here

    *                   is present here in order to avoid hash recomputation.
    */
   protected InternalCacheEntry loadLockSafe(Object key, String lockingKey) throws CacheLoaderException {
      Bucket bucket = loadBucket(lockingKey);
      if (bucket == null) return null;
      InternalCacheEntry se = bucket.getEntry(key);

      if (se != null && se.isExpired()) {
         // We do not actually remove expired items from the store here.  We leave that up to the implementation,
         // since it may be a costly thing (remote connection, row locking on a JDBC store for example) for a
         // supposedly quick load operation.
         return null;
      } else {
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.