Commit eac8a43e authored by Tom Evans's avatar Tom Evans Committed by tevans

OF-205: Prep core and existing clustering plugin for new hazelcast plugin

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/branches/pubsub_clustering@13290 b35dd754-fafc-0310-a699-88a17e54d16e
parent 4d0c825c
......@@ -93,6 +93,11 @@ public class NodeID implements Externalizable {
public int hashCode() {
return Arrays.hashCode(nodeID);
}
@Override
public String toString() {
return new String(nodeID);
}
public byte[] toByteArray() {
return nodeID;
......
......@@ -88,7 +88,7 @@ public class CacheFactory {
localCacheFactoryClass = JiveGlobals.getProperty(LOCAL_CACHE_PROPERTY_NAME,
"org.jivesoftware.util.cache.DefaultLocalCacheStrategy");
clusteredCacheFactoryClass = JiveGlobals.getProperty(CLUSTERED_CACHE_PROPERTY_NAME,
"com.jivesoftware.util.cache.CoherenceClusteredCacheFactory");
"com.jivesoftware.util.cache.ClusteredCacheFactory");
cacheNames.put("Favicon Hits", "faviconHits");
cacheNames.put("Favicon Misses", "faviconMisses");
......@@ -219,7 +219,7 @@ public class CacheFactory {
}
/**
* Sets a local property which overrides the maximum cache size as configured in coherence-cache-config.xml for the
* Sets a local property which overrides the maximum cache size for the
* supplied cache name.
* @param cacheName the name of the cache to store a value for.
* @param size the maximum cache size.
......@@ -245,7 +245,7 @@ public class CacheFactory {
}
/**
* Sets a local property which overrides the maximum cache entry lifetime as configured in coherence-cache-config.xml
* Sets a local property which overrides the maximum cache entry lifetime
* for the supplied cache name.
* @param cacheName the name of the cache to store a value for.
* @param lifetime the maximum cache entry lifetime.
......@@ -485,7 +485,7 @@ public class CacheFactory {
getClusteredCacheStrategyClassLoader()).newInstance();
return cacheFactory.getMaxClusterNodes();
} catch (ClassNotFoundException e) {
// Do nothing
Log.warn("Clustering implementation class " + clusteredCacheFactoryClass + " not found");
} catch (Exception e) {
Log.error("Error instantiating clustered cache factory", e);
}
......@@ -541,6 +541,10 @@ public class CacheFactory {
return cacheFactoryStrategy.doSynchronousClusterTask(task, nodeID);
}
public static String getPluginName() {
return cacheFactoryStrategy.getPluginName();
}
public static synchronized void initialize() throws InitializationException {
try {
cacheFactoryStrategy = (CacheFactoryStrategy) Class
......@@ -559,9 +563,12 @@ public class CacheFactory {
private static ClassLoader getClusteredCacheStrategyClassLoader() {
PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
Plugin plugin = pluginManager.getPlugin("clustering");
Plugin plugin = pluginManager.getPlugin("hazelcast");
if (plugin == null) {
plugin = pluginManager.getPlugin("enterprise");
plugin = pluginManager.getPlugin("clustering");
if (plugin == null) {
plugin = pluginManager.getPlugin("enterprise");
}
}
PluginClassLoader pluginLoader = pluginManager.getPluginClassloader(plugin);
if (pluginLoader != null) {
......
......@@ -181,4 +181,11 @@ public interface CacheFactoryStrategy {
* @return an existing lock on the specified key or creates a new one if none was found.
*/
Lock getLock(Object key, Cache cache);
/**
* Get the plugin name corresponding to this clustering implementation
*
* @return the plugin name for this clustering implementation
*/
String getPluginName();
}
......@@ -105,6 +105,11 @@ public class DefaultLocalCacheStrategy implements CacheFactoryStrategy {
public void updateCacheStats(Map<String, Cache> caches) {
}
@Override
public String getPluginName() {
return "local";
}
public Lock getLock(Object key, Cache cache) {
Object lockKey = key;
if (key instanceof String) {
......
......@@ -69,13 +69,13 @@ public class ClusteringPlugin implements Plugin, PropertyEventListener {
File[] jars = pluginDir.listFiles(new FileFilter() {
public boolean accept(File pathname) {
String fileName = pathname.getName().toLowerCase();
return (fileName.equalsIgnoreCase("enterprise.jar"));
return (fileName.equalsIgnoreCase("enterprise.jar") || fileName.equalsIgnoreCase("hazelcast.jar"));
}
});
if (jars.length > 0) {
// Do not load this plugin since Enterprise is still installed
System.out.println("Enterprise plugin found. Stopping Clustering Plugin");
throw new IllegalStateException("This plugin cannot run next to the Enterprise plugin");
System.out.println("Conflicting plugin found. Stopping Clustering Plugin");
throw new IllegalStateException("This plugin cannot run with the Enterprise or Hazelcast plugin");
}
// Make sure that the enteprise folder exists under the home directory
......
......@@ -41,7 +41,7 @@ import java.util.concurrent.locks.Lock;
*
* @author Gaston Dombiak
*/
public class CoherenceClusteredCacheFactory implements CacheFactoryStrategy {
public class ClusteredCacheFactory implements CacheFactoryStrategy {
/**
* Storage for cache statistics
......@@ -332,6 +332,11 @@ public class CoherenceClusteredCacheFactory implements CacheFactoryStrategy {
}
}
@Override
public String getPluginName() {
return "clustering";
}
private static Invocable buildInvocable(final ClusterTask task) {
return new AbstractInvocable() {
public void run() {
......
......@@ -283,12 +283,12 @@
%>
<tr class="<%= (isLocalMember ? "local" : "") %>" valign="middle">
<td align="center" width="1%">
<a href="plugins/clustering/system-clustering-node.jsp?UID=<%= nodeID %>"
<a href="plugins/<%= CacheFactory.getPluginName() %>/system-clustering-node.jsp?UID=<%= nodeID %>"
title="Click for more details"
><img src="images/server-network-24x24.gif" width="24" height="24" border="0" alt=""></a>
</td>
<td class="jive-description" nowrap width="1%" valign="middle">
<a href="plugins/clustering/system-clustering-node.jsp?UID=<%= nodeID %>">
<a href="plugins/<%= CacheFactory.getPluginName() %>/system-clustering-node.jsp?UID=<%= nodeID %>">
<% if (isLocalMember) { %>
<b><%= nodeInfo.getHostName() %></b>
<% } else { %>
......
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