incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stefane...@apache.org
Subject svn commit: r1500024 - in /sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl: cluster/voting/VotingView.java common/View.java
Date Fri, 05 Jul 2013 14:38:11 GMT
Author: stefanegli
Date: Fri Jul  5 14:38:11 2013
New Revision: 1500024

URL: http://svn.apache.org/r1500024
Log:
SLING-2945 : handling another race condition of vote deletion while evaluating it

Modified:
    sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/cluster/voting/VotingView.java
    sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/common/View.java

Modified: sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/cluster/voting/VotingView.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/cluster/voting/VotingView.java?rev=1500024&r1=1500023&r2=1500024&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/cluster/voting/VotingView.java
(original)
+++ sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/cluster/voting/VotingView.java
Fri Jul  5 14:38:11 2013
@@ -284,30 +284,37 @@ public class VotingView extends View {
             // the vote is being created. wait.
             return false;
         }
-        final Iterable<Resource> children = members.getChildren();
-        final Iterator<Resource> it = children.iterator();
-        boolean isWinning = false;
-        while (it.hasNext()) {
-            Resource aMemberRes = it.next();
-            try{
-                ValueMap properties = aMemberRes.adaptTo(ValueMap.class);
-                Boolean initiator = properties.get("initiator", Boolean.class);
-                Boolean vote = properties.get("vote", Boolean.class);
-                if (initiator != null && initiator) {
-                    isWinning = true;
-                    continue;
-                }
-                if (vote != null && vote) {
-                    isWinning = true;
-                    continue;
-                }
-                return false;
-            } catch(RuntimeException re) {
-                logger.info("isWinning: Could not check vote due to "+re);
-                return false;
-            }
+        try{
+	        final Iterable<Resource> children = members.getChildren();
+	        final Iterator<Resource> it = children.iterator();
+	        boolean isWinning = false;
+	        while (it.hasNext()) {
+	            Resource aMemberRes = it.next();
+	            try{
+	                ValueMap properties = aMemberRes.adaptTo(ValueMap.class);
+	                Boolean initiator = properties.get("initiator", Boolean.class);
+	                Boolean vote = properties.get("vote", Boolean.class);
+	                if (initiator != null && initiator) {
+	                    isWinning = true;
+	                    continue;
+	                }
+	                if (vote != null && vote) {
+	                    isWinning = true;
+	                    continue;
+	                }
+	                return false;
+	            } catch(RuntimeException re) {
+	                logger.info("isWinning: Could not check vote due to "+re);
+	                return false;
+	            }
+	        }
+	        return isWinning;
+        } catch(RuntimeException re) {
+        	// SLING-2945: gracefully handle case where members node is
+        	//             deleted by another instance
+        	logger.info("isWinning: could not check vote due to "+re);
+        	return false;
         }
-        return isWinning;
     }
 
     /**

Modified: sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/common/View.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/common/View.java?rev=1500024&r1=1500023&r2=1500024&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/common/View.java
(original)
+++ sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/common/View.java
Fri Jul  5 14:38:11 2013
@@ -113,6 +113,7 @@ public class View {
         	// SLING-2945 : the members resource could have been deleted
         	//              by another party simultaneously
         	//              so treat this situation nicely
+        	logger.info("matches: cannot compare due to "+re);
         	return false;
         }
         // now the ViewCopy set must be empty to represent a match



Mime
View raw message