Author: kfujino Date: Tue Jan 20 01:47:08 2015 New Revision: 1653178 URL: http://svn.apache.org/r1653178 Log: Clarify the handling of Copy message and Copy nodes.
Modified: tomcat/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java Modified: tomcat/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java?rev=1653178&r1=1653177&r2=1653178&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java (original) +++ tomcat/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java Tue Jan 20 01:47:08 2015 @@ -632,6 +632,7 @@ public abstract class AbstractReplicated } entry.setProxy(true); entry.setBackup(false); + entry.setCopy(false); entry.setBackupNodes(mapmsg.getBackupNodes()); entry.setPrimary(mapmsg.getPrimary()); } @@ -646,6 +647,7 @@ public abstract class AbstractReplicated entry = new MapEntry<>((K) mapmsg.getKey(), (V) mapmsg.getValue()); entry.setBackup(mapmsg.getMsgType() == MapMessage.MSG_BACKUP); entry.setProxy(false); + entry.setCopy(mapmsg.getMsgType() == MapMessage.MSG_COPY); entry.setBackupNodes(mapmsg.getBackupNodes()); entry.setPrimary(mapmsg.getPrimary()); if (mapmsg.getValue() instanceof ReplicatedMapEntry ) { @@ -654,6 +656,7 @@ public abstract class AbstractReplicated } else { entry.setBackup(mapmsg.getMsgType() == MapMessage.MSG_BACKUP); entry.setProxy(false); + entry.setCopy(mapmsg.getMsgType() == MapMessage.MSG_COPY); entry.setBackupNodes(mapmsg.getBackupNodes()); entry.setPrimary(mapmsg.getPrimary()); if (entry.getValue() instanceof ReplicatedMapEntry) { @@ -810,6 +813,7 @@ public abstract class AbstractReplicated entry.setPrimary(channel.getLocalMember(false)); entry.setBackup(false); entry.setProxy(false); + entry.setCopy(false); Member[] backup = publishEntryInfo(entry.getKey(), entry.getValue()); entry.setBackupNodes(backup); if ( mapOwner!=null ) mapOwner.objectMadePrimary(entry.getKey(),entry.getValue()); @@ -896,7 +900,7 @@ public abstract class AbstractReplicated try { Member[] backup = null; MapMessage msg = null; - if ( !entry.isBackup() ) { + if ( entry.isProxy() ) { //make sure we don't retrieve from ourselves msg = new MapMessage(getMapContextName(), MapMessage.MSG_RETRIEVE_BACKUP, false, (Serializable) key, null, null, null,null); @@ -929,11 +933,15 @@ public abstract class AbstractReplicated ReplicatedMapEntry val = (ReplicatedMapEntry)entry.getValue(); val.setOwner(getMapOwner()); } + } else if ( entry.isCopy() ) { + // TODO no need to send the entry data. + backup = publishEntryInfo(key, entry.getValue()); } entry.setPrimary(channel.getLocalMember(false)); entry.setBackupNodes(backup); entry.setBackup(false); entry.setProxy(false); + entry.setCopy(false); if ( getMapOwner()!=null ) getMapOwner().objectMadePrimary(key, entry.getValue()); } catch (Exception x) { @@ -990,6 +998,7 @@ public abstract class AbstractReplicated MapEntry<K,V> entry = new MapEntry<>(key, value); entry.setBackup(false); entry.setProxy(false); + entry.setCopy(false); entry.setPrimary(channel.getLocalMember(false)); V old = null; @@ -1148,6 +1157,7 @@ public abstract class AbstractReplicated public static class MapEntry<K,V> implements Map.Entry<K,V> { private boolean backup; private boolean proxy; + private boolean copy; private Member[] backupNodes; private Member primary; private K key; @@ -1184,7 +1194,7 @@ public abstract class AbstractReplicated } public boolean isPrimary() { - return (!proxy && !backup); + return (!proxy && !backup && !copy); } public boolean isActive() { @@ -1195,6 +1205,14 @@ public abstract class AbstractReplicated this.proxy = proxy; } + public boolean isCopy() { + return copy; + } + + public void setCopy(boolean copy) { + this.copy = copy; + } + public boolean isDiffable() { return (value instanceof ReplicatedMapEntry) && ((ReplicatedMapEntry)value).isDiffable(); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org