Package org.infinispan.marshall.core

Examples of org.infinispan.marshall.core.MarshalledEntryImpl


            Thread t = new Thread() {
               @Override
               public void run() {
                  try {
                     for (int i = 0; i < 100; i++)
                        writer.write(new MarshalledEntryImpl(k(m, i), v(m, i), null, marshaller()));
                  } catch (Exception e) {
                     log.error("Error storing entry", e);
                  }
                  done.countDown();
               }
View Full Code Here


      return new TestObjectStreamMarshaller(false);
   }

   public void testLoadAndStoreImmortal() throws PersistenceException {
      assertFalse(cl.contains("k"));
      cl.write(new MarshalledEntryImpl("k", "v", null, getMarshaller()));

      assert cl.load("k").getValue().equals("v");
      assert cl.load("k").getMetadata() == null || cl.load("k").getMetadata().expiryTime() == -1;
      assert cl.load("k").getMetadata() == null || cl.load("k").getMetadata().maxIdle() == -1;
      assert cl.contains("k");
View Full Code Here

   public void testLoadAndStoreWithLifespan() throws Exception {
      assertFalse(cl.contains("k"));

      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);

      lifespan = 1;
      se = TestInternalCacheEntryFactory.create("k", "v", lifespan);
      cl.write(new MarshalledEntryImpl("k","v", internalMetadata(se), getMarshaller()));
      Thread.sleep(100);
      purgeExpired();
      assert se.isExpired(System.currentTimeMillis());
      assertEventuallyExpires("k");
      assertFalse(cl.contains("k"));
View Full Code Here

   protected void sleepForStopStartTest() throws InterruptedException {
      Thread.sleep(100);
   }

   public void testPreload() throws Exception {
      cl.write(new MarshalledEntryImpl("k1","v1", null, getMarshaller()));
      cl.write(new MarshalledEntryImpl("k2","v2", null, getMarshaller()));
      cl.write(new MarshalledEntryImpl("k3","v3", null, getMarshaller()));

      Set<MarshalledEntry> set = TestingUtil.allEntries(cl);

      assert set.size() == 3;
      Set expected = new HashSet();
View Full Code Here

         assert expected.remove(se.getKey());
      assert expected.isEmpty();
   }

   public void testStoreAndRemove() throws PersistenceException {
      cl.write(new MarshalledEntryImpl("k1","v1", null, getMarshaller()));
      cl.write(new MarshalledEntryImpl("k2","v2", null, getMarshaller()));
      cl.write(new MarshalledEntryImpl("k3","v3", null, getMarshaller()));
      cl.write(new MarshalledEntryImpl("k4","v4", null, getMarshaller()));


      Set<MarshalledEntry> set = TestingUtil.allEntries(cl);

      assert set.size() == 4;
View Full Code Here

      assert cl.contains("k5");
   }

   public void testLoadAll() throws PersistenceException {

      cl.write(new MarshalledEntryImpl("k1","v1", null, getMarshaller()));
      cl.write(new MarshalledEntryImpl("k2","v2", null, getMarshaller()));
      cl.write(new MarshalledEntryImpl("k3","v3", null, getMarshaller()));
      cl.write(new MarshalledEntryImpl("k4","v4", null, getMarshaller()));
      cl.write(new MarshalledEntryImpl("k5","v5", null, getMarshaller()));

      Set<MarshalledEntry> s = TestingUtil.allEntries(cl);
      assert s.size() == 5 : "Expected 5 keys, was " + s;

      s = allEntries(cl, new CollectionKeyFilter(emptySet()));
View Full Code Here

      MarshalledValue key = new MarshalledValue(new Pojo().role("key"), getMarshaller());
      MarshalledValue key2 = new MarshalledValue(new Pojo().role("key2"), getMarshaller());
      MarshalledValue value = new MarshalledValue(new Pojo().role("value"), getMarshaller());

      assertFalse(cl.contains(key));
      cl.write(new MarshalledEntryImpl(key, value, null, getMarshaller()));

      assert cl.load(key).getValue().equals(value);
      assert cl.load(key).getMetadata() == null || cl.load(key).getMetadata().expiryTime() == - 1;
      assert cl.load(key).getMetadata() == null || cl.load(key).getMetadata().lifespan() == - 1;
      assert cl.contains(key);
View Full Code Here

      final String v1 = "real-data";
      final String v2 = "stale-data";

      // Simulate c3 was by itself and someone wrote a value that is now stale
      CacheWriter store = (CacheWriter) TestingUtil.getFirstLoader(c3);
      store.write(new MarshalledEntryImpl(k, v2, null, marshaller(c3)));

      c1.put(k, v1);

      assertEquals(v1, c3.get(k));
   }
View Full Code Here

      final String v1 = "real-data";
      final String v2 = "stale-data";

      // Simulate c3 was by itself and someone wrote a value that is now stale
      CacheWriter store = (CacheWriter) TestingUtil.getFirstLoader(c3);
      store.write(new MarshalledEntryImpl(k, v2, null, marshaller(c3)));

      c1.put(k, v1);

      assertEquals(v1, c3.get(k));
   }
View Full Code Here

      assertNoLocks(cache);
   }

   public void testLoading() throws PersistenceException {
      assertNotInCacheAndStore("k1", "k2", "k3", "k4");
      for (int i = 1; i < 5; i++) writer.write(new MarshalledEntryImpl("k" + i, "v" + i, null, sm));
      for (int i = 1; i < 5; i++) assert cache.get("k" + i).equals("v" + i);
      // make sure we have no stale locks!!
      assertNoLocks(cache);

      for (int i = 1; i < 5; i++) cache.evict("k" + i);
View Full Code Here

TOP

Related Classes of org.infinispan.marshall.core.MarshalledEntryImpl

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.