Package org.infinispan.marshall.core

Examples of org.infinispan.marshall.core.MarshalledEntry


         taskCount++;
         final Object key = k;
         ecs.submit(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
               final MarshalledEntry marshalledEntry = _load(key, fetchValue, fetchMetadata);
               if (marshalledEntry != null) {
                  task.processEntry(marshalledEntry, taskContext);
               }
               return null;
            }
View Full Code Here


               long now = ctx.getTimeService().wallClockTime();
               for (Map.Entry<byte[], byte[]> entry : batch) {
                  if (taskContext.isStopped()) {break;}
                  Object key = unmarshall(entry.getKey());
                  if (filter == null || filter.shouldLoadKey(key)) {
                     MarshalledEntry unmarshall = (MarshalledEntry) unmarshall(entry.getValue());
                     boolean isExpired = unmarshall.getMetadata() != null && unmarshall.getMetadata().isExpired(now);
                     if (!isExpired) {
                        cacheLoaderTask.processEntry(unmarshall, taskContext);
                     }
                  }
               }
View Full Code Here

   }

   @Override
   public MarshalledEntry load(Object key)  {
      try {
         MarshalledEntry me = (MarshalledEntry) unmarshall(db.get(marshall(key)));
         if (me == null) return null;

         InternalMetadata meta = me.getMetadata();
         if (meta != null && meta.isExpired(ctx.getTimeService().wallClockTime())) {
            return null;
         }
         return me;
      } catch (Exception e) {
View Full Code Here

               byte[] keyBytes = marshall(key);

               byte[] b = db.get(keyBytes);
               if (b == null)
                  continue;
               MarshalledEntry me = (MarshalledEntry) ctx.getMarshaller().objectFromByteBuffer(b);
               if (me.getMetadata() != null && me.getMetadata().isExpired(ctx.getTimeService().wallClockTime())) {
                  // somewhat inefficient to FIND then REMOVE...
                  db.delete(keyBytes);
                  count++;
               }
            }
View Full Code Here

      if (!isRetrieval && !ctx.isOriginLocal() && !forceLoad(key, cmd.getFlags())) return null;

      // 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) {
         MarshalledEntry loaded = persistenceManager.loadFromAllStores(key);
         if(loaded == null)
            return Boolean.FALSE;
         InternalMetadata metadata = loaded.getMetadata();
         if (metadata != null && metadata.isExpired(timeService.wallClockTime())) {
            return Boolean.FALSE;
         }
         InternalCacheEntry ice = iceFactory.create(loaded.getKey(), loaded.getValue(), metadata);
         CacheEntry wrappedEntry;
         if (cmd instanceof ApplyDeltaCommand) {
            ctx.putLookedUpEntry(key, ice);
            wrappedEntry = entryFactory.wrapEntryForDelta(ctx, key, ((ApplyDeltaCommand) cmd).getDelta());
         } else {
View Full Code Here

               wrapInternalCacheEntry(ctx, key, cmd, oldEntry, isDelta);
               isLoaded.set(null); //not loaded
               return oldEntry; //no changes in container
            }

            MarshalledEntry loaded = internalLoadAndUpdateStats(key, ctx);
            if(loaded == null) {
               isLoaded.set(Boolean.FALSE); //not loaded
               return null; //no changed in container
            }

            InternalCacheEntry newEntry;
            InternalMetadata metadata = loaded.getMetadata();
            if (metadata != null) {
               Metadata actual = metadata instanceof InternalMetadataImpl ? ((InternalMetadataImpl) metadata).actual() :
                     metadata;
               newEntry = factory.create(loaded.getKey(), loaded.getValue(), actual, metadata.created(), metadata.lifespan(),
                                       metadata.lastUsed(), metadata.maxIdle());
            } else {
               //metadata is null!
               newEntry = factory.create(loaded.getKey(), loaded.getValue(), (Metadata) null);
            }
            CacheEntry wrappedEntry = wrapInternalCacheEntry(ctx, key, cmd, newEntry, isDelta);
            recordLoadedEntry(ctx, key, wrappedEntry, newEntry, cmd);
            //afterSuccessfullyLoaded(wrappedEntry);
View Full Code Here

      try {
         for (CacheLoader l : loaders) {
            if (!context.isOriginLocal() && isLocalOnlyLoader(l))
               continue;

            MarshalledEntry load = l.load(key);
            if (load != null)
               return load;
         }
         return null;
      } finally {
View Full Code Here

      return isLoaded.get();
   }

   private MarshalledEntry internalLoadAndUpdateStats(Object key, InvocationContext context) {
      final MarshalledEntry loaded = persistenceManager.loadFromAllStores(key, context);
      if (getLog().isTraceEnabled()) {
         getLog().tracef("Loaded %s for key %s from persistence.", loaded, key);
      }
      if(loaded == null) {
         return null;
      }
      InternalMetadata metadata = loaded.getMetadata();
      if (metadata != null && metadata.isExpired(timeService.wallClockTime())) {
         return null;
      }
      return loaded;
   }
View Full Code Here

   @Override
   public MarshalledEntry loadFromAllStores(Object key) {
      storesMutex.readLock().lock();
      try {
         for (CacheLoader l : loaders) {
            MarshalledEntry load = l.load(key);
            if (load != null)
               return load;
         }
         return null;
      } finally {
View Full Code Here

               long now = ctx.getTimeService().wallClockTime();
               for (Map.Entry<byte[], byte[]> entry : batch) {
                  if (taskContext.isStopped()) {break;}
                  Object key = unmarshall(entry.getKey());
                  if (filter == null || filter.accept(key)) {
                     MarshalledEntry unmarshall = (MarshalledEntry) unmarshall(entry.getValue());
                     boolean isExpired = unmarshall.getMetadata() != null && unmarshall.getMetadata().isExpired(now);
                     if (!isExpired) {
                        cacheLoaderTask.processEntry(unmarshall, taskContext);
                     }
                  }
               }
View Full Code Here

TOP

Related Classes of org.infinispan.marshall.core.MarshalledEntry

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.