Package org.infinispan.server.core

Examples of org.infinispan.server.core.CacheValue$


   @Override
   public Object encodeValue(Object value) throws CodecException {
      if (value != null) {
         try {
            return new CacheValue(marshaller.objectToByteBuffer(value), 1);
         } catch (Exception e) {
            throw log.valueEncodingFailed(e, this.getName());
         }
      } else {
         return null;
View Full Code Here


   @Override
   public Object decodeValue(Object value) throws CodecException {
      if (value != null) {
         try {
            CacheValue cv = (CacheValue) value;
            return marshaller.objectFromByteBuffer(cv.data());
         } catch (Exception e) {
            throw log.valueDecodingFailed(e, this.getName());
         }
      } else {
         return null;
View Full Code Here

   }

   private InternalCacheEntry getInternalCacheEntry(Cache<ByteArrayKey, CacheValue> cache, String key, String value) throws Exception {
      InternalCacheEntry entry = cache.getAdvancedCache().getDataContainer().get(toBinaryKey(key));
      if (value != null) {
         CacheValue v = (CacheValue) entry.getValue();
         AssertJUnit.assertEquals(toBinaryValue(value), v.data());
      }
      return entry;
   }
View Full Code Here

   private void assertCacheContains(Cache cache, String key, String value) throws Exception {
      Marshaller marshaller = new JBossMarshaller();
      byte[] keyBytes = marshaller.objectToByteBuffer(key, 64);
      byte[] valueBytes = marshaller.objectToByteBuffer(value, 64);
      ByteArrayKey cacheKey = new ByteArrayKey(keyBytes);
      CacheValue cacheValue = (CacheValue) cache.get(cacheKey);
      if (value == null) {
         assert cacheValue == null : "Expected null value but received: " + cacheValue;
      } else {
         assert Arrays.equals(valueBytes, (byte[])cacheValue.data());
      }
   }
View Full Code Here

   public void testEntryWrapping() throws Exception {
      remoteSourceCache.put("k1", "v1");
      remoteSourceCache.put("k2", "v2");
      ByteArrayKey key = new ByteArrayKey(marshaller.objectToByteBuffer("k1"));
      CacheValue cv1 = targetCache.get(key);
      assertEquals(marshaller.objectToByteBuffer("v1"), cv1.data());
      String v1 = remoteTargetCache.get("k1");
      assertEquals("v1", v1);
      String v2 = remoteTargetCache.get("k2");
      assertEquals("v2", v2);
   }
View Full Code Here

   @Override
   public CacheValue wrapValue(MetadataValue<?> value) throws CacheLoaderException {
      Object v = value.getValue();
      if (v instanceof byte[]) {
         return new CacheValue((byte[]) v, value.getVersion());
      } else {
         throw log.unsupportedValueFormat(v != null ? v.getClass().getName() : "null");
      }
   }
View Full Code Here

TOP

Related Classes of org.infinispan.server.core.CacheValue$

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.