Search in sources :

Example 1 with RegionAttributesCreation

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

the class CacheXml70GatewayDUnitTest 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);
    factory.addGatewayEventFilter(new MyGatewayEventFilter());
    AsyncEventListener eventListener = new CacheXml70DUnitTest.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) CacheXml70DUnitTest(org.apache.geode.cache30.CacheXml70DUnitTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 2 with RegionAttributesCreation

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

the class CacheXml81DUnitTest method testRegionExtension.

/**
   * Test extensions to <code>region</code> element.
   * 
   * @since GemFire 8.1
   */
@Test
public void testRegionExtension() throws Exception {
    final String regionName = "testRegionExtension";
    final CacheCreation cache = new CacheCreation();
    final RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
    @SuppressWarnings("unchecked") Extensible<Region<?, ?>> region = (Extensible<Region<?, ?>>) cache.createRegion(regionName, attrs);
    final MockRegionExtension extension = new MockRegionExtension("test");
    region.getExtensionPoint().addExtension(extension);
    assertEquals(0, extension.beforeCreateCounter.get());
    assertEquals(0, extension.onCreateCounter.get());
    assertEquals(0, extension.getXmlGeneratorCounter.get());
    testXml(cache);
    assertEquals(0, extension.beforeCreateCounter.get());
    assertEquals(0, extension.onCreateCounter.get());
    assertEquals(1, extension.getXmlGeneratorCounter.get());
    @SuppressWarnings("unchecked") final Extensible<Region<?, ?>> r = (Extensible<Region<?, ?>>) getCache().getRegion(regionName);
    assertNotNull(r);
    final MockRegionExtension m = (MockRegionExtension) r.getExtensionPoint().getExtensions().iterator().next();
    assertNotNull(m);
    assertEquals(1, m.beforeCreateCounter.get());
    assertEquals(1, m.onCreateCounter.get());
    assertEquals(0, m.getXmlGeneratorCounter.get());
}
Also used : Extensible(org.apache.geode.internal.cache.extension.Extensible) RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) Region(org.apache.geode.cache.Region) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) MockRegionExtension(org.apache.geode.internal.cache.extension.mock.MockRegionExtension) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 3 with RegionAttributesCreation

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

the class CacheXmlGeode10DUnitTest method testEnableOffHeapMemory.

@SuppressWarnings("rawtypes")
@Test
public void testEnableOffHeapMemory() throws Exception {
    System.setProperty(DistributionConfig.GEMFIRE_PREFIX + OFF_HEAP_MEMORY_SIZE, "1m");
    final String regionName = "testEnableOffHeapMemory";
    final CacheCreation cache = new CacheCreation();
    final RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
    attrs.setOffHeap(true);
    assertEquals(true, attrs.getOffHeap());
    final Region regionBefore = cache.createRegion(regionName, attrs);
    assertNotNull(regionBefore);
    assertEquals(true, regionBefore.getAttributes().getOffHeap());
    testXml(cache);
    final Cache c = getCache();
    assertNotNull(c);
    final Region regionAfter = c.getRegion(regionName);
    assertNotNull(regionAfter);
    assertEquals(true, regionAfter.getAttributes().getOffHeap());
    assertEquals(true, ((RegionEntryContext) regionAfter).getOffHeap());
    regionAfter.localDestroyRegion();
}
Also used : RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) LocalRegion(org.apache.geode.internal.cache.LocalRegion) 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 4 with RegionAttributesCreation

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

the class CacheXmlGeode10DUnitTest method testAsyncEventQueueIsForwardExpirationDestroyAttribute.

@SuppressWarnings("rawtypes")
@Test
public void testAsyncEventQueueIsForwardExpirationDestroyAttribute() throws Exception {
    final String regionName = this.testName.getMethodName();
    // Create AsyncEventQueue with Listener
    final CacheCreation cache = new CacheCreation();
    AsyncEventQueueFactory factory = cache.createAsyncEventQueueFactory();
    AsyncEventListener listener = new MyAsyncEventListenerGeode10();
    // Test for default forwardExpirationDestroy attribute value (which is false)
    String aeqId1 = "aeqWithDefaultFED";
    factory.create(aeqId1, listener);
    AsyncEventQueue aeq1 = cache.getAsyncEventQueue(aeqId1);
    assertFalse(aeq1.isForwardExpirationDestroy());
    // Test by setting forwardExpirationDestroy attribute value.
    String aeqId2 = "aeqWithFEDsetToTrue";
    factory.setForwardExpirationDestroy(true);
    factory.create(aeqId2, listener);
    AsyncEventQueue aeq2 = cache.getAsyncEventQueue(aeqId2);
    assertTrue(aeq2.isForwardExpirationDestroy());
    // Create region and set the AsyncEventQueue
    final RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
    attrs.addAsyncEventQueueId(aeqId2);
    final Region regionBefore = cache.createRegion(regionName, attrs);
    assertNotNull(regionBefore);
    assertTrue(regionBefore.getAttributes().getAsyncEventQueueIds().size() == 1);
    testXml(cache);
    final Cache c = getCache();
    assertNotNull(c);
    aeq1 = c.getAsyncEventQueue(aeqId1);
    assertFalse(aeq1.isForwardExpirationDestroy());
    aeq2 = c.getAsyncEventQueue(aeqId2);
    assertTrue(aeq2.isForwardExpirationDestroy());
    final Region regionAfter = c.getRegion(regionName);
    assertNotNull(regionAfter);
    assertTrue(regionAfter.getAttributes().getAsyncEventQueueIds().size() == 1);
    regionAfter.localDestroyRegion();
    // Clear AsyncEventQueues.
    c.close();
}
Also used : AsyncEventQueueFactory(org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) LocalRegion(org.apache.geode.internal.cache.LocalRegion) Region(org.apache.geode.cache.Region) 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 5 with RegionAttributesCreation

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

the class CacheXml66DUnitTest method testPartitionedRegionAttributesForCoLocation.

@Test
public void testPartitionedRegionAttributesForCoLocation() throws Exception {
    closeCache();
    CacheCreation cache = new CacheCreation();
    RegionAttributesCreation custAttrs = new RegionAttributesCreation(cache);
    RegionAttributesCreation orderAttrs = new RegionAttributesCreation(cache);
    PartitionAttributesFactory custPaf = new PartitionAttributesFactory();
    PartitionAttributesFactory orderPaf = new PartitionAttributesFactory();
    custPaf.setRedundantCopies(1);
    custPaf.setTotalMaxMemory(500);
    custPaf.setLocalMaxMemory(100);
    custAttrs.setPartitionAttributes(custPaf.create());
    cache.createRegion("Customer", custAttrs);
    orderPaf.setRedundantCopies(1);
    orderPaf.setTotalMaxMemory(500);
    orderPaf.setLocalMaxMemory(100);
    orderPaf.setColocatedWith("Customer");
    orderAttrs.setPartitionAttributes(orderPaf.create());
    cache.createRegion("Order", orderAttrs);
    testXml(cache);
    Cache c = getCache();
    assertNotNull(c);
    Region cust = c.getRegion(Region.SEPARATOR + "Customer");
    assertNotNull(cust);
    Region order = c.getRegion(Region.SEPARATOR + "Order");
    assertNotNull(order);
    String coLocatedRegion = order.getAttributes().getPartitionAttributes().getColocatedWith();
    assertEquals("Customer", coLocatedRegion);
}
Also used : PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) LocalRegion(org.apache.geode.internal.cache.LocalRegion) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) Region(org.apache.geode.cache.Region) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) Cache(org.apache.geode.cache.Cache) ClientCache(org.apache.geode.cache.client.ClientCache) Test(org.junit.Test)

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