Commit 31dfe253 authored by Greg Thomas's avatar Greg Thomas

HZ-8: Preserve Hazelcast settings between plugin upgrades

parent de85ac82
......@@ -18,10 +18,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.hazelcast.com/schema/config
http://www.hazelcast.com/schema/config/hazelcast-config-3.9.xsd">
<group>
<name>openfire</name>
<password>openfire</password>
</group>
<import resource="${openfireHome}/conf/hazelcast-local-config.xml"/>
<properties>
<property name="hazelcast.logging.type">slf4j</property>
<property name="hazelcast.operation.call.timeout.millis">30000</property>
......@@ -29,42 +26,6 @@
<property name="hazelcast.rest.enabled">false</property>
</properties>
<management-center enabled="false"/>
<network>
<port auto-increment="true" port-count="100">5701</port>
<outbound-ports>
<ports>0</ports>
</outbound-ports>
<join>
<multicast enabled="true">
<multicast-group>224.2.2.3</multicast-group>
<multicast-port>54327</multicast-port>
</multicast>
<tcp-ip enabled="false"/>
<aws enabled="false"/>
</join>
<interfaces enabled="false">
<interface>10.10.1.*</interface>
</interfaces>
<ssl enabled="false"/>
<socket-interceptor enabled="false"/>
<symmetric-encryption enabled="false">
<!--
encryption algorithm such as
DES/ECB/PKCS5Padding,
PBEWithMD5AndDES,
AES/CBC/PKCS5Padding,
Blowfish,
DESede
-->
<algorithm>PBEWithMD5AndDES</algorithm>
<!-- salt value to use when generating the secret key -->
<salt>thesalt</salt>
<!-- pass phrase to use when generating the secret key -->
<password>thepass</password>
<!-- iteration count to use when generating the secret key -->
<iteration-count>19</iteration-count>
</symmetric-encryption>
</network>
<partition-group enabled="false"/>
<executor-service name="default">
<pool-size>16</pool-size>
......
<?xml version="1.0" encoding="UTF-8"?>
<hazelcast xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.hazelcast.com/schema/config
http://www.hazelcast.com/schema/config/hazelcast-config-3.9.xsd">
<group>
<name>openfire</name>
<password>openfire</password>
</group>
<network>
<port auto-increment="true" port-count="100">5701</port>
<outbound-ports>
<ports>0</ports>
</outbound-ports>
<!-- The following enables multicast discovery of cluster members
See http://docs.hazelcast.org/docs/3.9.2/manual/html-single/index.html#discovering-members-by-multicast
-->
<join>
<multicast enabled="true">
<multicast-group>224.2.2.3</multicast-group>
<multicast-port>54327</multicast-port>
</multicast>
<tcp-ip enabled="false"/>
</join>
<!-- The following enables TCP/IP based discovery of cluster members
See http://docs.hazelcast.org/docs/3.9.2/manual/html-single/index.html#discovering-members-by-tcp
-->
<!--
<join>
<multicast enabled="false"/>
<tcp-ip enabled="true">
<member>10.10.1.1:5701</member>
<member>10.10.1.2:5701</member>
</tcp-ip>
</join>
-->
<interfaces enabled="false">
<interface>10.10.1.*</interface>
</interfaces>
<ssl enabled="false"/>
<socket-interceptor enabled="false"/>
<symmetric-encryption enabled="false">
<!--
encryption algorithm such as
DES/ECB/PKCS5Padding,
PBEWithMD5AndDES,
AES/CBC/PKCS5Padding,
Blowfish,
DESede
-->
<algorithm>PBEWithMD5AndDES</algorithm>
<!-- salt value to use when generating the secret key -->
<salt>thesalt</salt>
<!-- pass phrase to use when generating the secret key -->
<password>thepass</password>
<!-- iteration count to use when generating the secret key -->
<iteration-count>19</iteration-count>
</symmetric-encryption>
</network>
</hazelcast>
......@@ -16,9 +16,6 @@
package org.jivesoftware.openfire.plugin;
import java.io.File;
import java.io.FileFilter;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.cluster.ClusterManager;
import org.jivesoftware.openfire.container.Plugin;
......@@ -28,6 +25,13 @@ import org.jivesoftware.util.JiveGlobals;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
/**
* Hazelcast clustering plugin. This implementation is based upon
* (and borrows heavily from) the original Openfire clustering plugin.
......@@ -38,38 +42,51 @@ import org.slf4j.LoggerFactory;
*/
public class HazelcastPlugin implements Plugin {
private static Logger logger = LoggerFactory.getLogger(HazelcastPlugin.class);
private static final Logger LOGGER = LoggerFactory.getLogger(HazelcastPlugin.class);
@Override
public void initializePlugin(final PluginManager manager, final File pluginDirectory) {
logger.info("Waiting for other plugins to initialize before initializing clustering");
LOGGER.info("Waiting for other plugins to initialize before initializing clustering");
manager.addPluginManagerListener(new PluginManagerListener() {
@Override
public void pluginsMonitored() {
manager.removePluginManagerListener(this);
initializeClustering();
initializeClustering(pluginDirectory);
}
});
}
private void initializeClustering() {
logger.info("All plugins have initialized; initializing clustering");
private void initializeClustering(final File hazelcastPluginDirectory) {
LOGGER.info("All plugins have initialized; initializing clustering");
// Check if another cluster is installed and stop loading this plugin if found
File pluginDir = new File(JiveGlobals.getHomeDirectory(), "plugins");
final String openfireHome = JiveGlobals.getHomeDirectory();
File pluginDir = new File(openfireHome, "plugins");
File[] jars = pluginDir.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
String fileName = pathname.getName().toLowerCase();
return (fileName.equalsIgnoreCase("enterprise.jar") ||
fileName.equalsIgnoreCase("coherence.jar"));
}
});
if (jars.length > 0) {
if (jars != null && jars.length > 0) {
// Do not load this plugin if a conflicting implementation exists
logger.warn("Conflicting clustering plugins found; remove Coherence and/or Enterprise jar files");
throw new IllegalStateException("Clustering plugin configuration conflict (Coherence)");
LOGGER.warn("Conflicting clustering plugins found; remove Coherence and/or Enterprise jar files");
return;
}
try {
final Path pathToLocalHazelcastConfig = Paths.get(openfireHome, "conf/hazelcast-local-config.xml");
if (!Files.exists(pathToLocalHazelcastConfig)) {
Files.copy(Paths.get(hazelcastPluginDirectory.getAbsolutePath(), "classes/hazelcast-local-config.xml.template"), pathToLocalHazelcastConfig);
}
ClusterManager.startup();
} catch (final IOException e) {
LOGGER.warn("Unable to create local Hazelcast configuration file from template; clustering will not start", e);
}
ClusterManager.startup();
}
@Override
public void destroyPlugin() {
// Shutdown is initiated by XMPPServer before unloading plugins
if (!XMPPServer.getInstance().isShuttingDown()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment