use of org.infinispan.container.entries.InternalCacheValue in project infinispan by infinispan.
the class ScatteredStateConsumerImpl method backupEntries.
private void backupEntries(List<InternalCacheEntry<?, ?>> entries) {
long incrementedCounter = chunkCounter.incrementAndGet();
if (log.isTraceEnabled())
log.tracef("Backing up entries, chunk counter is %d", incrementedCounter);
Map<Object, InternalCacheValue<?>> map = new HashMap<>();
for (InternalCacheEntry<?, ?> entry : entries) {
map.put(entry.getKey(), entry.toInternalCacheValue());
}
PutMapCommand putMapCommand = commandsFactory.buildPutMapCommand(map, null, STATE_TRANSFER_FLAGS);
putMapCommand.setTopologyId(rpcManager.getTopologyId());
rpcManager.invokeCommand(backupAddress, putMapCommand, SingleResponseCollector.validOnly(), rpcManager.getSyncRpcOptions()).whenComplete(((response, throwable) -> {
try {
if (throwable != null) {
log.failedOutBoundTransferExecution(throwable);
}
} finally {
long decrementedCounter = chunkCounter.decrementAndGet();
if (log.isTraceEnabled())
log.tracef("Backed up entries, chunk counter is %d", decrementedCounter);
if (decrementedCounter == 0) {
notifyEndOfStateTransferIfNeeded();
}
}
}));
}
use of org.infinispan.container.entries.InternalCacheValue in project infinispan by infinispan.
the class ConflictManagerTest method testGetAllVersionsDuringStateTransfer.
public void testGetAllVersionsDuringStateTransfer() throws Exception {
final int key = 1;
final int value = 1;
createCluster();
getCache(2).put(key, value);
splitCluster();
RehashListener listener = new RehashListener();
getCache(0).addListener(listener);
CountDownLatch latch = new CountDownLatch(1);
delayStateTransferCompletion(latch);
// Trigger the merge and wait for state transfer to begin
Future<?> mergeFuture = fork(() -> partition(0).merge(partition(1)));
assertTrue(listener.latch.await(10, TimeUnit.SECONDS));
Future<Map<Address, InternalCacheValue<Object>>> versionFuture = fork(() -> getAllVersions(0, key));
// Check that getAllVersions doesn't return while state transfer is in progress
TestingUtil.assertNotDone(versionFuture);
// Allow and wait for state transfer to finish
latch.countDown();
mergeFuture.get(30, TimeUnit.SECONDS);
// Check the results
Map<Address, InternalCacheValue<Object>> versionMap = versionFuture.get(60, TimeUnit.SECONDS);
assertTrue(versionMap != null);
assertTrue(!versionMap.isEmpty());
// mergepolicy == null, so no conflict resolution occurs therefore it's possible that versionMap may contain null entries
assertEquals(String.format("Returned versionMap %s", versionMap), 2, versionMap.size());
}
use of org.infinispan.container.entries.InternalCacheValue in project infinispan by infinispan.
the class CrashedNodeDuringConflictResolutionTest method afterConflictResolutionAndMerge.
@Override
protected void afterConflictResolutionAndMerge() {
ConflictManager cm = conflictManager(0);
assertFalse(cm.isConflictResolutionInProgress());
for (String key : ALL_KEYS) {
Map<Address, InternalCacheValue> versionMap = cm.getAllVersions(key);
assertNotNull(versionMap);
assertEquals("Versions: " + versionMap, numberOfOwners, versionMap.size());
String message = String.format("Key=%s. VersionMap: %s", key, versionMap);
for (InternalCacheValue icv : versionMap.values()) {
assertNotNull(message, icv);
assertNotNull(message, icv.getValue());
assertEquals(message, valueAfterMerge, icv.getValue());
}
}
assertEquals(0, cm.getConflicts().peek(m -> log.errorf("Conflict: " + m)).count());
}
use of org.infinispan.container.entries.InternalCacheValue in project infinispan by infinispan.
the class BaseStoreTest method testLoadAndStoreWithLifespanAndIdle.
public void testLoadAndStoreWithLifespanAndIdle() throws Exception {
assertIsEmpty();
long lifespan = 200000;
long idle = 120000;
InternalCacheEntry se = internalCacheEntry("k", "v", lifespan, idle);
InternalCacheValue icv = se.toInternalCacheValue();
assertEquals(se.getCreated(), icv.getCreated());
assertEquals(se.getLastUsed(), icv.getLastUsed());
assertExpired(se, false);
cl.write(marshalledEntry(se));
assertContains("k", true);
assertCorrectExpiry(cl.loadEntry("k"), "v", lifespan, idle, false);
assertCorrectExpiry(TestingUtil.allEntries(cl).iterator().next(), "v", lifespan, idle, false);
timeService.advance(idle + 1);
idle = 1000;
lifespan = 4000;
se = internalCacheEntry("k", "v", lifespan, idle);
assertExpired(se, false);
cl.write(marshalledEntry(se));
timeService.advance(idle + 1);
purgeExpired("k");
// expired by idle
assertExpired(se, true);
assertEventuallyExpires("k");
assertContains("k", false);
assertIsEmpty();
}
use of org.infinispan.container.entries.InternalCacheValue in project infinispan by infinispan.
the class WriteSkewCacheLoaderFunctionalTest method assertInCacheAndStore.
private void assertInCacheAndStore(Cache cache, DummyInMemoryStore store, Object key, Object value, long lifespanMillis) throws PersistenceException {
InternalCacheValue icv = cache.getAdvancedCache().getDataContainer().peek(key).toInternalCacheValue();
assertStoredEntry(icv.getValue(), value, icv.getLifespan(), lifespanMillis, "Cache", key);
assertNotNull("For :" + icv, icv.getInternalMetadata().entryVersion());
MarshallableEntry<?, ?> load = store.loadEntry(key);
assertStoredEntry(load.getValue(), value, load.getMetadata().lifespan(), lifespanMillis, "Store", key);
assertNotNull("For :" + load, load.getInternalMetadata().entryVersion());
}
Aggregations