Commit 0006eeb5 authored by Tom Evans's avatar Tom Evans Committed by tevans

OF-588: Add synchronization for cache swap during cluster startup/shutdown

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13382 b35dd754-fafc-0310-a699-88a17e54d16e
parent 70fe97f4
......@@ -381,7 +381,7 @@ public class CacheFactory {
*
* @param name the name of the cache to destroy.
*/
public static void destroyCache(String name) {
public static synchronized void destroyCache(String name) {
Cache cache = caches.remove(name);
if (cache != null) {
if (localOnly.contains(name)) {
......@@ -411,9 +411,13 @@ public class CacheFactory {
if (localOnly.contains(cache.getName())) {
return localCacheFactoryStrategy.getLock(key, cache);
} else {
// synchronized here because the backing cache
// will be swapped cluster startup/shutdown (OF-588)
synchronized(cache) {
return cacheFactoryStrategy.getLock(key, cache);
}
}
}
@SuppressWarnings("unchecked")
private static <T extends Cache> T wrapCache(T cache, String name) {
......@@ -686,11 +690,13 @@ public class CacheFactory {
for (Cache cache : getAllCaches()) {
// skip local-only caches
if (localOnly.contains(cache.getName())) continue;
synchronized (cache) {
cache.clear();
CacheWrapper cacheWrapper = ((CacheWrapper) cache);
Cache clusteredCache = cacheFactoryStrategy.createCache(cacheWrapper.getName());
cacheWrapper.setWrappedCache(clusteredCache);
}
}
clusteringStarting = false;
clusteringStarted = true;
}
......@@ -708,11 +714,13 @@ public class CacheFactory {
for (Cache cache : getAllCaches()) {
// skip local-only caches
if (localOnly.contains(cache.getName())) continue;
synchronized (cache) {
cache.clear();
CacheWrapper cacheWrapper = ((CacheWrapper) cache);
Cache standaloneCache = cacheFactoryStrategy.createCache(cacheWrapper.getName());
cacheWrapper.setWrappedCache(standaloneCache);
}
}
} catch (Exception e) {
log.error("Error reverting caches to local caches", e);
}
......
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