Package org.infinispan.persistence.spi

Examples of org.infinispan.persistence.spi.MarshalledEntry


         @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


      HashSet<IndexScopedKey> keysCollector = new HashSet<IndexScopedKey>();
      loadSomeKeys(keysCollector, Collections.EMPTY_SET, toLoadElements);
      for (IndexScopedKey key : keysCollector) {
         Object value = load(key);
         if (value != null) {
            MarshalledEntry cacheEntry = new MarshalledEntryImpl(key, value, null, marshaller);
            entriesCollector.add(cacheEntry);
         }
      }
   }
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

         taskCount++;
         final Object key = k;
         ecs.submit(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
               final MarshalledEntry marshalledEntry = _load(key, fetchValue, fetchMetadata);
               task.processEntry(marshalledEntry, taskContext);
               return null;
            }
         });
      }
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 = new MarshalledEntryImpl(key, icv.getKey(), icv.getValue(), ctx.getMarshaller());
         }
      } catch (SQLException e) {
         log.sqlFailureReadingKey(key, lockingKey, e);
         throw new CacheLoaderException(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 = new MarshalledEntryImpl(key, kvp.getKey(), kvp.getValue(), ctx.getMarshaller());
                  } else {
                     entry = new MarshalledEntryImpl(key, (Object)null, null, ctx.getMarshaller());
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

TOP

Related Classes of org.infinispan.persistence.spi.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.