Search in sources :

Example 41 with CacheCreation

use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.

the class CacheXml70DUnitTest method testAsyncEventQueueWithGatewayEventFilter.

/**
   * Added to test the scenario of defect #50600.
   */
@Test
public void testAsyncEventQueueWithGatewayEventFilter() throws Exception {
    getSystem();
    CacheCreation cache = new CacheCreation();
    String id = "WBCLChannel";
    AsyncEventQueueFactory factory = cache.createAsyncEventQueueFactory();
    factory.setBatchSize(100);
    factory.setBatchTimeInterval(500);
    factory.setBatchConflationEnabled(true);
    factory.setMaximumQueueMemory(200);
    factory.setDiskSynchronous(true);
    factory.setParallel(false);
    factory.setDispatcherThreads(33);
    AsyncEventListener eventListener = new MyAsyncEventListener();
    AsyncEventQueue asyncEventQueue = factory.create(id, eventListener);
    RegionAttributesCreation attrs = new RegionAttributesCreation();
    attrs.addAsyncEventQueueId(asyncEventQueue.getId());
    cache.createRegion("UserRegion", attrs);
    testXml(cache);
    Cache c = getCache();
    assertNotNull(c);
    Set<AsyncEventQueue> asyncEventQueuesOnCache = c.getAsyncEventQueues();
    assertTrue("Size of asyncEventQueues should be greater than 0", asyncEventQueuesOnCache.size() > 0);
    for (AsyncEventQueue asyncEventQueueOnCache : asyncEventQueuesOnCache) {
        CacheXml70DUnitTest.validateAsyncEventQueue(asyncEventQueue, asyncEventQueueOnCache);
    }
}
Also used : AsyncEventQueueFactory(org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener) Cache(org.apache.geode.cache.Cache) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 42 with CacheCreation

use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.

the class CacheXml70DUnitTest method testConcurrentAsyncEventQueue.

@Test
public void testConcurrentAsyncEventQueue() throws Exception {
    getSystem();
    CacheCreation cache = new CacheCreation();
    String id = "WBCLChannel";
    AsyncEventQueueFactory factory = cache.createAsyncEventQueueFactory();
    factory.setBatchSize(100);
    factory.setBatchTimeInterval(500);
    factory.setBatchConflationEnabled(true);
    factory.setMaximumQueueMemory(200);
    factory.setDiskSynchronous(true);
    factory.setDispatcherThreads(5);
    factory.setOrderPolicy(OrderPolicy.THREAD);
    AsyncEventListener eventListener = new MyAsyncEventListener();
    AsyncEventQueue asyncEventQueue = factory.create(id, eventListener);
    RegionAttributesCreation attrs = new RegionAttributesCreation();
    attrs.addAsyncEventQueueId(asyncEventQueue.getId());
    cache.createRegion("UserRegion", attrs);
    testXml(cache);
    Cache c = getCache();
    assertNotNull(c);
    Set<AsyncEventQueue> asyncEventQueuesOnCache = c.getAsyncEventQueues();
    assertTrue("Size of asyncEventQueues should be greater than 0", asyncEventQueuesOnCache.size() > 0);
    for (AsyncEventQueue asyncEventQueueOnCache : asyncEventQueuesOnCache) {
        validateConcurrentAsyncEventQueue(asyncEventQueue, asyncEventQueueOnCache);
    }
}
Also used : AsyncEventQueueFactory(org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener) Cache(org.apache.geode.cache.Cache) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 43 with CacheCreation

use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.

the class CacheXml70DUnitTest method testConcurrencyChecksEnabled.

/** make sure we can create regions with concurrencyChecksEnabled=true */
@Test
public void testConcurrencyChecksEnabled() throws Exception {
    CacheCreation cache = new CacheCreation();
    RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
    attrs.setScope(Scope.DISTRIBUTED_ACK);
    attrs.setDataPolicy(DataPolicy.REPLICATE);
    attrs.setConcurrencyChecksEnabled(true);
    cache.createRegion("replicated", attrs);
    attrs = new RegionAttributesCreation(cache);
    attrs.setDataPolicy(DataPolicy.PARTITION);
    attrs.setConcurrencyChecksEnabled(true);
    cache.createRegion("partitioned", attrs);
    attrs = new RegionAttributesCreation(cache);
    attrs.setScope(Scope.DISTRIBUTED_ACK);
    attrs.setDataPolicy(DataPolicy.EMPTY);
    attrs.setConcurrencyChecksEnabled(true);
    cache.createRegion("empty", attrs);
    attrs = new RegionAttributesCreation(cache);
    attrs.setScope(Scope.DISTRIBUTED_ACK);
    attrs.setConcurrencyChecksEnabled(true);
    cache.createRegion("normal", attrs);
    testXml(cache);
    Cache c = getCache();
    assertNotNull(c);
    Region region = c.getRegion("replicated");
    assertNotNull(region);
    assertTrue("expected concurrency checks to be enabled", region.getAttributes().getConcurrencyChecksEnabled());
    region.localDestroyRegion();
    region = c.getRegion("partitioned");
    assertNotNull(region);
    assertTrue("expected concurrency checks to be enabled", region.getAttributes().getConcurrencyChecksEnabled());
    region.localDestroyRegion();
    region = c.getRegion("empty");
    assertNotNull(region);
    assertTrue("expected concurrency checks to be enabled", region.getAttributes().getConcurrencyChecksEnabled());
    region.localDestroyRegion();
    region = c.getRegion("normal");
    assertNotNull(region);
    assertTrue("expected concurrency checks to be enabled", region.getAttributes().getConcurrencyChecksEnabled());
    region.localDestroyRegion();
}
Also used : RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) Region(org.apache.geode.cache.Region) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) Cache(org.apache.geode.cache.Cache) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 44 with CacheCreation

use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.

the class CacheXml80DUnitTest method testCompressor.

@SuppressWarnings("rawtypes")
@Test
public void testCompressor() throws Exception {
    final String regionName = "testCompressor";
    final CacheCreation cache = new CacheCreation();
    final RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
    attrs.setCompressor(SnappyCompressor.getDefaultInstance());
    /* Region regionBefore = */
    cache.createRegion(regionName, attrs);
    testXml(cache);
    final Cache c = getCache();
    assertNotNull(c);
    final Region regionAfter = c.getRegion(regionName);
    assertNotNull(regionAfter);
    assertTrue(SnappyCompressor.getDefaultInstance().equals(regionAfter.getAttributes().getCompressor()));
    regionAfter.localDestroyRegion();
}
Also used : RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) Region(org.apache.geode.cache.Region) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) Cache(org.apache.geode.cache.Cache) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 45 with CacheCreation

use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.

the class CacheXml80DUnitTest method testCacheServerDisableTcpNoDelay.

@Test
public void testCacheServerDisableTcpNoDelay() throws Exception {
    CacheCreation cache = new CacheCreation();
    CacheServer cs = cache.addCacheServer();
    cs.setPort(0);
    cs.setTcpNoDelay(false);
    RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
    attrs.setDataPolicy(DataPolicy.NORMAL);
    cache.createVMRegion("rootNORMAL", attrs);
    testXml(cache);
}
Also used : CacheServer(org.apache.geode.cache.server.CacheServer) RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

CacheCreation (org.apache.geode.internal.cache.xmlcache.CacheCreation)153 Test (org.junit.Test)143 ClientCacheCreation (org.apache.geode.internal.cache.xmlcache.ClientCacheCreation)114 RegionAttributesCreation (org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation)86 Region (org.apache.geode.cache.Region)62 LocalRegion (org.apache.geode.internal.cache.LocalRegion)57 Cache (org.apache.geode.cache.Cache)53 DistributedRegion (org.apache.geode.internal.cache.DistributedRegion)53 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)53 ClientCache (org.apache.geode.cache.client.ClientCache)42 RegionAttributes (org.apache.geode.cache.RegionAttributes)35 GemFireCacheImpl (org.apache.geode.internal.cache.GemFireCacheImpl)35 RegionCreation (org.apache.geode.internal.cache.xmlcache.RegionCreation)35 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)25 CacheServer (org.apache.geode.cache.server.CacheServer)17 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)16 File (java.io.File)15 DiskWriteAttributesFactory (org.apache.geode.cache.DiskWriteAttributesFactory)12 AttributesFactory (org.apache.geode.cache.AttributesFactory)9 FixedPartitionAttributes (org.apache.geode.cache.FixedPartitionAttributes)9