Author: kfujino Date: Wed Jun 17 08:30:46 2015 New Revision: 1685938 URL: http://svn.apache.org/r1685938 Log: When failed to replication, rather than all member is handled as a failed member, exclude the failure members from backup members.
Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/tipis/ReplicatedMap.java tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/tipis/ReplicatedMap.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/tipis/ReplicatedMap.java?rev=1685938&r1=1685937&r2=1685938&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/tipis/ReplicatedMap.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/tipis/ReplicatedMap.java Wed Jun 17 08:30:46 2015 @@ -17,12 +17,16 @@ package org.apache.catalina.tribes.tipis; import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; import java.util.Iterator; import java.util.Map; import org.apache.catalina.tribes.Channel; import org.apache.catalina.tribes.ChannelException; +import org.apache.catalina.tribes.ChannelException.FaultyMember; import org.apache.catalina.tribes.Member; +import org.apache.catalina.tribes.RemoteProcessException; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; @@ -132,12 +136,36 @@ public class ReplicatedMap<K,V> extends if (backup == null || backup.length == 0) return null; - //publish the data out to all nodes - MapMessage msg = new MapMessage(getMapContextName(), MapMessage.MSG_COPY, false, - (Serializable) key, (Serializable) value, null,channel.getLocalMember(false), backup); - - getChannel().send(getMapMembers(), msg, getChannelSendOptions()); - + try { + + //publish the data out to all nodes + MapMessage msg = new MapMessage(getMapContextName(), MapMessage.MSG_COPY, false, + (Serializable) key, (Serializable) value, null,channel.getLocalMember(false), backup); + + getChannel().send(getMapMembers(), msg, getChannelSendOptions()); + } catch (ChannelException e) { + FaultyMember[] faultyMembers = e.getFaultyMembers(); + if (faultyMembers.length == 0) throw e; + ArrayList<Member> faulty = new ArrayList<Member>(); + for (FaultyMember faultyMember : faultyMembers) { + if (!(faultyMember.getCause() instanceof RemoteProcessException)) { + faulty.add(faultyMember.getMember()); + } + } + Member[] realFaultyMembers = faulty.toArray(new Member[faulty.size()]); + if (realFaultyMembers.length != 0) { + backup = excludeFromSet(realFaultyMembers, backup); + if (backup.length == 0) { + throw e; + } else { + if (log.isWarnEnabled()) { + log.warn("Unable to replicate backup key:" + key + + ". Success nodes:" + Arrays.toString(backup) + + ". Failed nodes:" + Arrays.toString(realFaultyMembers), e); + } + } + } + } return backup; } Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1685938&r1=1685937&r2=1685938&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Wed Jun 17 08:30:46 2015 @@ -189,6 +189,11 @@ Ensure that the nodes that the data has been successfully replicated are set to the backup node. (kfujino) </fix> + <fix> + When failed to replication, rather than all member is handled as a + failed member, exclude the failure members from backup members. + (kfujino) + </fix> </changelog> </subsection> <subsection name="Other"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org