Package org.infinispan.metadata

Examples of org.infinispan.metadata.InternalMetadata


                  if (trace) log.trace("Key " + key + " filtered");
                  continue;
               }

               Object tempEntity = null;
               InternalMetadata tempMetadata = null;
               boolean loaded = false;

               /* We need second entity manager because with MySQL we can't do streaming in parallel with other queries
                  using single connection */
               EntityManager emExec = emf.createEntityManager();
               try {
                  EntityTransaction txExec = emExec.getTransaction();
                  txExec.begin();
                  try {
                     do {
                        try {
                           tempEntity = fetchValue ? findEntity(emExec, key) : null;
                           tempMetadata = fetchMetadata ? getMetadata(emExec, key) : null;
                        } finally {
                           try {
                              txExec.commit();
                              loaded = true;
                           } catch (Exception e) {
                              log.trace("Failed to load once", e);
                           }
                        }
                     } while (!loaded);
                  } finally {
                     if (txExec != null && txExec.isActive()) {
                        txExec.rollback();
                     }

                  }
               } finally {
                  if (emExec != null) {
                     emExec.close();
                  }
               }
               final Object entity = tempEntity;
               final InternalMetadata metadata = tempMetadata;
               if (trace) log.trace("Processing " + key + " -> " + entity + "(" + metadata + ")");

               if (metadata != null && metadata.isExpired(timeService.wallClockTime())) continue;
               eacs.submit(new Callable<Void>() {
                  @Override
                  public Void call() throws Exception {
                     try {
                        final MarshalledEntry marshalledEntry = marshallerEntryFactory.newMarshalledEntry(key, entity, metadata);
View Full Code Here


         try {
            Object entity = findEntity(em, key);
            try {
               if (entity == null)
                  return null;
               InternalMetadata m = null;
               if (configuration.storeMetadata()) {
                  byte[] keyBytes;
                  try {
                     keyBytes = marshaller.objectToByteBuffer(key);
                  } catch (Exception e) {
                     throw new JpaStoreException("Failed to marshall key", e);
                  }
                  MetadataEntity metadata = findMetadata(em, new MetadataEntityKey(keyBytes));
                  if (metadata != null && metadata.getMetadata() != null) {
                     try {
                        m = (InternalMetadata) marshaller.objectFromByteBuffer(metadata.getMetadata());
                     } catch (Exception e) {
                        throw new JpaStoreException("Failed to unmarshall metadata", e);
                     }
                     if (m.isExpired(timeService.wallClockTime())) {
                        return null;
                     }
                  }
               }
               if (trace) log.trace("Loaded " + entity + " (" + m + ")");
View Full Code Here

      @Override
      public Void call() throws Exception {
         boolean loaded = false;
         Object entity;
         InternalMetadata metadata;

         // The loading of entries and metadata is offloaded to another thread.
         // We need second entity manager anyway because with MySQL we can't do streaming
         // in parallel with other queries using single connection
         EntityManager emExec = emf.createEntityManager();
         try {
            EntityTransaction txExec = emExec.getTransaction();
            txExec.begin();
            try {
               do {
                  try {
                     metadata = fetchMetadata ? getMetadata(emExec, key) : null;
                     if (trace) {
                        log.tracef("Fetched metadata (fetching? %s) %s", fetchMetadata, metadata);
                     }
                     if (metadata != null && metadata.isExpired(timeService.wallClockTime())) {
                        return null;
                     }
                     if (fetchValue) {
                        entity = findEntity(emExec, key);
                        if (trace) {
View Full Code Here

   @Override
   public void write(MarshalledEntry entry) throws CacheLoaderException {
      if (log.isTraceEnabled()) {
         log.tracef("Adding entry: %s", entry);
      }
      InternalMetadata metadata = entry.getMetadata();
      long lifespan = metadata != null ? metadata.lifespan() : -1;
      long maxIdle = metadata != null ? metadata.maxIdle() : -1;
      remoteCache.put(entry.getKey(), configuration.rawValues() ? entry.getValue() : entry, toSeconds(lifespan, entry.getKey(), LIFESPAN), TimeUnit.SECONDS, toSeconds(maxIdle, entry.getKey(), MAXIDLE), TimeUnit.SECONDS);
   }
View Full Code Here

   @Override
   public void write(MarshalledEntry entry) throws PersistenceException {
      if (log.isTraceEnabled()) {
         log.tracef("Adding entry: %s", entry);
      }
      InternalMetadata metadata = entry.getMetadata();
      long lifespan = metadata != null ? metadata.lifespan() : -1;
      long maxIdle = metadata != null ? metadata.maxIdle() : -1;
      remoteCache.put(entry.getKey(), configuration.rawValues() ? entry.getValue() : entry, toSeconds(lifespan, entry.getKey(), LIFESPAN), TimeUnit.SECONDS, toSeconds(maxIdle, entry.getKey(), MAXIDLE), TimeUnit.SECONDS);
   }
View Full Code Here

   @Override
   public void write(MarshalledEntry entry) throws CacheLoaderException {
      if (log.isTraceEnabled()) {
         log.tracef("Adding entry: %s", entry);
      }
      InternalMetadata metadata = entry.getMetadata();
      long lifespan = metadata != null ? metadata.lifespan() : -1;
      long maxIdle = metadata != null ? metadata.maxIdle() : -1;
      remoteCache.put(entry.getKey(), configuration.rawValues() ? entry.getValue() : entry, toSeconds(lifespan, entry.getKey(), LIFESPAN), TimeUnit.SECONDS, toSeconds(maxIdle, entry.getKey(), MAXIDLE), TimeUnit.SECONDS);
   }
View Full Code Here

   @Override
   public void write(MarshalledEntry entry) throws CacheLoaderException {
      if (log.isTraceEnabled()) {
         log.tracef("Adding entry: %s", entry);
      }
      InternalMetadata metadata = entry.getMetadata();
      long lifespan = metadata != null ? metadata.lifespan() : -1;
      long maxIdle = metadata != null ? metadata.maxIdle() : -1;
      remoteCache.put(entry.getKey(), configuration.rawValues() ? entry.getValue() : entry, toSeconds(lifespan, entry.getKey(), LIFESPAN), TimeUnit.SECONDS, toSeconds(maxIdle, entry.getKey(), MAXIDLE), TimeUnit.SECONDS);
   }
View Full Code Here

   @Override
   public void write(MarshalledEntry me)  {
      try {
         db.put(marshall(me.getKey()), marshall(me));
         InternalMetadata meta = me.getMetadata();
         if (meta != null && meta.expiryTime() > -1) {
            addNewExpiry(me);
         }
      } catch (Exception e) {
         throw new DBException(e);
      }
View Full Code Here

   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) {
         throw new PersistenceException(e);
View Full Code Here

      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) {
View Full Code Here

TOP

Related Classes of org.infinispan.metadata.InternalMetadata

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.