throw new CartridgeAgentException(msg, e);
}
private ClusteringAgent createClusteringAgent(ConfigurationContext configurationContext,
String clusterDomain) throws ClusteringFault {
TribesClusteringAgent agent = new TribesClusteringAgent();
addParameter(agent, "AvoidInitiation", "true");
for (String key : conf.stringPropertyNames()) {
if (key.startsWith("clustering.")) {
addParameter(agent,
key.substring(key.indexOf(".") + 1),
conf.getProperty(key));
}
}
List<Member> members = new ArrayList<Member>();
for (int i = 1; i < Integer.MAX_VALUE; i++) {
String host = conf.getProperty("members." + i + ".host");
String port = conf.getProperty("members." + i + ".port");
if (host == null || port == null) {
break;
}
members.add(new Member(host, Integer.parseInt(port)));
}
agent.setMembers(members);
addParameter(agent, "domain", clusterDomain);
agent.setConfigurationContext(configurationContext);
List<MembershipListener> membershipListeners = new ArrayList<MembershipListener>();
membershipListeners.add(new RegistrantMembershipListener(this, configurationContext));
agent.setMembershipListeners(membershipListeners);
return agent;
}