Search in sources :

Example 1 with DefaultIracTombstoneManager

use of org.infinispan.container.versioning.irac.DefaultIracTombstoneManager in project infinispan by infinispan.

the class IracTombstoneUnitTest method testDelayAtHigherRate.

public void testDelayAtHigherRate() throws InterruptedException {
    int targetSize = 10;
    BlockingDeque<RunnableData> queue = new LinkedBlockingDeque<>();
    DefaultIracTombstoneManager manager = createIracTombstoneManager(queue, targetSize, 2000, new AtomicBoolean(false));
    manager.start();
    RunnableData data = queue.poll(10, TimeUnit.SECONDS);
    assertNotNull(data);
    assertEquals(1000, data.delay);
    IracMetadata metadata = createIracMetadata();
    insertTombstones(targetSize * 2, manager, metadata);
    data.runnable.run();
    data = queue.poll(10, TimeUnit.SECONDS);
    assertNotNull(data);
    assertEquals(708, data.delay);
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) IracMetadata(org.infinispan.metadata.impl.IracMetadata) DefaultIracTombstoneManager(org.infinispan.container.versioning.irac.DefaultIracTombstoneManager)

Example 2 with DefaultIracTombstoneManager

use of org.infinispan.container.versioning.irac.DefaultIracTombstoneManager in project infinispan by infinispan.

the class IracTombstoneUnitTest method createIracTombstoneManager.

private static DefaultIracTombstoneManager createIracTombstoneManager(Queue<? super RunnableData> queue, int targetSize, long maxDelay, AtomicBoolean keep) {
    DefaultIracTombstoneManager manager = new DefaultIracTombstoneManager(createConfiguration(targetSize, maxDelay));
    TestingUtil.inject(manager, createDistributionManager(), createTakeOfflineManager(), createIracManager(keep), new WithinThreadExecutor(), createScheduledExecutorService(queue), createCommandFactory(), createRpcManager());
    return manager;
}
Also used : WithinThreadExecutor(org.infinispan.util.concurrent.WithinThreadExecutor) DefaultIracTombstoneManager(org.infinispan.container.versioning.irac.DefaultIracTombstoneManager)

Example 3 with DefaultIracTombstoneManager

use of org.infinispan.container.versioning.irac.DefaultIracTombstoneManager in project infinispan by infinispan.

the class IracTombstoneUnitTest method testCleanupCantKeepUp.

public void testCleanupCantKeepUp() throws InterruptedException {
    int targetSize = 5;
    BlockingDeque<RunnableData> queue = new LinkedBlockingDeque<>();
    AtomicBoolean keep = new AtomicBoolean(true);
    DefaultIracTombstoneManager manager = createIracTombstoneManager(queue, targetSize, 1000, keep);
    manager.start();
    RunnableData data = queue.poll(10, TimeUnit.SECONDS);
    assertNotNull(data);
    assertEquals(500, data.delay);
    // Cleanup task didn't clean enough, delay goes down to 1ms
    IracMetadata metadata = createIracMetadata();
    insertTombstones(targetSize * 2, manager, metadata);
    data.runnable.run();
    data = queue.poll(10, TimeUnit.SECONDS);
    assertNotNull(data);
    assertEquals(1, data.delay);
    // Cleanup task didn't clean enough again, delay stays at 1ms
    insertTombstones(targetSize * 3, manager, metadata);
    data.runnable.run();
    data = queue.poll(10, TimeUnit.SECONDS);
    assertNotNull(data);
    assertEquals(1, data.delay);
    // Tombstones are now cleaned up, and the delay goes back up
    keep.set(false);
    data.runnable.run();
    data = queue.poll(10, TimeUnit.SECONDS);
    assertNotNull(data);
    assertEquals(32, data.delay);
    manager.stop();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) IracMetadata(org.infinispan.metadata.impl.IracMetadata) DefaultIracTombstoneManager(org.infinispan.container.versioning.irac.DefaultIracTombstoneManager)

Example 4 with DefaultIracTombstoneManager

use of org.infinispan.container.versioning.irac.DefaultIracTombstoneManager in project infinispan by infinispan.

the class IracTombstoneUnitTest method testDelayAtSameRate.

public void testDelayAtSameRate() throws InterruptedException {
    int targetSize = 20;
    BlockingDeque<RunnableData> queue = new LinkedBlockingDeque<>();
    DefaultIracTombstoneManager manager = createIracTombstoneManager(queue, targetSize, 2000, new AtomicBoolean(false));
    manager.start();
    RunnableData data = queue.poll(10, TimeUnit.SECONDS);
    assertNotNull(data);
    assertEquals(1000, data.delay);
    IracMetadata metadata = createIracMetadata();
    insertTombstones(targetSize, manager, metadata);
    data.runnable.run();
    data = queue.poll(10, TimeUnit.SECONDS);
    assertNotNull(data);
    assertEquals(1000, data.delay);
    manager.stop();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) IracMetadata(org.infinispan.metadata.impl.IracMetadata) DefaultIracTombstoneManager(org.infinispan.container.versioning.irac.DefaultIracTombstoneManager)

Example 5 with DefaultIracTombstoneManager

use of org.infinispan.container.versioning.irac.DefaultIracTombstoneManager in project infinispan by infinispan.

the class IracTombstoneUnitTest method testDelayIncreaseWithNoTombstones.

public void testDelayIncreaseWithNoTombstones() throws InterruptedException {
    BlockingDeque<RunnableData> queue = new LinkedBlockingDeque<>();
    DefaultIracTombstoneManager manager = createIracTombstoneManager(queue, 1, 1000, new AtomicBoolean(false));
    manager.start();
    RunnableData data = queue.poll(10, TimeUnit.SECONDS);
    assertNotNull(data);
    assertEquals(500, data.delay);
    // check the max limit
    for (long expectedDelay : Arrays.asList(707, 841, 917, 958, 979, 989, 994, 997, 998, 999, 999, 999)) {
        data.runnable.run();
        data = queue.poll(10, TimeUnit.SECONDS);
        assertNotNull(data);
        assertEquals(expectedDelay, data.delay);
    }
    manager.stop();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) DefaultIracTombstoneManager(org.infinispan.container.versioning.irac.DefaultIracTombstoneManager)

Aggregations

DefaultIracTombstoneManager (org.infinispan.container.versioning.irac.DefaultIracTombstoneManager)6 LinkedBlockingDeque (java.util.concurrent.LinkedBlockingDeque)5 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)5 IracMetadata (org.infinispan.metadata.impl.IracMetadata)4 WithinThreadExecutor (org.infinispan.util.concurrent.WithinThreadExecutor)1