Permalink
Browse files

ISPN-1860 Crashed member detector to update id only when they leave

  • Loading branch information...
1 parent d63338b commit 168ff2518246f3bc1a7420e4e8e3b315af510b65 @galderz galderz committed with maniksurtani Feb 16, 2012
@@ -56,12 +56,13 @@ class CrashedMemberDetectorListener(cache: Cache[Address, ServerAddress], server
val newMembers = collectionAsScalaIterable(e.getNewMembers)
val oldMembers = collectionAsScalaIterable(e.getOldMembers)
val goneMembers = oldMembers.filterNot(newMembers contains _)
- // Consider doing removeAsync and then waiting for all removals...
- goneMembers.foreach { addr =>
- trace("Remove %s from address cache", addr)
- addressCache.remove(addr)
+ if (!goneMembers.isEmpty) {
+ // Consider doing removeAsync and then waiting for all removals...
+ goneMembers.foreach(addressCache.remove(_))
+ // Only update view id once we've removed all addresses to
+ // guarantee that the cache will be up to date
+ updateViewdId(e)
}
- updateViewdId(e)
} catch {
case t: Throwable => logErrorDetectingCrashedMember(t)
}
@@ -64,7 +64,10 @@ class HotRodServer extends AbstractProtocolServer("HotRod") with Log {
def getViewId: Int = viewId
- def setViewId(viewId: Int) = this.viewId = viewId
+ def setViewId(viewId: Int) {
+ trace("Set view id to %d", viewId)
+ this.viewId = viewId
+ }
override def getEncoder = new HotRodEncoder(getCacheManager, this)
@@ -180,7 +183,7 @@ class HotRodServer extends AbstractProtocolServer("HotRod") with Log {
// Only update view id once cache has been updated
if (!event.isPre) {
val localViewId = transport.getViewId
- viewId = localViewId
+ setViewId(localViewId)
if (isTraceEnabled) {
log.tracef("Address cache had %s for key %s. View id is now %d",
event.getType, event.getKey, localViewId)

0 comments on commit 168ff25

Please sign in to comment.