use of org.infinispan.container.impl.EntryFactory in project infinispan by infinispan.
the class ConditionalOperationPrimaryOwnerFailTest method testEntryNotWrapped.
public void testEntryNotWrapped() throws Throwable {
assertClusterSize("Wrong cluster size!", 3);
final Object key = new MagicKey(cache(0), cache(1));
final Cache<Object, Object> futureBackupOwnerCache = cache(2);
cache(0).put(key, INITIAL_VALUE);
final PerCacheInboundInvocationHandler spyHandler = spyInvocationHandler(futureBackupOwnerCache);
final EntryFactory spyEntryFactory = spyEntryFactory(futureBackupOwnerCache);
// it blocks the StateResponseCommand.class
final CountDownLatch latch1 = new CountDownLatch(1);
final CountDownLatch latch2 = new CountDownLatch(1);
doAnswer(invocation -> {
CacheRpcCommand command = (CacheRpcCommand) invocation.getArguments()[0];
if (command instanceof StateResponseCommand) {
log.debugf("Blocking command %s", command);
latch2.countDown();
latch1.await();
}
return invocation.callRealMethod();
}).when(spyHandler).handle(any(CacheRpcCommand.class), any(Reply.class), any(DeliverOrder.class));
doAnswer(invocation -> {
InvocationContext context = (InvocationContext) invocation.getArguments()[0];
log.debugf("wrapEntryForWriting invoked with %s", context);
CompletionStage<Void> stage = (CompletionStage<Void>) invocation.callRealMethod();
CompletionStages.join(stage);
assertNull(context.lookupEntry(key), "Entry should not be wrapped!");
return stage;
}).when(spyEntryFactory).wrapEntryForWriting(any(InvocationContext.class), any(), anyInt(), anyBoolean(), anyBoolean(), any());
Future<?> killMemberResult = fork(() -> killMember(1));
// await until the key is received from state transfer (the command is blocked now...)
latch2.await(30, TimeUnit.SECONDS);
futureBackupOwnerCache.put(key, FINAL_VALUE);
latch1.countDown();
killMemberResult.get(30, TimeUnit.SECONDS);
}
use of org.infinispan.container.impl.EntryFactory in project infinispan by infinispan.
the class ConditionalOperationPrimaryOwnerFailTest method spyEntryFactory.
private EntryFactory spyEntryFactory(Cache<Object, Object> cache) {
EntryFactory spy = spy(extractComponent(cache, EntryFactory.class));
TestingUtil.replaceComponent(cache, EntryFactory.class, spy, true);
return spy;
}
Aggregations