From: fhanik Date: Thu, 9 Aug 2007 19:52:08 +0000 (+0000) Subject: make the backup node become the primary so that we can still expire sessions X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=d5581bd8e093f324b1b5969f64fca73db6603a53;p=tomcat7.0 make the backup node become the primary so that we can still expire sessions http://issues.apache.org/bugzilla/show_bug.cgi?id=43053 git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@564358 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java b/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java index fb655a2bc..9b97d8ea4 100644 --- a/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java +++ b/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java @@ -719,13 +719,26 @@ public abstract class AbstractReplicatedMap extends ConcurrentHashMap implements } else if (member.equals(entry.getPrimary())) { entry.setPrimary(null); } //end if - if ( entry.getPrimary() == null && + + if ( entry.isProxy() && + entry.getPrimary() == null && entry.getBackupNodes()!=null && entry.getBackupNodes().length == 1 && entry.getBackupNodes()[0].equals(member) ) { //remove proxies that have no backup nor primaries i.remove(); + } else if ( entry.isBackup() && + entry.getBackupNodes()!=null && + entry.getBackupNodes().length == 1 && + entry.getBackupNodes()[0].equals(channel.getLocalMember(false)) ) { + try { + Member[] backup = publishEntryInfo(entry.getKey(), entry.getValue()); + entry.setBackupNodes(backup); + } catch (ChannelException x) { + log.error("Unable to relocate[" + entry.getKey() + "] to a new backup node", x); + } } + } //while } @@ -979,7 +992,6 @@ public abstract class AbstractReplicatedMap extends ConcurrentHashMap implements Object key = e.getKey(); MapEntry entry = (MapEntry)super.get(key); if ( entry != null && entry.isPrimary() ) set.add(entry.getValue()); - else if ( entry != null && entry.getPrimary() == null && entry.isBackup() ) set.add(entry.getValue()); } return Collections.unmodifiableSet(set); } @@ -994,7 +1006,6 @@ public abstract class AbstractReplicatedMap extends ConcurrentHashMap implements Object key = e.getKey(); MapEntry entry = (MapEntry)super.get(key); if ( entry!=null && entry.isPrimary() ) set.add(key); - else if ( entry != null && entry.getPrimary() == null && entry.isBackup() ) set.add(key); } return Collections.unmodifiableSet(set); @@ -1011,7 +1022,6 @@ public abstract class AbstractReplicatedMap extends ConcurrentHashMap implements if ( e != null ) { MapEntry entry = (MapEntry) super.get(e.getKey()); if (entry!=null && entry.isPrimary() && entry.getValue() != null) counter++; - else if ( entry != null && entry.getPrimary() == null && entry.isBackup() ) counter++; } } return counter;