This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.discovery.commons-1.0.0 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-commons.git
commit df6d8658e503e7eb5efdefc2b52fb3a7638485c2 Author: Stefan Egli <[email protected]> AuthorDate: Thu Oct 22 15:35:44 2015 +0000 SLING-5173 : bugfix for leader changes: leader change was treated as a properties change - which was very bad - now it is properly treated as a TOPOLOGY_CHANGED. Note that leader change should not happen in an otherwise unchanged topology - but it can if one instance's discovery.oak bundle for example is restarted, thus getting a lower leaderElectionId. Thus discovery.commons must account for this git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/commons@1710040 13f79535-47bb-0310-9956-ffa450edef68 --- .../commons/providers/base/MinEventDelayHandler.java | 2 +- .../commons/providers/base/ViewStateManagerImpl.java | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/apache/sling/discovery/commons/providers/base/MinEventDelayHandler.java b/src/main/java/org/apache/sling/discovery/commons/providers/base/MinEventDelayHandler.java index 068cf7e..a8a0066 100644 --- a/src/main/java/org/apache/sling/discovery/commons/providers/base/MinEventDelayHandler.java +++ b/src/main/java/org/apache/sling/discovery/commons/providers/base/MinEventDelayHandler.java @@ -87,7 +87,7 @@ class MinEventDelayHandler { return false; } - if (viewStateManager.isPropertiesDiff(newView)) { + if (viewStateManager.onlyDiffersInProperties(newView)) { logger.info("handlesNewView: only properties differ, hence no delaying applicable"); return false; } diff --git a/src/main/java/org/apache/sling/discovery/commons/providers/base/ViewStateManagerImpl.java b/src/main/java/org/apache/sling/discovery/commons/providers/base/ViewStateManagerImpl.java index 70fa33f..9fa980b 100644 --- a/src/main/java/org/apache/sling/discovery/commons/providers/base/ViewStateManagerImpl.java +++ b/src/main/java/org/apache/sling/discovery/commons/providers/base/ViewStateManagerImpl.java @@ -454,7 +454,7 @@ public class ViewStateManagerImpl implements ViewStateManager { logger.debug("handleNewViewNonDelayed: we were not in changing state and new view matches old, so - ignoring"); return false; } - if (previousView==null || !isPropertiesDiff(newView)) { + if (previousView==null || !onlyDiffersInProperties(newView)) { logger.debug("handleNewViewNonDelayed: implicitly triggering a handleChanging as we were not in changing state"); handleChanging(); logger.debug("handleNewViewNonDelayed: implicitly triggering of a handleChanging done"); @@ -475,7 +475,7 @@ public class ViewStateManagerImpl implements ViewStateManager { } // now check if the view indeed changed or if it was just the properties - if (!isChanging && isPropertiesDiff(newView)) { + if (!isChanging && onlyDiffersInProperties(newView)) { // well then send a properties changed event only // and that one does not go via consistencyservice logger.info("handleNewViewNonDelayed: properties changed to: "+newView); @@ -552,7 +552,7 @@ public class ViewStateManagerImpl implements ViewStateManager { } } - protected boolean isPropertiesDiff(BaseTopologyView newView) { + protected boolean onlyDiffersInProperties(BaseTopologyView newView) { if (previousView==null) { return false; } @@ -571,13 +571,17 @@ public class ViewStateManagerImpl implements ViewStateManager { } for(InstanceDescription oldInstance : previousView.getInstances()) { - if (!newIds.contains(oldInstance.getSlingId())) { + InstanceDescription newInstance = newView.getInstance(oldInstance.getSlingId()); + if (newInstance == null) { + return false; + } + if (oldInstance.isLeader() != newInstance.isLeader()) { return false; } } return true; } - + private void doHandleConsistent(BaseTopologyView newView) { logger.trace("doHandleConsistent: start"); -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
