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);
}
}
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());
}
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();
}
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();
}
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);
}
Aggregations