Package org.infinispan.marshall.core

Examples of org.infinispan.marshall.core.MarshalledEntry


         Random random = new Random();
         int i = 0;
         while (stopLatch.getCount() != 0) {
            String key = keys.get(random.nextInt(keys.size()));
            String value = key + "_value_" + i + "_" + times("123456789_", random.nextInt(MAX_VALUE_SIZE) / 10);
            MarshalledEntry entry = new MarshalledEntryImpl<String, String>(key, value, null, marshaller);
            store.write(entry);
//            log.tracef("Wrote value %s for key %s", value, key);

            i++;
         }
View Full Code Here


      @Override
      public Random call() throws Exception {
         Random random = new Random();
         while (stopLatch.getCount() != 0) {
            String key = keys.get(random.nextInt(keys.size()));
            MarshalledEntry entryFromStore = store.load(key);
            if (entryFromStore == null) {
               assertTrue(allowNulls);
            } else {
               String storeValue = (String) entryFromStore.getValue();
//               log.tracef("Read value %s for key %s", storeValue, key);
               assertEquals(key, entryFromStore.getKey());
               assertTrue(storeValue.startsWith(key));
            }
         }
         return null;
      }
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

            //Entry wasn't loaded from persistence. return null.
            return null;
         }

         //check if the entry was loaded
         MarshalledEntry loaded = persistenceManager.loadFromAllStores(key, ctx);
         if (getLog().isTraceEnabled()) {
            getLog().tracef("Loaded %s for key %s from persistence.", loaded, key);
         }
         if(loaded == null) {
            return Boolean.FALSE;
         }
         InternalMetadata metadata = loaded.getMetadata();
         if (metadata != null && metadata.isExpired(timeService.wallClockTime())) {
            return Boolean.FALSE;
         }

         ice = iceFactory.create(loaded.getKey(), loaded.getValue(), metadata);
         CacheEntry wrappedEntry = wrapInternalCacheEntry(ctx, key, cmd, ice, isDelta, true);
         recordLoadedEntry(ctx, key, wrappedEntry, ice, cmd, isDelta);
         afterSuccessfullyLoaded(wrappedEntry);
         return Boolean.TRUE;
      } finally {
View Full Code Here

               try {
                  started.countDown();
                  int i = 0;
                  while (run.get()) {
                     InternalCacheEntry entry = TestInternalCacheEntryFactory.create("k" + i, "v" + i);
                     MarshalledEntry me = TestingUtil.marshalledEntry(entry, getMarshaller());
                     try {
                        AtomicInteger record = post.get() ? writtenPost : writtenPre;
                        cl.write(me);
                        ++i;
                        int prev;
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 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

   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(AdvancedCacheLoader.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.shouldLoadKey(entry.getKey()))
            result.put(entry.getKey(), me);
      }
      return result;
   }
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.