Unverified Commit a7a8f697 authored by GregDThomas's avatar GregDThomas Committed by GitHub

Merge pull request #1014 from GregDThomas/HZ-8

HZ-8: Preserve Hazelcast network settings between plugin upgrades
parents de85ac82 a4ef7b88
...@@ -18,10 +18,7 @@ ...@@ -18,10 +18,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.hazelcast.com/schema/config xsi:schemaLocation="http://www.hazelcast.com/schema/config
http://www.hazelcast.com/schema/config/hazelcast-config-3.9.xsd"> http://www.hazelcast.com/schema/config/hazelcast-config-3.9.xsd">
<group> <import resource="${openfireHome}/conf/hazelcast-local-config.xml"/>
<name>openfire</name>
<password>openfire</password>
</group>
<properties> <properties>
<property name="hazelcast.logging.type">slf4j</property> <property name="hazelcast.logging.type">slf4j</property>
<property name="hazelcast.operation.call.timeout.millis">30000</property> <property name="hazelcast.operation.call.timeout.millis">30000</property>
...@@ -29,42 +26,6 @@ ...@@ -29,42 +26,6 @@
<property name="hazelcast.rest.enabled">false</property> <property name="hazelcast.rest.enabled">false</property>
</properties> </properties>
<management-center enabled="false"/> <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"/> <partition-group enabled="false"/>
<executor-service name="default"> <executor-service name="default">
<pool-size>16</pool-size> <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>
...@@ -204,17 +204,20 @@ the Hazelcast cluster if JMX has been enabled via the Openfire admin console. ...@@ -204,17 +204,20 @@ the Hazelcast cluster if JMX has been enabled via the Openfire admin console.
Refer to the <a href="http://docs.hazelcast.org/docs/3.9.2/manual/html-single/index.html#monitoring-with-jmx"> Refer to the <a href="http://docs.hazelcast.org/docs/3.9.2/manual/html-single/index.html#monitoring-with-jmx">
Hazelcast JMX docs</a> for additional information.</li> Hazelcast JMX docs</a> for additional information.</li>
</ol> </ol>
<em>Note:</em> The default <code>hazelcast-cache-config.xml</code> file included with the plugin will include a file
<code>conf/hazelcast-local-config.xml</code> that will be preserved between plugin updates. It is recommended that
local changes are kept in this file.
<p>The Hazelcast plugin uses the <a href="http://docs.hazelcast.org/docs/3.9.2/manual/html-single/index.html#configuring-declaratively"> <p>The Hazelcast plugin uses the <a href="http://docs.hazelcast.org/docs/3.9.2/manual/html-single/index.html#configuring-declaratively">
XML configuration builder</a> to initialize the cluster from the XML file described above. XML configuration builder</a> to initialize the cluster from the XML file <code>conf/hazelcast-local-config.xml</code>.
By default the cluster members will attempt to discover each other via multicast at the By default the cluster members will attempt to discover each other via UDP multicast at the
following location: following location:
</p> </p>
<ul> <ul>
<li>IP Address: 224.2.2.3</li> <li>IP Address: 224.2.2.3</li>
<li>Port: 54327</li> <li>Port: 54327</li>
</ul> </ul>
Note that these values can be overridden in the plugin's /classes/hazelcast-cache-config.xml These values can be overridden in the <code>conf/hazelcast-local-config.xml</code>
file (via the multicast-group and multicast-port elements). Many other initialization and file via the multicast-group and multicast-port elements. Many other initialization and
discovery options exist, as documented in the Hazelcast configuration docs noted above. For discovery options exist, as documented in the Hazelcast configuration docs noted above. For
example, to set up a two-node cluster using well-known DNS name/port values, try the example, to set up a two-node cluster using well-known DNS name/port values, try the
following alternative: following alternative:
...@@ -223,10 +226,9 @@ following alternative: ...@@ -223,10 +226,9 @@ following alternative:
&lt;join&gt; &lt;join&gt;
&lt;multicast enabled="false"/&gt; &lt;multicast enabled="false"/&gt;
&lt;tcp-ip enabled="true"&gt; &lt;tcp-ip enabled="true"&gt;
&lt;member&gt;of-node-a.example.com:5701&lt;/member&gt; &lt;member&gt;of-node-a.example.com&lt;/member&gt;
&lt;member&gt;of-node-b.example.com:5701&lt;/member&gt; &lt;member&gt;of-node-b.example.com&lt;/member&gt;
&lt;/tcp-ip&gt; &lt;/tcp-ip&gt;
&lt;aws enabled="false"/&gt;
&lt;/join&gt; &lt;/join&gt;
... ...
</pre> </pre>
......
...@@ -16,9 +16,6 @@ ...@@ -16,9 +16,6 @@
package org.jivesoftware.openfire.plugin; package org.jivesoftware.openfire.plugin;
import java.io.File;
import java.io.FileFilter;
import org.jivesoftware.openfire.XMPPServer; import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.cluster.ClusterManager; import org.jivesoftware.openfire.cluster.ClusterManager;
import org.jivesoftware.openfire.container.Plugin; import org.jivesoftware.openfire.container.Plugin;
...@@ -28,6 +25,13 @@ import org.jivesoftware.util.JiveGlobals; ...@@ -28,6 +25,13 @@ import org.jivesoftware.util.JiveGlobals;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; 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 * Hazelcast clustering plugin. This implementation is based upon
* (and borrows heavily from) the original Openfire clustering plugin. * (and borrows heavily from) the original Openfire clustering plugin.
...@@ -38,38 +42,51 @@ import org.slf4j.LoggerFactory; ...@@ -38,38 +42,51 @@ import org.slf4j.LoggerFactory;
*/ */
public class HazelcastPlugin implements Plugin { 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) { 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() { manager.addPluginManagerListener(new PluginManagerListener() {
@Override @Override
public void pluginsMonitored() { public void pluginsMonitored() {
manager.removePluginManagerListener(this); manager.removePluginManagerListener(this);
initializeClustering(); initializeClustering(pluginDirectory);
} }
}); });
} }
private void initializeClustering() { private void initializeClustering(final File hazelcastPluginDirectory) {
logger.info("All plugins have initialized; initializing clustering"); LOGGER.info("All plugins have initialized; initializing clustering");
// Check if another cluster is installed and stop loading this plugin if found // 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() { File[] jars = pluginDir.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) { public boolean accept(File pathname) {
String fileName = pathname.getName().toLowerCase(); String fileName = pathname.getName().toLowerCase();
return (fileName.equalsIgnoreCase("enterprise.jar") || return (fileName.equalsIgnoreCase("enterprise.jar") ||
fileName.equalsIgnoreCase("coherence.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 // Do not load this plugin if a conflicting implementation exists
logger.warn("Conflicting clustering plugins found; remove Coherence and/or Enterprise jar files"); LOGGER.warn("Conflicting clustering plugins found; remove Coherence and/or Enterprise jar files");
throw new IllegalStateException("Clustering plugin configuration conflict (Coherence)"); 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() { public void destroyPlugin() {
// Shutdown is initiated by XMPPServer before unloading plugins // Shutdown is initiated by XMPPServer before unloading plugins
if (!XMPPServer.getInstance().isShuttingDown()) { 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