Author: stefanegli Date: Wed Oct 21 11:39:26 2015 New Revision: 1709801 URL: http://svn.apache.org/viewvc?rev=1709801&view=rev Log: 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
Modified: sling/trunk/bundles/extensions/discovery/commons/src/main/java/org/apache/sling/discovery/commons/providers/base/MinEventDelayHandler.java sling/trunk/bundles/extensions/discovery/commons/src/main/java/org/apache/sling/discovery/commons/providers/base/ViewStateManagerImpl.java Modified: sling/trunk/bundles/extensions/discovery/commons/src/main/java/org/apache/sling/discovery/commons/providers/base/MinEventDelayHandler.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/commons/src/main/java/org/apache/sling/discovery/commons/providers/base/MinEventDelayHandler.java?rev=1709801&r1=1709800&r2=1709801&view=diff ============================================================================== --- sling/trunk/bundles/extensions/discovery/commons/src/main/java/org/apache/sling/discovery/commons/providers/base/MinEventDelayHandler.java (original) +++ sling/trunk/bundles/extensions/discovery/commons/src/main/java/org/apache/sling/discovery/commons/providers/base/MinEventDelayHandler.java Wed Oct 21 11:39:26 2015 @@ -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 Modified: sling/trunk/bundles/extensions/discovery/commons/src/main/java/org/apache/sling/discovery/commons/providers/base/ViewStateManagerImpl.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/commons/src/main/java/org/apache/sling/discovery/commons/providers/base/ViewStateManagerImpl.java?rev=1709801&r1=1709800&r2=1709801&view=diff ============================================================================== --- sling/trunk/bundles/extensions/discovery/commons/src/main/java/org/apache/sling/discovery/commons/providers/base/ViewStateManagerImpl.java (original) +++ sling/trunk/bundles/extensions/discovery/commons/src/main/java/org/apache/sling/discovery/commons/providers/base/ViewStateManagerImpl.java Wed Oct 21 11:39:26 2015 @@ -33,8 +33,6 @@ import org.apache.sling.discovery.Instan 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 implem 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 implem // 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 implem // 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");