use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.
the class CacheXml66DUnitTest method testBridgeAttributesRelatedToHAOverFlow65.
@Test
public void testBridgeAttributesRelatedToHAOverFlow65() throws Exception {
CacheCreation cache = new CacheCreation();
cache.setMessageSyncInterval(3445);
CacheServer bs = cache.addCacheServer();
ClientSubscriptionConfig csc = bs.getClientSubscriptionConfig();
csc.setEvictionPolicy("entry");
cache.getLogger().config("EvictionPolicy : " + csc.getEvictionPolicy());
csc.setCapacity(501);
cache.getLogger().config("EvictionCapacity : " + csc.getCapacity());
File overflowDirectory = new File("overFlow");
overflowDirectory.mkdirs();
DiskStoreFactory dsf = cache.createDiskStoreFactory();
File[] dirs1 = new File[] { overflowDirectory };
DiskStore ds1 = dsf.setDiskDirs(dirs1).create(getUniqueName());
csc.setDiskStoreName(getUniqueName());
try {
csc.setOverflowDirectory("overFlow");
} catch (IllegalStateException e) {
assertTrue(e.getMessage().contains(LocalizedStrings.DiskStore_Deprecated_API_0_Cannot_Mix_With_DiskStore_1.toLocalizedString("setOverflowDirectory", getUniqueName())));
}
cache.getLogger().config("Eviction disk store : " + csc.getDiskStoreName());
bs.setPort(AvailablePortHelper.getRandomAvailableTCPPort());
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setDataPolicy(DataPolicy.NORMAL);
cache.createVMRegion("rootNORMAL", attrs);
testXml(cache);
Cache c = getCache();
assertNotNull(c);
CacheServer server = (CacheServer) cache.getCacheServers().iterator().next();
assertNotNull(server);
ClientSubscriptionConfig chaqf = server.getClientSubscriptionConfig();
assertEquals("entry", chaqf.getEvictionPolicy());
assertEquals(501, chaqf.getCapacity());
DiskStore dsi = cache.findDiskStore(chaqf.getDiskStoreName());
assertEquals("overFlow", dsi.getDiskDirs()[0].toString());
}
use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.
the class CacheXml66DUnitTest method testEnableAsyncConflationAttribute.
/**
* Test EnableAsyncConflation region attribute
*
* @since GemFire 4.2
*/
@Test
public void testEnableAsyncConflationAttribute() throws Exception {
CacheCreation cache = new CacheCreation();
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setEnableAsyncConflation(true);
cache.createRegion("root", attrs);
testXml(cache);
assertEquals(true, cache.getRegion("root").getAttributes().getEnableAsyncConflation());
}
use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.
the class CacheXml66DUnitTest method testNoConnectionPools.
@Test
public void testNoConnectionPools() throws Exception {
CacheCreation cache = new CacheCreation();
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setPoolName("mypool");
cache.createVMRegion("rootNORMAL", attrs);
IgnoredException expectedException = IgnoredException.addIgnoredException(LocalizedStrings.AbstractRegion_THE_CONNECTION_POOL_0_HAS_NOT_BEEN_CREATED.toLocalizedString("mypool"));
try {
testXml(cache);
fail("expected IllegalStateException");
} catch (IllegalStateException expected) {
} finally {
expectedException.remove();
}
}
use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.
the class CacheXml66DUnitTest method testExplicitConnectionPool.
/**
* test for enabling PRsingleHop feature. Test for enabling multiuser-authentication attribute.
*/
@Test
public void testExplicitConnectionPool() throws Exception {
getSystem();
CacheCreation cache = new CacheCreation();
PoolFactory f = cache.createPoolFactory();
f.addServer(ALIAS2, 3777).addServer(ALIAS1, 3888);
f.setFreeConnectionTimeout(12345).setLoadConditioningInterval(12345).setSocketBufferSize(12345).setThreadLocalConnections(true).setPRSingleHopEnabled(true).setReadTimeout(12345).setMinConnections(12346).setMaxConnections(12347).setRetryAttempts(12348).setIdleTimeout(12349).setPingInterval(12350).setStatisticInterval(12351).setServerGroup("mygroup").setSubscriptionRedundancy(12345).setSubscriptionMessageTrackingTimeout(12345).setSubscriptionAckInterval(333).setMultiuserAuthentication(true);
f.create("mypool");
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setPoolName("mypool");
// required for multiuser mode
attrs.setDataPolicy(DataPolicy.EMPTY);
cache.createVMRegion("rootNORMAL", attrs);
IgnoredException.addIgnoredException("Connection refused: connect");
testXml(cache);
Cache c = getCache();
assertNotNull(c);
Region r = c.getRegion("rootNORMAL");
assertNotNull(r);
assertEquals("mypool", r.getAttributes().getPoolName());
Pool cp = PoolManager.find("mypool");
assertNotNull(cp);
assertEquals(0, cp.getLocators().size());
assertEquals(2, cp.getServers().size());
assertEquals(createINSA(ALIAS2, 3777), cp.getServers().get(0));
assertEquals(createINSA(ALIAS1, 3888), cp.getServers().get(1));
assertEquals(12345, cp.getFreeConnectionTimeout());
assertEquals(12345, cp.getLoadConditioningInterval());
assertEquals(12345, cp.getSocketBufferSize());
assertEquals(true, cp.getThreadLocalConnections());
assertEquals(true, cp.getPRSingleHopEnabled());
assertEquals(12345, cp.getReadTimeout());
assertEquals(12346, cp.getMinConnections());
assertEquals(12347, cp.getMaxConnections());
assertEquals(12348, cp.getRetryAttempts());
assertEquals(12349, cp.getIdleTimeout());
assertEquals(12350, cp.getPingInterval());
assertEquals(12351, cp.getStatisticInterval());
assertEquals("mygroup", cp.getServerGroup());
// TODO: commented this out until queues are implemented
// assertIndexDetailsEquals(true, cp.getQueueEnabled());
assertEquals(12345, cp.getSubscriptionRedundancy());
assertEquals(12345, cp.getSubscriptionMessageTrackingTimeout());
assertEquals(333, cp.getSubscriptionAckInterval());
assertEquals(true, cp.getMultiuserAuthentication());
}
use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.
the class CacheXml66DUnitTest method testNestedRegions.
/**
* Tests nested regions
*/
@Test
public void testNestedRegions() throws Exception {
CacheCreation cache = new CacheCreation();
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setScope(Scope.DISTRIBUTED_NO_ACK);
RegionCreation root = (RegionCreation) cache.createRegion("root", attrs);
{
attrs = new RegionAttributesCreation(cache);
attrs.setScope(Scope.DISTRIBUTED_NO_ACK);
attrs.setMirrorType(MirrorType.KEYS_VALUES);
attrs.setInitialCapacity(142);
attrs.setLoadFactor(42.42f);
attrs.setStatisticsEnabled(false);
root.createSubregion("one", attrs);
}
{
attrs = new RegionAttributesCreation(cache);
attrs.setScope(Scope.DISTRIBUTED_ACK);
attrs.setMirrorType(MirrorType.KEYS);
attrs.setInitialCapacity(242);
Region region = root.createSubregion("two", attrs);
{
attrs = new RegionAttributesCreation(cache);
attrs.setScope(Scope.GLOBAL);
attrs.setLoadFactor(43.43f);
region.createSubregion("three", attrs);
}
}
testXml(cache);
}
Aggregations