use of org.infinispan.container.entries.ImmortalCacheEntry in project infinispan by infinispan.
the class L1WriteSynchronizerTest method testSpawnedThreadBlockingValueTimeWait.
@Test
public void testSpawnedThreadBlockingValueTimeWait() throws InterruptedException, ExecutionException, TimeoutException {
Object value = new Object();
Future future = fork(() -> sync.get(5, TimeUnit.SECONDS));
// This should not return since we haven't signaled the sync yet
try {
future.get(50, TimeUnit.MILLISECONDS);
fail("Should have thrown a timeout exception");
} catch (TimeoutException e) {
// This should time out exception
}
InternalCacheEntry ice = new ImmortalCacheEntry(value, value);
sync.runL1UpdateIfPossible(ice);
assertEquals(ice, future.get(1, TimeUnit.SECONDS));
}
use of org.infinispan.container.entries.ImmortalCacheEntry in project infinispan by infinispan.
the class L1WriteSynchronizerTest method testGetReturnValueTimeWait.
@Test
public void testGetReturnValueTimeWait() throws InterruptedException, ExecutionException, TimeoutException {
Object value = new Object();
InternalCacheEntry ice = new ImmortalCacheEntry(value, value);
sync.runL1UpdateIfPossible(ice);
assertEquals(ice, sync.get(1, TimeUnit.SECONDS));
}
use of org.infinispan.container.entries.ImmortalCacheEntry in project infinispan by infinispan.
the class L1WriteSynchronizerTest method testGetReturnValueWait.
@Test
public void testGetReturnValueWait() throws InterruptedException, ExecutionException, TimeoutException {
Object value = new Object();
InternalCacheEntry ice = new ImmortalCacheEntry(value, value);
sync.runL1UpdateIfPossible(ice);
assertEquals(ice, sync.get());
}
use of org.infinispan.container.entries.ImmortalCacheEntry in project infinispan by infinispan.
the class BaseStreamTest method testObjReduce2.
public void testObjReduce2() {
Cache<Integer, String> cache = getCache(0);
int range = 10;
// First populate the cache with a bunch of values
IntStream.range(0, range).boxed().forEach(i -> cache.put(i, i + "-value"));
CacheSet<Map.Entry<Integer, String>> entrySet = cache.entrySet();
// This isn't the best usage of this, but should be a usable example
Map.Entry<Integer, String> result = createStream(entrySet).reduce(new ImmortalCacheEntry(0, ""), (e1, e2) -> new ImmortalCacheEntry(e1.getKey() + e2.getKey(), e1.getValue() + e2.getValue()));
assertEquals((range - 1) * (range / 2), result.getKey().intValue());
assertEquals(range * 7, result.getValue().length());
}
use of org.infinispan.container.entries.ImmortalCacheEntry in project infinispan by infinispan.
the class BaseSetupStreamIteratorTest method generateEntriesPerSegment.
protected Map<Integer, Set<Map.Entry<Object, String>>> generateEntriesPerSegment(KeyPartitioner keyPartitioner, Iterable<Map.Entry<Object, String>> entries) {
Map<Integer, Set<Map.Entry<Object, String>>> returnMap = new HashMap<>();
for (Map.Entry<Object, String> value : entries) {
int segment = keyPartitioner.getSegment(value.getKey());
Set<Map.Entry<Object, String>> set = returnMap.computeIfAbsent(segment, k -> new LinkedHashSet<>());
set.add(new ImmortalCacheEntry(value.getKey(), value.getValue()));
}
return returnMap;
}
Aggregations