use of org.infinispan.container.versioning.NumericVersion in project infinispan by infinispan.
the class MetaParamsTest method testDuplicateParametersOnConstruction.
@Test
public void testDuplicateParametersOnConstruction() {
MetaEntryVersion versionParam1 = new MetaEntryVersion(new NumericVersion(100));
MetaEntryVersion versionParam2 = new MetaEntryVersion(new NumericVersion(200));
MetaParams metas = MetaParams.of(versionParam1, versionParam2);
assertEquals(1, metas.size());
assertEquals(Optional.of(new MetaEntryVersion(new NumericVersion(200))), metas.find(MetaEntryVersion.class));
}
use of org.infinispan.container.versioning.NumericVersion in project infinispan by infinispan.
the class OffHeapBoundedMemoryTest method testAllocatedAmountEqualWithVersionAndExpiration.
public void testAllocatedAmountEqualWithVersionAndExpiration() {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.memory().size(MemoryUnit.MEGABYTES.toBytes(20)).evictionType(EvictionType.MEMORY).storageType(StorageType.OFF_HEAP);
EmbeddedCacheManager manager = TestCacheManagerFactory.createCacheManager(builder);
AdvancedCache<Object, Object> cache = manager.getCache().getAdvancedCache();
cache.put("lifespan", 2, new EmbeddedMetadata.Builder().lifespan(1, TimeUnit.MINUTES).version(new NumericVersion(23)).build());
cache.put("both", 2, new EmbeddedMetadata.Builder().lifespan(1, TimeUnit.MINUTES).maxIdle(1, TimeUnit.MINUTES).version(new NumericVersion(23)).build());
cache.put("maxidle", 2, new EmbeddedMetadata.Builder().maxIdle(1, TimeUnit.MINUTES).version(new NumericVersion(23)).build());
OffHeapMemoryAllocator allocator = cache.getComponentRegistry().getComponent(OffHeapMemoryAllocator.class);
BoundedOffHeapDataContainer container = (BoundedOffHeapDataContainer) getContainer(cache);
assertEquals(allocator.getAllocatedAmount(), container.currentSize);
cache.clear();
assertEquals(allocator.getAllocatedAmount(), container.currentSize);
}
use of org.infinispan.container.versioning.NumericVersion in project infinispan by infinispan.
the class OffHeapBoundedMemoryTest method testAllocatedAmountEqualWithVersion.
public void testAllocatedAmountEqualWithVersion() {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.memory().size(MemoryUnit.MEGABYTES.toBytes(20)).evictionType(EvictionType.MEMORY).storageType(StorageType.OFF_HEAP);
EmbeddedCacheManager manager = TestCacheManagerFactory.createCacheManager(builder);
AdvancedCache<Object, Object> cache = manager.getCache().getAdvancedCache();
cache.put(1, 2, new EmbeddedMetadata.Builder().version(new NumericVersion(23)).build());
OffHeapMemoryAllocator allocator = cache.getComponentRegistry().getComponent(OffHeapMemoryAllocator.class);
BoundedOffHeapDataContainer container = (BoundedOffHeapDataContainer) getContainer(cache);
assertEquals(allocator.getAllocatedAmount(), container.currentSize);
cache.clear();
assertEquals(allocator.getAllocatedAmount(), container.currentSize);
}
use of org.infinispan.container.versioning.NumericVersion in project infinispan by infinispan.
the class HotRodClientTestingUtil method entryVersion.
public static <K> long entryVersion(Cache<byte[], ?> cache, K key) {
byte[] lookupKey;
try {
lookupKey = toBytes(key);
} catch (Exception e) {
throw new AssertionError(e);
}
Metadata meta = cache.getAdvancedCache().getCacheEntry(lookupKey).getMetadata();
return ((NumericVersion) meta.version()).getVersion();
}
use of org.infinispan.container.versioning.NumericVersion in project infinispan by infinispan.
the class MetadataAPITest method testPutIfAbsentWithVersion.
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()));
}
Aggregations