Commit 309ba9a6 authored by Tom Evans's avatar Tom Evans Committed by tevans

OF-205: Improve timing for cluster state transitions to eliminate errors during startup

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13304 b35dd754-fafc-0310-a699-88a17e54d16e
parent 27dc2164
...@@ -581,18 +581,16 @@ public class CacheFactory { ...@@ -581,18 +581,16 @@ public class CacheFactory {
} }
public static void startClustering() { public static void startClustering() {
clusteringStarted = false;
clusteringStarting = true;
try { try {
cacheFactoryStrategy = (CacheFactoryStrategy) Class.forName(clusteredCacheFactoryClass, true, cacheFactoryStrategy = (CacheFactoryStrategy) Class.forName(clusteredCacheFactoryClass, true,
getClusteredCacheStrategyClassLoader()) getClusteredCacheStrategyClassLoader())
.newInstance(); .newInstance();
clusteringStarted = cacheFactoryStrategy.startCluster(); clusteringStarting = cacheFactoryStrategy.startCluster();
} }
catch (Exception e) { catch (Exception e) {
Log.error("Unable to start clustering - continuing in local mode", e); Log.error("Unable to start clustering - continuing in local mode", e);
} }
if (!clusteringStarted) { if (!clusteringStarting) {
// Revert to local cache factory if cluster fails to start // Revert to local cache factory if cluster fails to start
try { try {
cacheFactoryStrategy = (CacheFactoryStrategy) Class.forName(localCacheFactoryClass).newInstance(); cacheFactoryStrategy = (CacheFactoryStrategy) Class.forName(localCacheFactoryClass).newInstance();
...@@ -656,7 +654,6 @@ public class CacheFactory { ...@@ -656,7 +654,6 @@ public class CacheFactory {
statsThread.start(); statsThread.start();
} }
} }
clusteringStarting = false;
} }
public static void stopClustering() { public static void stopClustering() {
...@@ -667,7 +664,6 @@ public class CacheFactory { ...@@ -667,7 +664,6 @@ public class CacheFactory {
cacheFactoryStrategy = (CacheFactoryStrategy) Class.forName(localCacheFactoryClass) cacheFactoryStrategy = (CacheFactoryStrategy) Class.forName(localCacheFactoryClass)
.newInstance(); .newInstance();
clusteringStarted = false;
} }
catch (Exception e) { catch (Exception e) {
Log.error("Unable to stop clustering - continuing in clustered mode", e); Log.error("Unable to stop clustering - continuing in clustered mode", e);
...@@ -684,12 +680,15 @@ public class CacheFactory { ...@@ -684,12 +680,15 @@ public class CacheFactory {
Cache clusteredCache = cacheFactoryStrategy.createCache(cacheWrapper.getName()); Cache clusteredCache = cacheFactoryStrategy.createCache(cacheWrapper.getName());
cacheWrapper.setWrappedCache(clusteredCache); cacheWrapper.setWrappedCache(clusteredCache);
} }
clusteringStarting = false;
clusteringStarted = true;
} }
/** /**
* Notification message indicating that this JVM has left the cluster. * Notification message indicating that this JVM has left the cluster.
*/ */
public static void leftCluster() { public static void leftCluster() {
clusteringStarted = false;
// Loop through clustered caches and change them to local caches (migrate content) // Loop through clustered caches and change them to local caches (migrate content)
try { try {
cacheFactoryStrategy = (CacheFactoryStrategy) Class.forName(localCacheFactoryClass).newInstance(); cacheFactoryStrategy = (CacheFactoryStrategy) Class.forName(localCacheFactoryClass).newInstance();
......
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