I just wrote a piece of code that flushes the LRU cache by calling clearAll. It doesn't do anything.
It that related to your posting (the map.clear() bug)?
Are there any elegant workarounds?
(iterating through the entire cache and clearing each element individually is considered elegant).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
When I do the "clearAll" call, it works only on one VM. Other VMs do not clear the cache.
However, when clearing a single element from the cache, other VMs get the change.
So this is clearly not a networking issue.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've been experimenting/debugging this issue, and have noticed that when one JVM sends a CacheNotification with a key "(ALL)" (MultiCacheManager.CLEAR_ALL) the second JVM will receive this CacheNotification and execute the method receiveNotification on MultiCacheManager.
And there the code is + - like this:
(...)
if (notification.getKey() == CLEAR_ALL) {
cache.doClearAll();
} else {
cache.doClear(notification.getKey());
}
(...)
So being CLEAR_ALL a String with value "(ALL)", the first condition will only be true if both are the same object on this JVM, which is not the case I think.
So should the `if` be rather something like:
if (CLEAR_ALL.equals(notification.getKey())) ?
Can John Watkinson or one of the active developers clarify this please?
Thanks
Fernando Martins
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Don't know if this project is still alive but here goes:
The Clearall method of the LRUCache is
<code>
public void clearAll()
{
if(log.isDebugEnabled())
log.debug("Purged " + cacheId + " cache.");
cache = Collections.synchronizedMap(new LRUMap(size));
}
</code>
This is not taking care of the map memberfield and also any listeners which were set on it. We need to change this to:
<code>
public void clearAll()
{
if(log.isDebugEnabled())
log.debug("Purged " + cacheId + " cache.");
map.clear();
}
</code>
--Bipin
Ooops and I forgot to ask...
shouldn't clearAll() be synchronized..
--Bipin
I just wrote a piece of code that flushes the LRU cache by calling clearAll. It doesn't do anything.
It that related to your posting (the map.clear() bug)?
Are there any elegant workarounds?
(iterating through the entire cache and clearing each element individually is considered elegant).
When I do the "clearAll" call, it works only on one VM. Other VMs do not clear the cache.
However, when clearing a single element from the cache, other VMs get the change.
So this is clearly not a networking issue.
I've been experimenting/debugging this issue, and have noticed that when one JVM sends a CacheNotification with a key "(ALL)" (MultiCacheManager.CLEAR_ALL) the second JVM will receive this CacheNotification and execute the method receiveNotification on MultiCacheManager.
And there the code is + - like this:
(...)
if (notification.getKey() == CLEAR_ALL) {
cache.doClearAll();
} else {
cache.doClear(notification.getKey());
}
(...)
So being CLEAR_ALL a String with value "(ALL)", the first condition will only be true if both are the same object on this JVM, which is not the case I think.
So should the `if` be rather something like:
if (CLEAR_ALL.equals(notification.getKey())) ?
Can John Watkinson or one of the active developers clarify this please?
Thanks
Fernando Martins
This is a swarmcache bug I also ran into.
You should patch it to use .equals()
I think patch 1048007 (see patches in swarmcache project page) fixes this.
Too bad swarmcache seems not to be maintained any more, it needs an RC3 release bad.
--Coder