mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
MNT-24708 - Set messagesCache and loadedBundlesCache as local (#3026)
* In a cluster env these caches were always invalidating the other nodes loaded bundles, forcing them to reload * Only resourceBundlesNamesCache should be invalidating to be able to force the cache reset if a bundle is added, removed or reloaded dynamically * On unregister of a resource bundle, the cache wasn't being explicitly updated, so it was not invalidating the cache on the other nodes.
This commit is contained in:
@@ -205,12 +205,10 @@ public class MessageServiceImpl implements MessageService
|
||||
if (! tenantResourceBundleBaseNames.contains(resBundlePath))
|
||||
{
|
||||
tenantResourceBundleBaseNames.add(resBundlePath);
|
||||
putResourceBundleBaseNames(tenantDomain, tenantResourceBundleBaseNames);
|
||||
reloadResourceBundles(tenantResourceBundleBaseNames);
|
||||
}
|
||||
|
||||
logger.info("Registered message bundle '" + resBundlePath + "'");
|
||||
|
||||
clearLoadedResourceBundles(tenantDomain); // force re-load of message cache
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -290,7 +288,8 @@ public class MessageServiceImpl implements MessageService
|
||||
Set<String> resourceBundleBaseNamesForAllLocales;
|
||||
|
||||
String tenantDomain = getTenantDomain();
|
||||
LockHelper.tryLock(readLock, tryLockTimeout, "getting loaded resource bundles, messages and base names in 'MessageServiceImpl.unregisterResourceBundle()'");
|
||||
LockHelper.tryLock(readLock, tryLockTimeout,
|
||||
"getting loaded resource bundles, messages and base names in 'MessageServiceImpl.unregisterResourceBundle()'");
|
||||
try
|
||||
{
|
||||
// all locales
|
||||
@@ -303,7 +302,8 @@ public class MessageServiceImpl implements MessageService
|
||||
readLock.unlock();
|
||||
}
|
||||
|
||||
LockHelper.tryLock(writeLock, tryLockTimeout, "removing resource bundle by path in 'MessageServiceImpl.unregisterResourceBundle()'");
|
||||
LockHelper.tryLock(writeLock, tryLockTimeout,
|
||||
"removing resource bundle by path in 'MessageServiceImpl.unregisterResourceBundle()'");
|
||||
try
|
||||
{
|
||||
// unload resource bundles for each locale (by tenant, if applicable)
|
||||
@@ -342,7 +342,8 @@ public class MessageServiceImpl implements MessageService
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to read message resource bundle from repository " + resBundlePath + " : " + ioe);
|
||||
throw new AlfrescoRuntimeException("Failed to read message resource bundle from repository "
|
||||
+ resBundlePath + " : " + ioe);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -372,10 +373,9 @@ public class MessageServiceImpl implements MessageService
|
||||
if (resourceBundleBaseNamesForAllLocales != null)
|
||||
{
|
||||
resourceBundleBaseNamesForAllLocales.remove(resBundlePath);
|
||||
reloadResourceBundles(resourceBundleBaseNamesForAllLocales);
|
||||
logger.info("Unregistered message bundle '" + resBundlePath + "'");
|
||||
}
|
||||
|
||||
clearLoadedResourceBundles(tenantDomain); // force re-load of message cache
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -383,6 +383,14 @@ public class MessageServiceImpl implements MessageService
|
||||
}
|
||||
}
|
||||
|
||||
private void reloadResourceBundles(Set<String> newResourceBundles)
|
||||
{
|
||||
logger.debug("Reloading message bundles ...");
|
||||
String tenantDomain = getTenantDomain();
|
||||
putResourceBundleBaseNames(tenantDomain, newResourceBundles);
|
||||
clearLoadedResourceBundles(tenantDomain); // force re-load of message cache
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the messages for a locale.
|
||||
* <p>
|
||||
@@ -491,7 +499,8 @@ public class MessageServiceImpl implements MessageService
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to read message resource bundle from repository " + resBundlePath + " : " + ioe);
|
||||
throw new AlfrescoRuntimeException(
|
||||
"Failed to read message resource bundle from repository " + resBundlePath + " : " + ioe);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@@ -394,7 +394,7 @@ cache.loadedResourceBundlesSharedCache.tx.statsEnabled=${caches.tx.statsEnabled}
|
||||
cache.loadedResourceBundlesSharedCache.maxItems=1000
|
||||
cache.loadedResourceBundlesSharedCache.timeToLiveSeconds=0
|
||||
cache.loadedResourceBundlesSharedCache.maxIdleSeconds=0
|
||||
cache.loadedResourceBundlesSharedCache.cluster.type=invalidating
|
||||
cache.loadedResourceBundlesSharedCache.cluster.type=local
|
||||
cache.loadedResourceBundlesSharedCache.backup-count=1
|
||||
cache.loadedResourceBundlesSharedCache.eviction-policy=LRU
|
||||
cache.loadedResourceBundlesSharedCache.merge-policy=com.hazelcast.spi.merge.PutIfAbsentMergePolicy
|
||||
@@ -405,7 +405,7 @@ cache.messagesSharedCache.tx.statsEnabled=${caches.tx.statsEnabled}
|
||||
cache.messagesSharedCache.maxItems=1000
|
||||
cache.messagesSharedCache.timeToLiveSeconds=0
|
||||
cache.messagesSharedCache.maxIdleSeconds=0
|
||||
cache.messagesSharedCache.cluster.type=invalidating
|
||||
cache.messagesSharedCache.cluster.type=local
|
||||
cache.messagesSharedCache.backup-count=1
|
||||
cache.messagesSharedCache.eviction-policy=LRU
|
||||
cache.messagesSharedCache.merge-policy=com.hazelcast.spi.merge.PutIfAbsentMergePolicy
|
||||
|
Reference in New Issue
Block a user