Parameter memberPassword = getParameter(HazelcastConstants.GROUP_PASSWORD);
if (memberPassword != null) {
groupConfig.setPassword((String) memberPassword.getValue());
}
NetworkConfig nwConfig = primaryHazelcastConfig.getNetworkConfig();
Parameter localMemberHost = getParameter(HazelcastConstants.LOCAL_MEMBER_HOST);
if (localMemberHost != null) {
nwConfig.setPublicAddress(((String) localMemberHost.getValue()).trim());
} else {
try {
String ipAddress = Utils.getIpAddress();
nwConfig.setPublicAddress(ipAddress);
} catch (SocketException e) {
log.error("Could not set local member host", e);
}
}
Parameter localMemberPort = getParameter(HazelcastConstants.LOCAL_MEMBER_PORT);
if (localMemberPort != null) {
String port = ((String) localMemberPort.getValue()).trim();
nwConfig.setPort(Integer.parseInt(port)); // localMemberPort
}
configureMembershipScheme(nwConfig);
MapConfig mapConfig = new MapConfig("foo");
mapConfig.setEvictionPolicy("LRU");
primaryHazelcastConfig.addMapConfig(mapConfig);
if (clusterManagementMode) {
for (Map.Entry<String, Map<String, GroupManagementAgent>> entry : groupManagementAgents.entrySet()) {
for (GroupManagementAgent agent : entry.getValue().values()) {
if (agent instanceof HazelcastGroupManagementAgent) {
((HazelcastGroupManagementAgent) agent).init(primaryHazelcastConfig,
configurationContext);
}
}
}
}
primaryHazelcastInstance = HazelcastInstanceManager.getInstance().init(primaryHazelcastConfig);
membershipScheme.setPrimaryHazelcastInstance(primaryHazelcastInstance);
clusteringMessageTopic = primaryHazelcastInstance.getTopic(HazelcastConstants.CLUSTERING_MESSAGE_TOPIC);
clusteringMessageTopic.addMessageListener(new HazelcastClusterMessageListener(configurationContext));
ITopic<ControlCommand> controlCommandTopic = primaryHazelcastInstance.getTopic(HazelcastConstants.CONTROL_COMMAND_TOPIC);
controlCommandTopic.addMessageListener(new HazelcastControlCommandListener(configurationContext));
final Member localMember = primaryHazelcastInstance.getCluster().getLocalMember();
membershipScheme.setLocalMember(localMember);
org.apache.axis2.clustering.Member carbonLocalMember =
MemberUtils.getLocalMember(primaryDomain, nwConfig.getPublicAddress(), nwConfig.getPort());
log.info("Local member: [" + localMember.getUuid() + "] - " + carbonLocalMember);
MemberUtils.getMembersMap(primaryHazelcastInstance, primaryDomain).put(localMember.getUuid(),
carbonLocalMember);
membershipScheme.joinGroup();
log.info("Cluster initialization completed");