Search in sources :

Example 1 with BlockingInterceptor

use of org.infinispan.distribution.BlockingInterceptor in project hibernate-orm by hibernate.

the class TombstoneTest method blockedPutFromLoad.

private Future<?> blockedPutFromLoad(CyclicBarrier putFromLoadBarrier) throws InterruptedException, BrokenBarrierException, TimeoutException {
    BlockingInterceptor blockingInterceptor = new BlockingInterceptor(putFromLoadBarrier, PutKeyValueCommand.class, false, true);
    entityCache.addInterceptor(blockingInterceptor, 0);
    cleanup.add(() -> entityCache.removeInterceptor(BlockingInterceptor.class));
    // the putFromLoad should be blocked in the interceptor
    Future<?> putFromLoad = executor.submit(() -> withTxSessionApply(s -> {
        assertEquals("Original item", s.load(Item.class, itemId).getDescription());
        return null;
    }));
    putFromLoadBarrier.await(WAIT_TIMEOUT, TimeUnit.SECONDS);
    blockingInterceptor.suspend(true);
    return putFromLoad;
}
Also used : Arrays(java.util.Arrays) CyclicBarrier(java.util.concurrent.CyclicBarrier) Tombstone(org.hibernate.cache.infinispan.util.Tombstone) TimeoutException(java.util.concurrent.TimeoutException) Assert.assertTrue(org.junit.Assert.assertTrue) BrokenBarrierException(java.util.concurrent.BrokenBarrierException) Test(org.junit.Test) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) TestForIssue(org.hibernate.testing.TestForIssue) List(java.util.List) Future(java.util.concurrent.Future) Assert.assertFalse(org.junit.Assert.assertFalse) PutKeyValueCommand(org.infinispan.commands.write.PutKeyValueCommand) BlockingInterceptor(org.infinispan.distribution.BlockingInterceptor) Item(org.hibernate.test.cache.infinispan.functional.entities.Item) Assert.assertEquals(org.junit.Assert.assertEquals) Item(org.hibernate.test.cache.infinispan.functional.entities.Item) BlockingInterceptor(org.infinispan.distribution.BlockingInterceptor)

Aggregations

Arrays (java.util.Arrays)1 List (java.util.List)1 BrokenBarrierException (java.util.concurrent.BrokenBarrierException)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 CyclicBarrier (java.util.concurrent.CyclicBarrier)1 Future (java.util.concurrent.Future)1 TimeUnit (java.util.concurrent.TimeUnit)1 TimeoutException (java.util.concurrent.TimeoutException)1 Tombstone (org.hibernate.cache.infinispan.util.Tombstone)1 Item (org.hibernate.test.cache.infinispan.functional.entities.Item)1 TestForIssue (org.hibernate.testing.TestForIssue)1 PutKeyValueCommand (org.infinispan.commands.write.PutKeyValueCommand)1 BlockingInterceptor (org.infinispan.distribution.BlockingInterceptor)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertFalse (org.junit.Assert.assertFalse)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Test (org.junit.Test)1