use of org.apache.geode.cache.LossAction in project geode by apache.
the class CacheXmlParser method endMembershipAttributes.
/**
* When a <code>membership-attributes</code> element is finished, the arguments for constructing
* the MembershipAttributes are on the stack.
*/
private void endMembershipAttributes() {
Set roles = new HashSet();
Object obj = null;
while (!(obj instanceof Object[])) {
obj = stack.pop();
if (obj instanceof String) {
// found a required-role name
roles.add(obj);
}
}
Object[] attrs = (Object[]) obj;
String laName = ((String) attrs[0]).toUpperCase().replace('-', '_');
String raName = ((String) attrs[1]).toUpperCase().replace('-', '_');
LossAction laction = LossAction.fromName(laName);
ResumptionAction raction = ResumptionAction.fromName(raName);
MembershipAttributes ra = new MembershipAttributes((String[]) roles.toArray(new String[roles.size()]), laction, raction);
RegionAttributesCreation rattrs = (RegionAttributesCreation) stack.peek();
rattrs.setMembershipAttributes(ra);
}
use of org.apache.geode.cache.LossAction 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;
}
}
}
Aggregations