Search in sources :

Example 56 with AsyncEventQueue

use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.

the class DescribeDiskStoreFunctionJUnitTest method testIsAsyncEventQueueUsingDiskStoreWhenUsingDefaultDiskStore.

@Test
public void testIsAsyncEventQueueUsingDiskStoreWhenUsingDefaultDiskStore() {
    final AsyncEventQueue mockQueue = mockContext.mock(AsyncEventQueue.class, "AsyncEventQueue");
    final DiskStore mockDiskStore = mockContext.mock(DiskStore.class, "DiskStore");
    mockContext.checking(new Expectations() {

        {
            oneOf(mockQueue).getDiskStoreName();
            will(returnValue(" "));
            oneOf(mockQueue).isPersistent();
            will(returnValue(true));
            oneOf(mockDiskStore).getName();
            will(returnValue(DiskStoreDetails.DEFAULT_DISK_STORE_NAME));
        }
    });
    final DescribeDiskStoreFunction function = createDescribeDiskStoreFunction(null);
    assertTrue(function.isUsingDiskStore(mockQueue, mockDiskStore));
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) Expectations(org.jmock.Expectations) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 57 with AsyncEventQueue

use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.

the class PDXAsyncEventQueueDUnitTest method createSerialAsyncEventQueue.

protected void createSerialAsyncEventQueue(VM vm, final boolean persistent) {
    SerializableCallable createSystem = new SerializableCallable() {

        public Object call() throws Exception {
            Cache cache = getCache();
            AsyncEventQueue sender = cache.createAsyncEventQueueFactory().setBatchSize(2).setBatchTimeInterval(1000).setBatchConflationEnabled(false).setPersistent(persistent).create("queue", new AsyncEventListener() {

                @Override
                public void close() {
                // TODO Auto-generated method stub
                }

                @Override
                public boolean processEvents(List<AsyncEvent> events) {
                    // do nothing
                    return true;
                }
            });
            return null;
        }
    };
    vm.invoke(createSystem);
}
Also used : SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) AsyncEvent(org.apache.geode.cache.asyncqueue.AsyncEvent) Cache(org.apache.geode.cache.Cache) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener)

Example 58 with AsyncEventQueue

use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.

the class LuceneIndexCreationPersistenceIntegrationTest method shouldStoreIndexAndQueueInTheSameDiskStoreAsTheRegion.

@Test
public void shouldStoreIndexAndQueueInTheSameDiskStoreAsTheRegion() {
    createIndex(cache, "text");
    cache.createDiskStoreFactory().setDiskDirs(new File[] { diskDirRule.get() }).create("DiskStore");
    cache.createRegionFactory(RegionShortcut.PARTITION_PERSISTENT).setDiskStoreName("DiskStore").create(REGION_NAME);
    final String diskStoreName = cache.getRegion(REGION_NAME).getAttributes().getDiskStoreName();
    verifyInternalRegions(region -> {
        assertEquals(diskStoreName, region.getAttributes().getDiskStoreName());
    });
    AsyncEventQueue queue = getIndexQueue(cache);
    assertEquals(diskStoreName, queue.getDiskStoreName());
}
Also used : AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) File(java.io.File) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 59 with AsyncEventQueue

use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.

the class LuceneIndexCreationPersistenceIntegrationTest method aeqShouldAlwaysBeDiskSynchronousWhenUserRegionIsEither.

@Test
@Parameters({ "true", "false" })
public void aeqShouldAlwaysBeDiskSynchronousWhenUserRegionIsEither(boolean synchronous) {
    createIndex(cache, "text");
    cache.createRegionFactory(RegionShortcut.PARTITION_PERSISTENT).setDiskSynchronous(synchronous).create(REGION_NAME);
    verifyInternalRegions(region -> {
        assertTrue(region.getDataPolicy().withPersistence());
        assertTrue(region.isDiskSynchronous());
    });
    AsyncEventQueue queue = getIndexQueue(cache);
    assertTrue(queue.isDiskSynchronous());
    assertEquals(true, queue.isPersistent());
}
Also used : AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) Parameters(junitparams.Parameters) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 60 with AsyncEventQueue

use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.

the class WANTestBase method waitForAsyncQueueToGetEmpty.

public static void waitForAsyncQueueToGetEmpty(String asyncQueueId) {
    AsyncEventQueue theAsyncEventQueue = null;
    Set<AsyncEventQueue> asyncEventChannels = cache.getAsyncEventQueues();
    for (AsyncEventQueue asyncChannel : asyncEventChannels) {
        if (asyncQueueId.equals(asyncChannel.getId())) {
            theAsyncEventQueue = asyncChannel;
        }
    }
    final GatewaySender sender = ((AsyncEventQueueImpl) theAsyncEventQueue).getSender();
    if (sender.isParallel()) {
        final Set<RegionQueue> queues = ((AbstractGatewaySender) sender).getQueues();
        Awaitility.await().atMost(60, TimeUnit.SECONDS).until(() -> {
            int size = 0;
            for (RegionQueue q : queues) {
                size += q.size();
            }
            assertEquals("Expected queue size to be : " + 0 + " but actual entries: " + size, 0, size);
        });
    } else {
        Awaitility.await().atMost(60, TimeUnit.SECONDS).until(() -> {
            Set<RegionQueue> queues = ((AbstractGatewaySender) sender).getQueues();
            int size = 0;
            for (RegionQueue q : queues) {
                size += q.size();
            }
            assertEquals("Expected queue size to be : " + 0 + " but actual entries: " + size, 0, size);
        });
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) AsyncEventQueueImpl(org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueImpl) RegionQueue(org.apache.geode.internal.cache.RegionQueue)

Aggregations

AsyncEventQueue (org.apache.geode.cache.asyncqueue.AsyncEventQueue)62 Test (org.junit.Test)20 AsyncEventListener (org.apache.geode.cache.asyncqueue.AsyncEventListener)19 AsyncEventQueueFactory (org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory)13 AsyncEventQueueImpl (org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueImpl)13 Cache (org.apache.geode.cache.Cache)10 GatewaySender (org.apache.geode.cache.wan.GatewaySender)9 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)9 UnitTest (org.apache.geode.test.junit.categories.UnitTest)8 Expectations (org.jmock.Expectations)8 DiskStore (org.apache.geode.cache.DiskStore)7 CacheCreation (org.apache.geode.internal.cache.xmlcache.CacheCreation)7 HashMap (java.util.HashMap)6 Map (java.util.Map)6 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)6 Region (org.apache.geode.cache.Region)5 AsyncEventQueueStats (org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueStats)5 RegionAttributesCreation (org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation)5 File (java.io.File)4 Properties (java.util.Properties)4