Package org.infinispan.marshall.core

Examples of org.infinispan.marshall.core.MarshalledEntry


      for (Object key : remoteCache.keySet()) {
         if (taskContext.isStopped())
            break;
         if (filter == null || filter.shouldLoadKey(key)) {
            try {
               MarshalledEntry marshalledEntry = load(key);
               if (marshalledEntry != null) {
                  task.processEntry(marshalledEntry, taskContext);
               }
            } catch (InterruptedException e) {
               Thread.currentThread().interrupt();
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

   }

   @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

         // 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, false);
            if (statsEnabled) passivations.getAndIncrement();
         } catch (CacheException e) {
            log.unableToPassivateEntry(key, e);
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

   public MarshalledEntry load(Object key) {
      String lockingKey = key2Str(key);
      Connection conn = null;
      PreparedStatement ps = null;
      ResultSet rs = null;
      MarshalledEntry storedValue = null;
      try {
         String sql = tableManipulation.getSelectRowSql();
         conn = connectionFactory.getConnection();
         ps = conn.prepareStatement(sql);
         ps.setString(1, lockingKey);
         rs = ps.executeQuery();
         if (rs.next()) {
            InputStream inputStream = rs.getBinaryStream(2);
            KeyValuePair<ByteBuffer, ByteBuffer> icv = JdbcUtil.unmarshall(ctx.getMarshaller(), inputStream);
            storedValue = ctx.getMarshalledEntryFactory().newMarshalledEntry(key, icv.getKey(), icv.getValue());
         }
      } catch (SQLException e) {
         log.sqlFailureReadingKey(key, lockingKey, e);
         throw new PersistenceException(String.format(
               "SQL error while fetching stored entry with key: %s, lockingKey: %s",
               key, lockingKey), e);
      } finally {
         JdbcUtil.safeClose(rs);
         JdbcUtil.safeClose(ps);
         connectionFactory.releaseConnection(conn);
      }
      if (storedValue != null && storedValue.getMetadata() != null &&
            storedValue.getMetadata().isExpired(ctx.getTimeService().wallClockTime())) {
         return null;
      }
      return storedValue;
   }
View Full Code Here

                  Object key = ((TwoWayKey2StringMapper) key2StringMapper).getKeyMapping(keyStr);
                  if (taskContext.isStopped()) break;
                  if (filter != null && !filter.shouldLoadKey(key))
                     continue;
                  InputStream inputStream = rs.getBinaryStream(1);
                  MarshalledEntry entry;
                  if (fetchValue || fetchMetadata) {
                     KeyValuePair<ByteBuffer, ByteBuffer> kvp = JdbcUtil.unmarshall(ctx.getMarshaller(), inputStream);
                     entry = ctx.getMarshalledEntryFactory().newMarshalledEntry(key, kvp.getKey(), kvp.getValue());
                  } else {
                     entry = ctx.getMarshalledEntryFactory().newMarshalledEntry(key, (Object)null, null);
View Full Code Here

         @Override
         public Object call() throws Exception {
            for (Object k : batch) {
               if (taskContext.isStopped())
                  break;
               MarshalledEntry load = load(k);
               if (load != null)
                  cacheLoaderTask.processEntry(load, taskContext);
            }
            return null;
         }
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.