use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.
the class CacheXml66DUnitTest method testMembershipAttributes.
/**
* Test xml support of MembershipAttributes.
*/
@Test
public void testMembershipAttributes() throws Exception {
final String MY_ROLES = "Foo, Bip, BAM";
final String[][] roles = new String[][] { { "Foo" }, { "Bip", "BAM" } };
final LossAction[] policies = (LossAction[]) LossAction.VALUES.toArray(new LossAction[LossAction.VALUES.size()]);
final ResumptionAction[] actions = (ResumptionAction[]) ResumptionAction.VALUES.toArray(new ResumptionAction[ResumptionAction.VALUES.size()]);
CacheCreation cache = new CacheCreation();
// for each policy, try each action and each role...
for (int policy = 0; policy < policies.length; policy++) {
for (int action = 0; action < actions.length; action++) {
for (int role = 0; role < roles.length; role++) {
String[] theRoles = roles[role];
LossAction thePolicy = policies[policy];
ResumptionAction theAction = actions[action];
// if (theRoles.length == 0 && (thePolicy != LossAction.NONE || theAction !=
// ResumptionAction.NONE
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
MembershipAttributes ra = new MembershipAttributes(theRoles, thePolicy, theAction);
attrs.setMembershipAttributes(ra);
String region = "rootMEMBERSHIP_ATTRIBUTES_" + policy + "_" + action + "_" + role;
cache.createRegion(region, attrs);
}
}
}
{
// make our system play the roles used by this test so the create regions
// will not think the a required role is missing
Properties config = new Properties();
config.setProperty(ROLES, MY_ROLES);
this.xmlProps = config;
}
DistributedRegion.ignoreReconnect = true;
try {
testXml(cache);
} finally {
this.xmlProps = null;
try {
preTearDown();
} finally {
DistributedRegion.ignoreReconnect = false;
}
}
}
use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.
the class CacheXml66DUnitTest method testDynamicRegionFactoryDiskDir.
/**
* @since GemFire 4.3
*/
@Test
public void testDynamicRegionFactoryDiskDir() throws Exception {
CacheCreation cache = new CacheCreation();
File f = new File("diskDir");
f.mkdirs();
cache.setDynamicRegionFactoryConfig(new DynamicRegionFactory.Config(f, null, true, true));
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(true, DynamicRegionFactory.get().isOpen());
assertEquals(f.getAbsoluteFile(), DynamicRegionFactory.get().getConfig().getDiskDir());
Region dr = getCache().getRegion("__DynamicRegions");
if (dr != null) {
dr.localDestroyRegion();
}
}
use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.
the class CacheXml66DUnitTest method testRegionAttributesForRegionEntryCloning.
/**
* Tests that a region created with a named attributes set programmatically for delta propogation
* has the correct attributes.
*/
@Test
public void testRegionAttributesForRegionEntryCloning() throws Exception {
final String rNameBase = getUniqueName();
final String r1 = rNameBase + "1";
// Setting multi-cast via nested region attributes
CacheCreation creation = new CacheCreation();
RegionAttributesCreation attrs = new RegionAttributesCreation(creation);
attrs.setScope(Scope.LOCAL);
attrs.setEarlyAck(false);
attrs.setCloningEnable(false);
attrs.setMulticastEnabled(true);
creation.createRegion(r1, attrs);
testXml(creation);
Cache c = getCache();
assertTrue(c instanceof GemFireCacheImpl);
c.loadCacheXml(generate(creation));
Region reg1 = c.getRegion(r1);
assertNotNull(reg1);
assertEquals(Scope.LOCAL, reg1.getAttributes().getScope());
assertFalse(reg1.getAttributes().getEarlyAck());
assertTrue(reg1.getAttributes().getMulticastEnabled());
assertFalse(reg1.getAttributes().getCloningEnabled());
// changing Clonned setting
reg1.getAttributesMutator().setCloningEnabled(true);
assertTrue(reg1.getAttributes().getCloningEnabled());
reg1.getAttributesMutator().setCloningEnabled(false);
assertFalse(reg1.getAttributes().getCloningEnabled());
// for sub region - a child attribute should be inherited
String sub = "subRegion";
RegionAttributesCreation attrsSub = new RegionAttributesCreation(creation);
attrsSub.setScope(Scope.LOCAL);
reg1.createSubregion(sub, attrsSub);
Region subRegion = reg1.getSubregion(sub);
assertFalse(subRegion.getAttributes().getCloningEnabled());
subRegion.getAttributesMutator().setCloningEnabled(true);
assertTrue(subRegion.getAttributes().getCloningEnabled());
}
use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.
the class CacheXml66DUnitTest method testClientSubscriptionQueueUsingDefaultDS.
@Test
public void testClientSubscriptionQueueUsingDefaultDS() 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);
// don't set diskstore or overflowdir
cache.getLogger().config("EvictionCapacity : " + csc.getCapacity());
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());
File curDir = new File(".").getAbsoluteFile();
File lockFile = new File(curDir, "DRLK_IF" + GemFireCacheImpl.getDefaultDiskStoreName() + ".lk");
assertTrue(lockFile.exists());
}
use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.
the class CacheXml66DUnitTest method testPreloadDataPolicy.
@Test
public void testPreloadDataPolicy() throws Exception {
CacheCreation cache = new CacheCreation();
{
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setDataPolicy(DataPolicy.NORMAL);
cache.createRegion("rootNORMAL", attrs);
}
{
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setDataPolicy(DataPolicy.NORMAL);
attrs.setSubscriptionAttributes(new SubscriptionAttributes(InterestPolicy.ALL));
cache.createRegion("rootNORMAL_ALL", attrs);
}
{
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setMirrorType(MirrorType.KEYS_VALUES);
cache.createRegion("rootREPLICATE", attrs);
}
{
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
cache.createRegion("rootPERSISTENT_REPLICATE", attrs);
}
{
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setDataPolicy(DataPolicy.EMPTY);
cache.createRegion("rootEMPTY", attrs);
}
{
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setDataPolicy(DataPolicy.EMPTY);
attrs.setSubscriptionAttributes(new SubscriptionAttributes(InterestPolicy.ALL));
cache.createRegion("rootEMPTY_ALL", attrs);
}
{
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setDataPolicy(DataPolicy.PRELOADED);
attrs.setSubscriptionAttributes(new SubscriptionAttributes(InterestPolicy.ALL));
cache.createRegion("rootPRELOADED_ALL", attrs);
}
testXml(cache);
}
Aggregations