Search in sources :

Example 21 with RegionAttributesCreation

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

the class CacheXml66DUnitTest method testConstrainedValues.

/**
   * Tests the value constraints region attribute that was added in GemFire 4.0.
   *
   * @since GemFire 4.1
   */
@Test
public void testConstrainedValues() throws Exception {
    CacheCreation cache = new CacheCreation();
    RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
    attrs.setValueConstraint(String.class);
    cache.createRegion("root", attrs);
    testXml(cache);
}
Also used : RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) Test(org.junit.Test)

Example 22 with RegionAttributesCreation

use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation 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 23 with RegionAttributesCreation

use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation 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 24 with RegionAttributesCreation

use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation 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 25 with RegionAttributesCreation

use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation 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)

Aggregations

RegionAttributesCreation (org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation)87 CacheCreation (org.apache.geode.internal.cache.xmlcache.CacheCreation)86 Test (org.junit.Test)85 ClientCacheCreation (org.apache.geode.internal.cache.xmlcache.ClientCacheCreation)64 Region (org.apache.geode.cache.Region)37 Cache (org.apache.geode.cache.Cache)35 LocalRegion (org.apache.geode.internal.cache.LocalRegion)32 DistributedRegion (org.apache.geode.internal.cache.DistributedRegion)28 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)28 ClientCache (org.apache.geode.cache.client.ClientCache)27 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)17 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)14 File (java.io.File)13 RegionAttributes (org.apache.geode.cache.RegionAttributes)11 RegionCreation (org.apache.geode.internal.cache.xmlcache.RegionCreation)11 DiskWriteAttributesFactory (org.apache.geode.cache.DiskWriteAttributesFactory)10 FixedPartitionAttributes (org.apache.geode.cache.FixedPartitionAttributes)9 CacheServer (org.apache.geode.cache.server.CacheServer)8 AttributesFactory (org.apache.geode.cache.AttributesFactory)7 PartitionAttributes (org.apache.geode.cache.PartitionAttributes)7