use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testLOCAL_PERSISTENT_OVERFLOW.
@Test
public void testLOCAL_PERSISTENT_OVERFLOW() throws Exception {
CacheCreation cache = new CacheCreation();
RegionCreation root = (RegionCreation) cache.createRegion("cpolocal", "LOCAL_PERSISTENT_OVERFLOW");
testXml(cache);
GemFireCacheImpl c = (GemFireCacheImpl) getCache();
Region r = c.getRegion("cpolocal");
assertNotNull(r);
RegionAttributes ra = r.getAttributes();
assertEquals(DataPolicy.PERSISTENT_REPLICATE, ra.getDataPolicy());
assertEquals(Scope.LOCAL, ra.getScope());
assertEquals(EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK), ra.getEvictionAttributes());
assertEquals(LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE, c.getResourceManager().getEvictionHeapPercentage(), 0);
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testMessageSyncInterval.
/**
* Tests the {@code message-sync-interval} attribute of attribute is related to HA of
* client-queues in gemfire ca framework. This attribute is the frequency at which a messent by
* the primary cache-server node to all the secondary cache-server nodes to remove the events
* which have already been dispatched from the queue
*/
@Test
public void testMessageSyncInterval() throws Exception {
CacheCreation cache = new CacheCreation();
cache.setMessageSyncInterval(123);
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setDataPolicy(DataPolicy.NORMAL);
cache.createVMRegion("rootNORMAL", attrs);
testXml(cache);
Cache c = getCache();
assertNotNull(c);
assertEquals(123, c.getMessageSyncInterval());
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testDynamicRegionFactoryConnectionPool.
@Test
public void testDynamicRegionFactoryConnectionPool() throws Exception, IOException {
IgnoredException.addIgnoredException("Connection reset");
IgnoredException.addIgnoredException("SocketTimeoutException");
IgnoredException.addIgnoredException("ServerConnectivityException");
IgnoredException.addIgnoredException("Socket Closed");
getSystem();
VM vm0 = Host.getHost(0).getVM(0);
final int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
vm0.invoke(new SerializableCallable("Create cache server") {
public Object call() throws IOException {
DynamicRegionFactory.get().open();
Cache cache = getCache();
CacheServer bridge = cache.addCacheServer();
bridge.setPort(port);
bridge.setNotifyBySubscription(true);
bridge.start();
return null;
}
});
CacheCreation cache = new CacheCreation();
cache.createPoolFactory().addServer(NetworkUtils.getServerHostName(vm0.getHost()), port).setSubscriptionEnabled(true).create("connectionPool");
cache.setDynamicRegionFactoryConfig(new DynamicRegionFactory.Config(null, "connectionPool", false, false));
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
cache.createRegion("root", attrs);
// note that testXml can't check if they are same because enabling
// dynamic regions causes a meta region to be produced.
testXml(cache, false);
assertEquals(false, DynamicRegionFactory.get().getConfig().getRegisterInterest());
assertEquals(false, DynamicRegionFactory.get().getConfig().getPersistBackup());
assertEquals(true, DynamicRegionFactory.get().isOpen());
assertEquals(null, DynamicRegionFactory.get().getConfig().getDiskDir());
assertEquals("connectionPool", DynamicRegionFactory.get().getConfig().getPoolName());
Region dr = getCache().getRegion("__DynamicRegions");
if (dr != null) {
dr.localDestroyRegion();
}
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testTransactionWriter.
/**
* Tests that a region created with a named attributes set programmatically for delta propogation
* has the correct attributes.
*/
@Test
public void testTransactionWriter() throws Exception {
CacheCreation creation = new CacheCreation();
CacheTransactionManagerCreation ctmc = new CacheTransactionManagerCreation();
ctmc.setWriter(new TestTransactionWriter());
creation.addCacheTransactionManagerCreation(ctmc);
testXml(creation);
Cache c = getCache();
assertTrue(c instanceof GemFireCacheImpl);
c.loadCacheXml(generate(creation));
TransactionWriter tw = c.getCacheTransactionManager().getWriter();
assertTrue("tw should be TransactionWriter, but it is:" + tw, tw instanceof TestTransactionWriter);
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testResourceManagerThresholds.
/**
* Test the ResourceManager element's critical-heap-percentage and eviction-heap-percentage
* attributes
*/
@Test
public void testResourceManagerThresholds() throws Exception {
CacheCreation cache = new CacheCreation();
final float low = 90.0f;
final float high = 95.0f;
Cache c;
ResourceManagerCreation rmc = new ResourceManagerCreation();
rmc.setEvictionHeapPercentage(low);
rmc.setCriticalHeapPercentage(high);
cache.setResourceManagerCreation(rmc);
testXml(cache);
{
c = getCache();
assertEquals(low, c.getResourceManager().getEvictionHeapPercentage(), 0);
assertEquals(high, c.getResourceManager().getCriticalHeapPercentage(), 0);
}
closeCache();
rmc = new ResourceManagerCreation();
// Set them to similar values
rmc.setEvictionHeapPercentage(low);
rmc.setCriticalHeapPercentage(low + 1);
cache.setResourceManagerCreation(rmc);
testXml(cache);
{
c = getCache();
assertEquals(low, c.getResourceManager().getEvictionHeapPercentage(), 0);
assertEquals(low + 1, c.getResourceManager().getCriticalHeapPercentage(), 0);
}
closeCache();
rmc = new ResourceManagerCreation();
rmc.setEvictionHeapPercentage(high);
rmc.setCriticalHeapPercentage(low);
cache.setResourceManagerCreation(rmc);
IgnoredException expectedException = IgnoredException.addIgnoredException(LocalizedStrings.MemoryMonitor_EVICTION_PERCENTAGE_LTE_CRITICAL_PERCENTAGE.toLocalizedString());
try {
testXml(cache);
assertTrue(false);
} catch (IllegalArgumentException expected) {
} finally {
expectedException.remove();
closeCache();
}
// Disable eviction
rmc = new ResourceManagerCreation();
rmc.setEvictionHeapPercentage(0);
rmc.setCriticalHeapPercentage(low);
cache.setResourceManagerCreation(rmc);
testXml(cache);
{
c = getCache();
assertEquals(0f, c.getResourceManager().getEvictionHeapPercentage(), 0);
assertEquals(low, c.getResourceManager().getCriticalHeapPercentage(), 0);
}
closeCache();
// Disable refusing ops in "red zone"
rmc = new ResourceManagerCreation();
rmc.setEvictionHeapPercentage(low);
rmc.setCriticalHeapPercentage(0);
cache.setResourceManagerCreation(rmc);
testXml(cache);
{
c = getCache();
assertEquals(low, c.getResourceManager().getEvictionHeapPercentage(), 0);
assertEquals(0f, c.getResourceManager().getCriticalHeapPercentage(), 0);
}
closeCache();
// Disable both
rmc = new ResourceManagerCreation();
rmc.setEvictionHeapPercentage(0);
rmc.setCriticalHeapPercentage(0);
cache.setResourceManagerCreation(rmc);
testXml(cache);
c = getCache();
assertEquals(0f, c.getResourceManager().getEvictionHeapPercentage(), 0);
assertEquals(0f, c.getResourceManager().getCriticalHeapPercentage(), 0);
}
Aggregations