Skip to content

Commit

Permalink
SAK-32267 Enable JMX for jgroups. (sakaiproject#4008)
Browse files Browse the repository at this point in the history
Register jgroups with the platform JMX server. This allow easier
inspection of jgroups while Sakai is running.
  • Loading branch information
buckett authored and adrianfish committed Mar 3, 2017
1 parent c08ecfb commit 846fe87
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Serializable;
import java.lang.management.ManagementFactory;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
Expand All @@ -21,6 +22,7 @@
import org.jgroups.Message;
import org.jgroups.Receiver;
import org.jgroups.View;
import org.jgroups.jmx.JmxConfigurator;
import org.sakaiproject.component.api.ComponentManager;
import org.sakaiproject.component.api.ServerConfigurationService;
import org.sakaiproject.email.api.EmailService;
Expand Down Expand Up @@ -167,22 +169,24 @@ public void init() {
try {
String channelId = serverConfigurationService.getString("portalchat.cluster.channel");
if (channelId != null && !channelId.equals("")) {
// Pick up the config file from sakai home if it exists
File jgroupsConfig = new File(serverConfigurationService.getSakaiHomePath() + File.separator + "jgroups-config.xml");
if (jgroupsConfig.exists()) {
logger.debug("Using jgroups config file: {}", jgroupsConfig.getAbsolutePath());
clusterChannel = new JChannel(jgroupsConfig);
} else {
// Pick up the config file from sakai home if it exists
File jgroupsConfig = new File(serverConfigurationService.getSakaiHomePath() + File.separator + "jgroups-config.xml");
JChannel channel;
if (jgroupsConfig.exists()) {
logger.debug("Using jgroups config file: {}", jgroupsConfig.getAbsolutePath());
clusterChannel = channel = new JChannel(jgroupsConfig);
} else {
logger.debug("No jgroups config file. Using jgroup defaults.");
clusterChannel = new JChannel();
}
logger.debug("JGROUPS PROTOCOL: {}", clusterChannel.getProtocolStack().printProtocolSpecAsXML());
clusterChannel = channel = new JChannel();
}

logger.debug("JGROUPS PROTOCOL: {}", clusterChannel.getProtocolStack().printProtocolSpecAsXML());

clusterChannel.setReceiver(this);
clusterChannel.connect(channelId);
// We don't want a copy of our JGroups messages sent back to us
clusterChannel.setDiscardOwnMessages(true);
JmxConfigurator.registerChannel(channel, ManagementFactory.getPlatformMBeanServer(), "DefaultDomain:name=JGroups");
clustered = true;

logger.info("Portal chat is connected on JGroups channel '" + channelId + "'");
Expand Down

0 comments on commit 846fe87

Please sign in to comment.