Package org.infinispan.container.versioning

Examples of org.infinispan.container.versioning.NumericVersion


   @Override
   public InternalCacheEntry load(Object key) throws CacheLoaderException {
      if (config.isRawValues()) {
         MetadataValue<?> value = remoteCache.getWithMetadata(key);
         if (value != null)
            return iceFactory.create(key, value.getValue(), new NumericVersion(value.getVersion()),
                  value.getCreated(), TimeUnit.SECONDS.toMillis(value.getLifespan()),
                  value.getLastUsed(), TimeUnit.SECONDS.toMillis(value.getMaxIdle()));
         else
            return null;
      } else {
View Full Code Here


      return cm;
   }

   public void testPutWithVersion() {
      final Integer key = 1;
      NumericVersion version = new NumericVersion(1);
      advCache.put(key, "v1", withVersion(version));
      CacheEntry cacheEntry = advCache.getCacheEntry(key);
      assertEquals(InequalVersionComparisonResult.EQUAL,
            version.compareTo(cacheEntry.getVersion()));
   }
View Full Code Here

            version.compareTo(cacheEntry.getVersion()));
   }

   public void testConditionalReplaceWithVersion() {
      final Integer key = 2;
      NumericVersion version = new NumericVersion(1);
      advCache.put(key, "v1", new EmbeddedMetadata.Builder().version(version).build());
      NumericVersion newVersion = new NumericVersion(2);
      advCache.replace(key, "v1", "v2", withVersion(newVersion));
      CacheEntry cacheEntry = advCache.getCacheEntry(key);
      assertEquals(InequalVersionComparisonResult.EQUAL,
            newVersion.compareTo(cacheEntry.getVersion()));
   }
View Full Code Here

            newVersion.compareTo(cacheEntry.getVersion()));
   }

   public void testPutIfAbsentWithVersion() {
      final Integer key = 3;
      NumericVersion version = new NumericVersion(1);
      assertEquals(null, advCache.putIfAbsent(key, "v1", withVersion(version)));
      CacheEntry cacheEntry = advCache.getCacheEntry(key);
      assertEquals(InequalVersionComparisonResult.EQUAL,
            version.compareTo(cacheEntry.getVersion()));
   }
View Full Code Here

   @Override
   public InternalCacheEntry load(Object key) throws CacheLoaderException {
      if (configuration.rawValues()) {
         MetadataValue<?> value = remoteCache.getWithMetadata(key);
         if (value != null)
            return iceFactory.create(key, value.getValue(), new NumericVersion(value.getVersion()),
                  value.getCreated(), TimeUnit.SECONDS.toMillis(value.getLifespan()),
                  value.getLastUsed(), TimeUnit.SECONDS.toMillis(value.getMaxIdle()));
         else
            return null;
      } else {
View Full Code Here

   @Override
   public InternalCacheEntry load(Object key) throws CacheLoaderException {
      if (config.isRawValues()) {
         MetadataValue<?> value = remoteCache.getWithMetadata(key);
         if (value != null)
            return iceFactory.create(key, value.getValue(), new NumericVersion(value.getVersion()),
                  value.getCreated(), TimeUnit.SECONDS.toMillis(value.getLifespan()),
                  value.getLastUsed(), TimeUnit.SECONDS.toMillis(value.getMaxIdle()));
         else
            return null;
      } else {
View Full Code Here

      return cm;
   }

   public void testPutWithVersion() {
      final Integer key = 1;
      NumericVersion version = new NumericVersion(1);
      advCache.put(key, "v1", withVersion(version));
      CacheEntry cacheEntry = advCache.getCacheEntry(key);
      assertEquals(EQUAL, version.compareTo(cacheEntry.getMetadata().version()));
   }
View Full Code Here

      assertEquals(EQUAL, version.compareTo(cacheEntry.getMetadata().version()));
   }

   public void testConditionalReplaceWithVersion() {
      final Integer key = 2;
      NumericVersion version = new NumericVersion(1);
      advCache.put(key, "v1", new EmbeddedMetadata.Builder().version(version).build());
      NumericVersion newVersion = new NumericVersion(2);
      advCache.replace(key, "v1", "v2", withVersion(newVersion));
      CacheEntry cacheEntry = advCache.getCacheEntry(key);
      assertEquals(EQUAL, newVersion.compareTo(cacheEntry.getMetadata().version()));
   }
View Full Code Here

      assertEquals(EQUAL, newVersion.compareTo(cacheEntry.getMetadata().version()));
   }

   public void testPutIfAbsentWithVersion() {
      final Integer key = 3;
      NumericVersion version = new NumericVersion(1);
      assertEquals(null, advCache.putIfAbsent(key, "v1", withVersion(version)));
      CacheEntry cacheEntry = advCache.getCacheEntry(key);
      assertEquals(EQUAL, version.compareTo(cacheEntry.getMetadata().version()));
   }
View Full Code Here

      assertEquals(EQUAL, version.compareTo(cacheEntry.getMetadata().version()));
   }

   public void testPutAsyncWithVersion() throws Exception {
      final Integer key = 4;
      NumericVersion version = new NumericVersion(1);
      Future<String> f = advCache.putAsync(key, "v1", withVersion(version));
      assertNotNull(f);
      assertFalse(f.isCancelled());
      assertNull(f.get());
      assertTrue(f.isDone());
      CacheEntry entry = advCache.getCacheEntry(key);
      assertEquals("v1", entry.getValue());
      assertEquals(EQUAL, version.compareTo(entry.getMetadata().version()));
   }
View Full Code Here

TOP

Related Classes of org.infinispan.container.versioning.NumericVersion

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.