Search in sources :

Example 1 with CacheEntryDelegator

use of org.infinispan.test.fwk.CacheEntryDelegator in project infinispan by infinispan.

the class NonTxStateTransferOverwritingValue2Test method blockEntryCommit.

private void blockEntryCommit(final CheckPoint checkPoint, AdvancedCache<Object, Object> cache) {
    ClusteringDependentLogic cdl1 = TestingUtil.extractComponent(cache, ClusteringDependentLogic.class);
    ClusteringDependentLogic replaceCdl = new ClusteringDependentLogicDelegator(cdl1) {

        @Override
        public CompletionStage<Void> commitEntry(CacheEntry entry, FlagAffectedCommand command, InvocationContext ctx, Flag trackFlag, boolean l1Invalidation) {
            // skip for clear command!
            if (entry instanceof ClearCacheEntry) {
                return super.commitEntry(entry, command, ctx, trackFlag, l1Invalidation);
            }
            final Address source = ctx.getOrigin();
            CacheEntry newEntry = new CacheEntryDelegator(entry) {

                @Override
                public void commit(DataContainer container) {
                    checkPoint.trigger("pre_commit_entry_" + getKey() + "_from_" + source);
                    try {
                        checkPoint.awaitStrict("resume_commit_entry_" + getKey() + "_from_" + source, 10, SECONDS);
                    } catch (InterruptedException | TimeoutException e) {
                        throw new RuntimeException(e);
                    }
                    super.commit(container);
                    checkPoint.trigger("post_commit_entry_" + getKey() + "_from_" + source);
                }
            };
            return super.commitEntry(newEntry, command, ctx, trackFlag, l1Invalidation);
        }
    };
    TestingUtil.replaceComponent(cache, ClusteringDependentLogic.class, replaceCdl, true);
}
Also used : Address(org.infinispan.remoting.transport.Address) ClusteringDependentLogic(org.infinispan.interceptors.locking.ClusteringDependentLogic) CacheEntryDelegator(org.infinispan.test.fwk.CacheEntryDelegator) ClearCacheEntry(org.infinispan.container.entries.ClearCacheEntry) CacheEntry(org.infinispan.container.entries.CacheEntry) Flag(org.infinispan.context.Flag) ClearCacheEntry(org.infinispan.container.entries.ClearCacheEntry) FlagAffectedCommand(org.infinispan.commands.FlagAffectedCommand) DataContainer(org.infinispan.container.DataContainer) InvocationContext(org.infinispan.context.InvocationContext) ClusteringDependentLogicDelegator(org.infinispan.test.fwk.ClusteringDependentLogicDelegator) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

TimeoutException (java.util.concurrent.TimeoutException)1 FlagAffectedCommand (org.infinispan.commands.FlagAffectedCommand)1 DataContainer (org.infinispan.container.DataContainer)1 CacheEntry (org.infinispan.container.entries.CacheEntry)1 ClearCacheEntry (org.infinispan.container.entries.ClearCacheEntry)1 Flag (org.infinispan.context.Flag)1 InvocationContext (org.infinispan.context.InvocationContext)1 ClusteringDependentLogic (org.infinispan.interceptors.locking.ClusteringDependentLogic)1 Address (org.infinispan.remoting.transport.Address)1 CacheEntryDelegator (org.infinispan.test.fwk.CacheEntryDelegator)1 ClusteringDependentLogicDelegator (org.infinispan.test.fwk.ClusteringDependentLogicDelegator)1