Package org.infinispan.marshall.core

Examples of org.infinispan.marshall.core.MarshalledEntryImpl


   /**
    * When trying to persist an unsupported object an exception is expected.
    */
   public void persistUnsupportedObject() throws Exception {
      try {
         cacheStore.write(new MarshalledEntryImpl("key", "value", null, marshaller));
         fail("exception is expected as PersonKey2StringMapper does not support strings");
      } catch (UnsupportedKeyTypeException e) {
         //expected
      }
      //just check that an person object will be persisted okay
      cacheStore.write(new MarshalledEntryImpl(MIRCEA, "Cluj Napoca", null, marshaller));
   }
View Full Code Here


   public void testStoreLoadRemove() throws Exception {
      assertRowCount(0);
      assertNull("should not be present in the store", cacheStore.load(MIRCEA));
      String value = "adsdsadsa";
      cacheStore.write(new MarshalledEntryImpl(MIRCEA, value, null, marshaller));
      assertRowCount(1);
      assertEquals(value, cacheStore.load(MIRCEA).getValue());
      assertFalse(cacheStore.delete(MANIK));
      assertEquals(value, cacheStore.load(MIRCEA).getValue());
      assertRowCount(1);
View Full Code Here

   }


   public void testClear() throws Exception {
      assertRowCount(0);
      cacheStore.write(new MarshalledEntryImpl(MIRCEA, "value", null, marshaller));
      cacheStore.write(new MarshalledEntryImpl(MANIK, "value", null, marshaller));
      assertRowCount(2);
      cacheStore.clear();
      assertRowCount(0);
   }
View Full Code Here

         byte[] data = new byte[size];
         random.nextBytes(data);
         String key = "key" + i;
         Huge value = new Huge(key, data);
         long lifespan = provider == null ? -1 : provider.get();
         MarshalledEntryImpl entry = lifespan < 0 ? createEntry(key, value) : createEntry(key, value, lifespan);
         cs.write(entry);
         if (i % 100 == 0)
            log.info("Writing key " + key);
      }
      log.info("All keys written");
View Full Code Here

   protected StreamingMarshaller getMarshaller() {
      return marshaller;
   }

   protected MarshalledEntryImpl createEntry(Object key, Object value) {
      return new MarshalledEntryImpl(key, value, null, getMarshaller());
   }
View Full Code Here

      return new MarshalledEntryImpl(key, value, null, getMarshaller());
   }

   protected MarshalledEntryImpl createEntry(Object key, Object value, long lifespan) {
      InternalCacheEntry ice = TestInternalCacheEntryFactory.create(key, value, lifespan);
      return new MarshalledEntryImpl(key, value, new InternalMetadataImpl(ice), getMarshaller());
   }
View Full Code Here

   }

   public void testStoreWithJpaGoodKey() {
     TestObject obj = createTestObject("testStoreWithJpaGoodKey");
     assertFalse(cs.contains(obj.getKey()));
     MarshalledEntryImpl me = createEntry(obj);
     cs.write(me);
   }
View Full Code Here

   }

   public void testLoadAndStoreImmortal() {
      TestObject obj = createTestObject("testLoadAndStoreImmortal");
      assertFalse(cs.contains(obj.getKey()));
      MarshalledEntryImpl me = createEntry(obj);
      cs.write(me);

      assertTrue(cs.contains(obj.getKey()));
      assertEquals(obj.getValue(), cs.load(obj.getKey()).getValue());
      assertNull(cs.load(obj.getKey()).getMetadata());
View Full Code Here

   }

   public void testPurgeExpiredAllCodepaths() throws Exception {
      FixedHashKey k1 = new FixedHashKey(1, "a");
      FixedHashKey k2 = new FixedHashKey(1, "b");
      cl.write(new MarshalledEntryImpl(k1, "value", null, getMarshaller()));
      Metadata metadata = metadata(1000, null);
      InternalMetadataImpl im = new InternalMetadataImpl(metadata, System.currentTimeMillis(), System.currentTimeMillis());
      cl.write(new MarshalledEntryImpl(k2, "value", im, getMarshaller())); // will expire
      for (int i = 0; i < 120; i++) {
         cl.write(new MarshalledEntryImpl(new FixedHashKey(i + 10, "non-exp k" + i), "value", null, getMarshaller()));
         cl.write(new MarshalledEntryImpl(new FixedHashKey(i + 10, "exp k" + i), "value", im, getMarshaller())); // will expire
      }
      TestingUtil.sleepThread(1000);
      assert cl.contains(k1);
      assert !cl.contains(k2);
      (cl).purge(new WithinThreadExecutor(), null);
View Full Code Here

      return cacheStores.get();
   }

   void storeEntry(InvocationContext ctx, Object key, FlagAffectedCommand command) {
      InternalCacheValue sv = getStoredValue(key, ctx);
      persistenceManager.writeToAllStores(new MarshalledEntryImpl(key, sv.getValue(), internalMetadata(sv), marshaller),
                                          skipSharedStores(ctx, key, command));
      if (getLog().isTraceEnabled()) getLog().tracef("Stored entry %s under key %s", sv, key);
   }
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.