Package org.infinispan.marshall.core

Examples of org.infinispan.marshall.core.MarshalledEntry


      }

      log.tracef("after write");

      for (int i = 0; i < number; i++) {
         MarshalledEntry me = loader.load(key + i);
         assert me != null && (value + i).equals(me.getValue());
      }
   }
View Full Code Here


   private void doTestSameKeyPut(int number, String key, String value) throws Exception {
      for (int i = 0; i < number; i++) {
         writer.write(new MarshalledEntryImpl(key, value + i, null, marshaller()));
      }
      MarshalledEntry me = loader.load(key);
      assert me != null && (value + (number - 1)).equals(me.getValue());
   }
View Full Code Here

   private void testStoredEntry(MarshalledEntry entry, Object key, String src) {
      assert entry != null : src + " entry for key " + key + " should NOT be null";
   }

   private void assertInStoreNotInCache(Object key) throws PersistenceException {
      MarshalledEntry se = loader.load(key);
      testStoredEntry(se, key, "Store");
      assert !cache.getAdvancedCache().getDataContainer().containsKey(key) : "Key " + key + " should not be in cache!";
   }
View Full Code Here

      long lifespan = 120000;
      InternalCacheEntry se = TestInternalCacheEntryFactory.create("k", "v", lifespan);
      cl.write(new MarshalledEntryImpl("k", "v", internalMetadata(se), getMarshaller()));

      assert cl.contains("k");
      MarshalledEntry me = cl.load("k");
      assertCorrectExpiry(me, "v", lifespan, -1, false);

      me = TestingUtil.allEntries(cl).iterator().next();
      assertCorrectExpiry(me, "v", lifespan, -1, false);
View Full Code Here

      long idle = 120000;
      InternalCacheEntry se = TestInternalCacheEntryFactory.create("k", "v", -1, idle);
      cl.write(marshalledEntry(se, getMarshaller()));

      assert cl.contains("k");
      MarshalledEntry me = cl.load("k");
      assertCorrectExpiry(me, "v", -1, idle, false);
      assertCorrectExpiry(TestingUtil.allEntries(cl).iterator().next(), "v", -1, idle, false);

      idle = 1;
      se = TestInternalCacheEntryFactory.create("k", "v", -1, idle);
View Full Code Here

      assertEquals(se.getCreated(), icv.getCreated());
      assertEquals(se.getLastUsed(), icv.getLastUsed());
      cl.write(marshalledEntry(se, getMarshaller()));

      assert cl.contains("k");
      MarshalledEntry ice = cl.load("k");
      assertCorrectExpiry(ice, "v", lifespan, idle, false);
      assertCorrectExpiry(TestingUtil.allEntries(cl).iterator().next(), "v", lifespan, idle, false);

      idle = 1;
      se = TestInternalCacheEntryFactory.create("k", "v", lifespan, idle);
View Full Code Here

      final long startTime = System.currentTimeMillis();
      final long lifespan = 3000;
      InternalCacheEntry ice = TestInternalCacheEntryFactory.create("k1", "v1", lifespan);
      cl.write(marshalledEntry(ice, getMarshaller()));
      while (true) {
         MarshalledEntry entry = cl.load("k1");
         if (System.currentTimeMillis() >= startTime + lifespan)
            break;
         assertEquals(entry.getValue(),"v1");
         Thread.sleep(100);
      }

      // Make sure that in the next 20 secs data is removed
      while (System.currentTimeMillis() < startTime + lifespan + 20000) {
         if (cl.load("k1") == null) break;
      }

      assert null == cl.load("k1");

      InternalCacheEntry ice2 = TestInternalCacheEntryFactory.create("k1", "v2", lifespan);
      cl.write(marshalledEntry(ice2, getMarshaller()));
      while (true) {
         MarshalledEntry entry = cl.load("k1");
         if (System.currentTimeMillis() >= startTime + lifespan)
            break;
         assertEquals(entry.getValue(),"v2");
         Thread.sleep(100);
      }

      // Make sure that in the next 20 secs data is removed
      while (System.currentTimeMillis() < startTime + lifespan + 20000) {
View Full Code Here

   private Operation<String, Integer> readOperation(final AdvancedCacheLoader store) {
      return new Operation<String, Integer>("GET") {
         @Override
         public boolean call(String key, long run) {
            MarshalledEntry me = store.load(key);
            if (trace)
               log.tracef("Loaded key=%s, value=%s", key, me != null ? me.getValue() : "null");
            return me != null;
         }
      };
   }
View Full Code Here

   }

   private void assertInCacheAndStore(Cache<?, ?> cache, CacheLoader loader, Object key, Object value, long lifespanMillis) throws PersistenceException {
      InternalCacheEntry se = cache.getAdvancedCache().getDataContainer().get(key);
      testStoredEntry(se.getValue(), value, se.getLifespan(), lifespanMillis, "Cache", key);
      MarshalledEntry load = loader.load(key);
      testStoredEntry(load.getValue(), value, load.getMetadata() == null ? -1 : load.getMetadata().lifespan(), lifespanMillis, "Store", key);
   }
View Full Code Here

         final Object key = "k" + i;
         final Object value = "v" + i;
         final long lifespan = i % 2 == 1 ? -1 : this.lifespan;
         boolean found = false;
         InternalCacheEntry se = preloadingCache.getAdvancedCache().getDataContainer().get(key);
         MarshalledEntry load = preloadingCacheLoader.load(key);
         if (se != null) {
            testStoredEntry(se.getValue(), value, se.getLifespan(), lifespan, "Cache", key);
            found = true;
         }
         if (load != null) {
            testStoredEntry(load.getValue(), value, load.getMetadata().lifespan(), lifespan, "Store", key);
            found = true;
         }
         assertTrue("Key not found.", found);
      }

      preloadingCache.stop();
      assertEquals("DataContainer still has entries after stop", 0, c.size());

      preloadingCache.start();
      // The old store's marshaller is not working any more
      preloadingCacheLoader = (AdvancedCacheLoader) TestingUtil.getCacheLoader(preloadingCache);

      assertTrue("Preload not enabled in cache configuration",
                 preloadingCache.getCacheConfiguration().persistence().preload());

      c = preloadingCache.getAdvancedCache().getDataContainer();
      assertEquals("Wrong number of entries in data container", expectedEntriesInContainer, c.size());

      for (int i = 1; i < 5; i++) {
         final Object key = "k" + i;
         final Object value = "v" + i;
         final long lifespan = i % 2 == 1 ? -1 : this.lifespan;
         boolean found = false;
         InternalCacheEntry se = preloadingCache.getAdvancedCache().getDataContainer().get(key);
         MarshalledEntry load = preloadingCacheLoader.load(key);
         if (se != null) {
            testStoredEntry(se.getValue(), value, se.getLifespan(), lifespan, "Cache", key);
            found = true;
         }
         if (load != null) {
            testStoredEntry(load.getValue(), value, load.getMetadata().lifespan(), lifespan, "Store", key);
            found = true;
         }
         assertTrue("Key not found.", found);
      }
   }
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.