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 dcfc44f90adfe2bd0004821e6eabf073871faacb
Author: Stefan Egli <[email protected]>
AuthorDate: Wed Oct 21 11:39:26 2015 +0000

    SLING-5173 and SLING-4603 related : more syncToken log.info - plus always 
doing the syncToken thingy, independent of whether any instance left or joined 
the cluster as otherwise this thing wont work
    
    git-svn-id: 
https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/commons@1709801
 13f79535-47bb-0310-9956-ffa450edef68
---
 .../providers/base/MinEventDelayHandler.java       |  6 +--
 .../providers/base/ViewStateManagerImpl.java       | 49 ++++++++--------------
 2 files changed, 20 insertions(+), 35 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 d3a9b6a..82c18eb 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
@@ -128,17 +128,17 @@ class MinEventDelayHandler {
                     // check if the new topology is already ready
                     TopologyView t = discoveryService.getTopology();
                     if (!(t instanceof BaseTopologyView)) {
-                        logger.error("asyncDelay.run: topology not of type 
BaseTopologyView: "+t);
+                        logger.error("asyncDelay.run: done delaying. topology 
not of type BaseTopologyView: "+t);
                         // cannot continue in this case
                         return;
                     }
                     BaseTopologyView topology = (BaseTopologyView) t;
                     
                     if (topology.isCurrent()) {
-                        logger.debug("asyncDelay.run: got new view: ", 
topology);
+                        logger.info("asyncDelay.run: done delaying. got new 
view: ", topology.toShortString());
                         viewStateManager.handleNewViewNonDelayed(topology);
                     } else {
-                        logger.info("asyncDelay.run: new view (still/again) 
not current, delaying again");
+                        logger.info("asyncDelay.run: done delaying. new view 
(still/again) not current, delaying again");
                         triggerAsyncDelaying(topology);
                         // we're actually not interested in the result here
                         // if the async part failed, then we have to rely
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 b5fa9fa..f2c3525 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
@@ -33,8 +33,6 @@ import org.apache.sling.discovery.InstanceDescription;
 import org.apache.sling.discovery.TopologyEvent;
 import org.apache.sling.discovery.TopologyEvent.Type;
 import org.apache.sling.discovery.TopologyEventListener;
-import org.apache.sling.discovery.commons.InstancesDiff;
-import org.apache.sling.discovery.commons.InstancesDiff.InstanceCollection;
 import org.apache.sling.discovery.commons.providers.BaseTopologyView;
 import org.apache.sling.discovery.commons.providers.EventHelper;
 import org.apache.sling.discovery.commons.providers.ViewStateManager;
@@ -484,37 +482,23 @@ public class ViewStateManagerImpl implements 
ViewStateManager {
             
             final boolean invokeConsistencyService;
             if (consistencyService==null) {
-                logger.debug("handleNewViewNonDelayed: no consistencyService 
set - continuing directly.");
+                logger.info("handleNewViewNonDelayed: no consistencyService 
set - continuing directly.");
                 invokeConsistencyService = false;
-            } else if (previousView==null) {
-                // when there was no previous view, we cannot determine if
-                // any instance left
-                // so for safety reason: always invoke the consistencyservice
-                logger.debug("handleNewViewNonDelayed: no previousView set - 
invoking consistencyService");
-                invokeConsistencyService = true;
             } else {
-                final InstancesDiff diff = new InstancesDiff(previousView, 
newView);
-                InstanceCollection removed = diff.removed();
-//                Collection<InstanceDescription> c = removed.get();
-//                Iterator<InstanceDescription> it = c.iterator();
-//                while(it.hasNext()) {
-//                    logger.info("handleNewViewNonDelayed: removed: 
"+it.next());
-//                }
-                InstanceCollection inClusterView = removed.
-                        
isInClusterView(newView.getLocalInstance().getClusterView());
-//                c = removed.get();
-//                it = c.iterator();
-//                while(it.hasNext()) {
-//                    logger.info("handleNewViewNonDelayed: inClusterView: 
"+it.next());
-//                }
-                final boolean anyInstanceLeftLocalCluster = inClusterView.
-                        get().size()>0;
-                if (anyInstanceLeftLocalCluster) {
-                    logger.debug("handleNewViewNonDelayed: 
anyInstanceLeftLocalCluster=true, hence invoking consistencyService next");
-                } else {
-                    logger.debug("handleNewViewNonDelayed: 
anyInstanceLeftLocalCluster=false - continuing directly.");
-                }
-                invokeConsistencyService = anyInstanceLeftLocalCluster;
+                // there used to be a distinction between:
+                // * if no previousView is set, then we should invoke the 
consistencyService
+                // * if one was set, then we only invoke it if any instance 
left the cluster
+                // this algorithm would not work though, as the newly joining 
instance
+                // would always have (previousView==null) - thus would always 
do the syncToken
+                // thingy - while the existing instances would think: ah, no 
instance left,
+                // so it is not so urgent to do the syncToken.
+                // at which point the joining instance would wait forever for 
a syncToken 
+                // to arrive.
+                //
+                // which is a long way of saying: if the consistencyService is 
configured,
+                // then we always use it, hence:
+                logger.info("handleNewViewNonDelayed: consistencyService set - 
invoking consistencyService");
+                invokeConsistencyService = true;
             }
                         
             if (invokeConsistencyService) {
@@ -522,7 +506,7 @@ public class ViewStateManagerImpl implements 
ViewStateManager {
                 // then:
                 // run the set consistencyService
                 final int lastModCnt = modCnt;
-                logger.debug("handleNewViewNonDelayed: invoking 
consistencyService (modCnt={})", modCnt);
+                logger.info("handleNewViewNonDelayed: invoking 
consistencyService (modCnt={})", modCnt);
                 consistencyService.sync(newView,
                         new Runnable() {
                     
@@ -551,6 +535,7 @@ public class ViewStateManagerImpl implements 
ViewStateManager {
                 // or using it is not applicable at this stage - so continue
                 // with sending the TOPOLOGY_CHANGED (or TOPOLOGY_INIT if there
                 // are any newly bound topology listeners) directly
+                logger.info("handleNewViewNonDelayed: not invoking 
consistencyService, considering consistent now");
                 doHandleConsistent(newView);
             }
             logger.debug("handleNewViewNonDelayed: end");

-- 
To stop receiving notification emails like this one, please contact
"[email protected]" <[email protected]>.

Reply via email to