Package org.infinispan.marshall.core

Examples of org.infinispan.marshall.core.MarshalledEntry


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


            }
            marshalledEntry = db.get(marshall(key));
         } finally {
            semaphore.release();
         }
         MarshalledEntry me = (MarshalledEntry) unmarshall(marshalledEntry);
         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);
               // TODO race condition: the entry could be updated between the get and delete!
               if (me.getMetadata() != null && me.getMetadata().isExpired(now)) {
                  // somewhat inefficient to FIND then REMOVE...
                  db.delete(keyBytes);
                  purgeListener.entryPurged(key);
                  count++;
               }
View Full Code Here

   public final boolean removeEntry(Object key) {
      return entries.remove(key) != null;
   }

   public final MarshalledEntry getEntry(Object key, TimeService timeService) {
      MarshalledEntry marshalledEntry = entries.get(key);
      if (marshalledEntry == null)
         return null;
      if (marshalledEntry.getMetadata() != null && marshalledEntry.getMetadata().isExpired(timeService.wallClockTime())) {
         return null;
      }
      return marshalledEntry;
   }
View Full Code Here

      Set<Object> result = new HashSet<Object>();
      long currentTimeMillis = 0;
      Iterator<Map.Entry<Object, MarshalledEntry>> entryIterator = entries.entrySet().iterator();
      while (entryIterator.hasNext()) {
         Map.Entry<Object, MarshalledEntry> entry = entryIterator.next();
         final MarshalledEntry value = entry.getValue();
         if (value.getMetadata() != null) {
            if (currentTimeMillis == 0)
               currentTimeMillis = timeService.wallClockTime();
            if (value.getMetadata().isExpired(currentTimeMillis)) {
               result.add(entry.getKey());
               entryIterator.remove();
            }
         }
      }
View Full Code Here

   public Map<Object, MarshalledEntry> getStoredEntries(KeyFilter filter, TimeService timeService) {
      filter = PersistenceUtil.notNull(filter);
      long currentTimeMillis = timeService.wallClockTime();
      Map<Object, MarshalledEntry> result = new HashMap<Object, MarshalledEntry>();
      for (Map.Entry<Object, MarshalledEntry> entry : getStoredEntries().entrySet()) {
         MarshalledEntry me = entry.getValue();
         if (!isExpired(currentTimeMillis, me) && filter.accept(entry.getKey()))
            result.put(entry.getKey(), me);
      }
      return result;
   }
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

         public Object call() throws Exception {
            try {
               for (Object k : batch) {
                  if (taskContext.isStopped())
                     break;
                  MarshalledEntry load = load(k);
                  if (load != null)
                     cacheLoaderTask.processEntry(load, taskContext);
               }
               return null;
            } catch (Exception e) {
View Full Code Here

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

         // notify listeners that this entry is about to be passivated
         notifier.notifyCacheEntryPassivated(key, entry.getValue(), true,
               ImmutableContext.INSTANCE, null);
         if (trace) log.tracef("Passivating entry %s", key);
         try {
            MarshalledEntry marshalledEntry = marshalledEntryFactory.newMarshalledEntry(entry.getKey(), entry.getValue(),
                                                                                        internalMetadata(entry));
            persistenceManager.writeToAllStores(marshalledEntry, BOTH);
            if (statsEnabled) passivations.getAndIncrement();
         } catch (CacheException e) {
            log.unableToPassivateEntry(key, e);
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.