You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by st...@apache.org on 2016/11/15 12:38:36 UTC

svn commit: r1769802 [1/3] - in /sling/trunk/bundles/extensions/discovery: base/ base/src/main/java/org/apache/sling/discovery/base/connectors/announcement/ base/src/test/java/org/apache/sling/discovery/base/its/ base/src/test/java/org/apache/sling/dis...

Author: stefanegli
Date: Tue Nov 15 12:38:35 2016
New Revision: 1769802

URL: http://svn.apache.org/viewvc?rev=1769802&view=rev
Log:
SLING-5231 : remove getAdministrativeResourceResolver from discovery components : merged patches from Carsten

Modified:
    sling/trunk/bundles/extensions/discovery/base/pom.xml
    sling/trunk/bundles/extensions/discovery/base/src/main/java/org/apache/sling/discovery/base/connectors/announcement/AnnouncementRegistryImpl.java
    sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/AbstractClusterTest.java
    sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/AbstractSingleInstanceTest.java
    sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/AbstractTopologyEventTest.java
    sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/setup/VirtualInstance.java
    sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/setup/VirtualInstanceHelper.java
    sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/setup/mock/DummyResourceResolverFactory.java
    sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/setup/mock/DummyViewChecker.java
    sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockedResourceResolver.java
    sling/trunk/bundles/extensions/discovery/commons/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/IdMapService.java
    sling/trunk/bundles/extensions/discovery/commons/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/OakBacklogClusterSyncService.java
    sling/trunk/bundles/extensions/discovery/commons/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/SyncTokenService.java
    sling/trunk/bundles/extensions/discovery/commons/src/test/java/org/apache/sling/discovery/commons/providers/base/TestHelper.java
    sling/trunk/bundles/extensions/discovery/commons/src/test/java/org/apache/sling/discovery/commons/providers/base/TestMinEventDelayHandler.java
    sling/trunk/bundles/extensions/discovery/commons/src/test/java/org/apache/sling/discovery/commons/providers/base/TestViewStateManager.java
    sling/trunk/bundles/extensions/discovery/commons/src/test/java/org/apache/sling/discovery/commons/providers/spi/base/DescriptorHelper.java
    sling/trunk/bundles/extensions/discovery/commons/src/test/java/org/apache/sling/discovery/commons/providers/spi/base/MockedResourceResolver.java
    sling/trunk/bundles/extensions/discovery/commons/src/test/java/org/apache/sling/discovery/commons/providers/spi/base/RepositoryTestHelper.java
    sling/trunk/bundles/extensions/discovery/impl/pom.xml
    sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/DiscoveryServiceImpl.java
    sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/TopologyWebConsolePlugin.java
    sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/cluster/ClusterViewServiceImpl.java
    sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/cluster/voting/VotingHandler.java
    sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/common/heartbeat/HeartbeatHandler.java
    sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/DiscoveryServiceImplTest.java
    sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/cluster/RepositoryDelaysTest.java
    sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/cluster/voting/VotingHandlerTest.java
    sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/common/heartbeat/HeartbeatTest.java
    sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/setup/FullJR2VirtualInstance.java
    sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/setup/FullJR2VirtualInstanceBuilder.java
    sling/trunk/bundles/extensions/discovery/oak/pom.xml
    sling/trunk/bundles/extensions/discovery/oak/src/main/java/org/apache/sling/discovery/oak/OakDiscoveryService.java
    sling/trunk/bundles/extensions/discovery/oak/src/main/java/org/apache/sling/discovery/oak/TopologyWebConsolePlugin.java
    sling/trunk/bundles/extensions/discovery/oak/src/main/java/org/apache/sling/discovery/oak/cluster/OakClusterViewService.java
    sling/trunk/bundles/extensions/discovery/oak/src/main/java/org/apache/sling/discovery/oak/pinger/OakViewChecker.java
    sling/trunk/bundles/extensions/discovery/oak/src/test/java/org/apache/sling/discovery/oak/OakDiscoveryServiceTest.java
    sling/trunk/bundles/extensions/discovery/oak/src/test/java/org/apache/sling/discovery/oak/its/OakDiscoveryServiceTest.java
    sling/trunk/bundles/extensions/discovery/oak/src/test/java/org/apache/sling/discovery/oak/its/setup/OakVirtualInstanceBuilder.java

Modified: sling/trunk/bundles/extensions/discovery/base/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/base/pom.xml?rev=1769802&r1=1769801&r2=1769802&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/base/pom.xml (original)
+++ sling/trunk/bundles/extensions/discovery/base/pom.xml Tue Nov 15 12:38:35 2016
@@ -184,7 +184,7 @@
 		<dependency>
 			<groupId>org.apache.sling</groupId>
 			<artifactId>org.apache.sling.api</artifactId>
-			<version>2.4.0</version>
+			<version>2.5.0</version>
             <scope>provided</scope>
 		</dependency>
         <dependency>

Modified: sling/trunk/bundles/extensions/discovery/base/src/main/java/org/apache/sling/discovery/base/connectors/announcement/AnnouncementRegistryImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/base/src/main/java/org/apache/sling/discovery/base/connectors/announcement/AnnouncementRegistryImpl.java?rev=1769802&r1=1769801&r2=1769802&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/base/src/main/java/org/apache/sling/discovery/base/connectors/announcement/AnnouncementRegistryImpl.java (original)
+++ sling/trunk/bundles/extensions/discovery/base/src/main/java/org/apache/sling/discovery/base/connectors/announcement/AnnouncementRegistryImpl.java Tue Nov 15 12:38:35 2016
@@ -62,17 +62,17 @@ public class AnnouncementRegistryImpl im
     private SlingSettingsService settingsService;
 
     private String slingId;
-    
+
     @Reference
     private BaseConfig config;
-    
+
     public static AnnouncementRegistryImpl testConstructorAndActivate(ResourceResolverFactory resourceResolverFactory,
             SlingSettingsService slingSettingsService, BaseConfig config) {
         AnnouncementRegistryImpl registry = testConstructor(resourceResolverFactory, slingSettingsService, config);
         registry.activate();
         return registry;
     }
-    
+
     public static AnnouncementRegistryImpl testConstructor(ResourceResolverFactory resourceResolverFactory,
             SlingSettingsService slingSettingsService, BaseConfig config) {
         AnnouncementRegistryImpl registry = new AnnouncementRegistryImpl();
@@ -81,22 +81,23 @@ public class AnnouncementRegistryImpl im
         registry.config = config;
         return registry;
     }
-    
+
     @Activate
     protected void activate() {
         slingId = settingsService.getSlingId();
     }
-    
-    private final Map<String,CachedAnnouncement> ownAnnouncementsCache = 
+
+    private final Map<String,CachedAnnouncement> ownAnnouncementsCache =
             new HashMap<String,CachedAnnouncement>();
 
+    @Override
     public synchronized void unregisterAnnouncement(final String ownerId) {
         if (ownerId==null || ownerId.length()==0) {
             throw new IllegalArgumentException("ownerId must not be null or empty");
         }
         // remove from the cache - even if there's an error afterwards
         ownAnnouncementsCache.remove(ownerId);
-        
+
         if (resourceResolverFactory == null) {
             logger.error("unregisterAnnouncement: resourceResolverFactory is null");
             return;
@@ -104,7 +105,7 @@ public class AnnouncementRegistryImpl im
         ResourceResolver resourceResolver = null;
         try {
             resourceResolver = resourceResolverFactory
-                    .getAdministrativeResourceResolver(null);
+                    .getServiceResourceResolver(null);
 
             final String path = config.getClusterInstancesPath()
                     + "/"
@@ -134,10 +135,12 @@ public class AnnouncementRegistryImpl im
         }
     }
 
+    @Override
     public synchronized Collection<Announcement> listLocalAnnouncements() {
         return fillWithCachedAnnouncements(new LinkedList<Announcement>());
     }
-    
+
+    @Override
     public synchronized Collection<CachedAnnouncement> listLocalIncomingAnnouncements() {
         Collection<CachedAnnouncement> result = new LinkedList<CachedAnnouncement>(ownAnnouncementsCache.values());
         for (Iterator<CachedAnnouncement> it = result.iterator(); it.hasNext();) {
@@ -153,7 +156,7 @@ public class AnnouncementRegistryImpl im
         }
         return result;
     }
-    
+
     private final InstanceDescription getLocalInstanceDescription(final ClusterView localClusterView) {
         for (Iterator<InstanceDescription> it = localClusterView.getInstances().iterator(); it
                 .hasNext();) {
@@ -165,6 +168,7 @@ public class AnnouncementRegistryImpl im
         return null;
     }
 
+    @Override
     public synchronized Collection<Announcement> listAnnouncementsInSameCluster(final ClusterView localClusterView) {
         logger.debug("listAnnouncementsInSameCluster: start. localClusterView: {}", localClusterView);
         if (localClusterView==null) {
@@ -175,7 +179,7 @@ public class AnnouncementRegistryImpl im
         final InstanceDescription localInstance = getLocalInstanceDescription(localClusterView);
         try {
             resourceResolver = resourceResolverFactory
-                    .getAdministrativeResourceResolver(null);
+                    .getServiceResourceResolver(null);
 
             Resource clusterInstancesResource = ResourceHelper
                     .getOrCreateResource(
@@ -194,7 +198,7 @@ public class AnnouncementRegistryImpl im
                     fillWithCachedAnnouncements(incomingAnnouncements);
                     continue;
                 }
-                
+
                 //TODO: add ClusterView.contains(instanceSlingId) for convenience to next api change
                 if (!contains(localClusterView, instanceId)) {
                     logger.debug("listAnnouncementsInSameCluster: instance is not in my view, ignoring: {}", instanceId);
@@ -221,7 +225,7 @@ public class AnnouncementRegistryImpl im
                                             String.class));
                     logger.debug("listAnnouncementsInSameCluster: found announcement: {}", topologyAnnouncement);
                     incomingAnnouncements.add(topologyAnnouncement);
-                    // SLING-3389: no longer check for expired announcements - 
+                    // SLING-3389: no longer check for expired announcements -
                     // instead make use of the fact that this instance
                     // has a clusterView and that every live instance
                     // is responsible of cleaning up expired announcements
@@ -253,7 +257,7 @@ public class AnnouncementRegistryImpl im
     	}
         return incomingAnnouncements;
     }
-    
+
     private final Collection<Announcement> fillWithCachedAnnouncements(
             final Collection<Announcement> incomingAnnouncements) {
         for (Iterator<Entry<String, CachedAnnouncement>> it = ownAnnouncementsCache.entrySet().iterator(); it
@@ -280,6 +284,7 @@ public class AnnouncementRegistryImpl im
         return false;
     }
 
+    @Override
     public synchronized boolean hasActiveAnnouncement(final String ownerId) {
         if (ownerId==null || ownerId.length()==0) {
             throw new IllegalArgumentException("ownerId must not be null or empty: "+ownerId);
@@ -288,10 +293,11 @@ public class AnnouncementRegistryImpl im
         if (cachedAnnouncement==null) {
             return false;
         }
-        
+
         return !cachedAnnouncement.hasExpired();
     }
 
+    @Override
     public synchronized long registerAnnouncement(final Announcement topologyAnnouncement) {
         if (topologyAnnouncement==null) {
             throw new IllegalArgumentException("topologyAnnouncement must not be null");
@@ -304,8 +310,8 @@ public class AnnouncementRegistryImpl im
             logger.error("registerAnnouncement: resourceResolverFactory is null");
             return -1;
         }
-        
-        final CachedAnnouncement cachedAnnouncement = 
+
+        final CachedAnnouncement cachedAnnouncement =
                 ownAnnouncementsCache.get(topologyAnnouncement.getOwnerId());
         if (cachedAnnouncement!=null) {
             if (logger.isDebugEnabled()) {
@@ -320,7 +326,7 @@ public class AnnouncementRegistryImpl im
                     return cachedAnnouncement.registerPing(topologyAnnouncement, config);
                 }
                 logger.debug("registerAnnouncement: incoming announcement differs from existing one!");
-                
+
             } catch(JSONException e) {
                 logger.error("registerAnnouncement: got JSONException while converting incoming announcement to JSON: "+e, e);
             }
@@ -364,7 +370,7 @@ public class AnnouncementRegistryImpl im
         ResourceResolver resourceResolver = null;
         try {
             resourceResolver = resourceResolverFactory
-                    .getAdministrativeResourceResolver(null);
+                    .getServiceResourceResolver(null);
 
             final Resource announcementsResource = ResourceHelper
                     .getOrCreateResource(
@@ -376,7 +382,7 @@ public class AnnouncementRegistryImpl im
 
             topologyAnnouncement.persistTo(announcementsResource);
             resourceResolver.commit();
-            ownAnnouncementsCache.put(topologyAnnouncement.getOwnerId(), 
+            ownAnnouncementsCache.put(topologyAnnouncement.getOwnerId(),
                     new CachedAnnouncement(topologyAnnouncement, config));
         } catch (LoginException e) {
             logger.error(
@@ -401,12 +407,13 @@ public class AnnouncementRegistryImpl im
         return 0;
     }
 
-    public synchronized void addAllExcept(final Announcement target, final ClusterView clusterView, 
+    @Override
+    public synchronized void addAllExcept(final Announcement target, final ClusterView clusterView,
             final AnnouncementFilter filter) {
         ResourceResolver resourceResolver = null;
         try {
             resourceResolver = resourceResolverFactory
-                    .getAdministrativeResourceResolver(null);
+                    .getServiceResourceResolver(null);
 
             final Resource clusterInstancesResource = ResourceHelper
                     .getOrCreateResource(
@@ -471,14 +478,15 @@ public class AnnouncementRegistryImpl im
         }
     }
 
+    @Override
     public synchronized void checkExpiredAnnouncements() {
-        for (Iterator<Entry<String, CachedAnnouncement>> it = 
+        for (Iterator<Entry<String, CachedAnnouncement>> it =
                 ownAnnouncementsCache.entrySet().iterator(); it.hasNext();) {
             final Entry<String, CachedAnnouncement> entry = it.next();
             if (entry.getValue().hasExpired()) {
                 // then we have an expiry
                 it.remove();
-                
+
                 final String instanceId = entry.getKey();
                 logger.info("checkExpiredAnnouncements: topology connector of "+instanceId+
                         " (to me="+slingId+
@@ -496,7 +504,7 @@ public class AnnouncementRegistryImpl im
         boolean requiresCommit = false;
         try {
             resourceResolver = resourceResolverFactory
-                    .getAdministrativeResourceResolver(null);
+                    .getServiceResourceResolver(null);
             final Resource announcementsResource = ResourceHelper
                     .getOrCreateResource(
                             resourceResolver,
@@ -510,7 +518,7 @@ public class AnnouncementRegistryImpl im
             	final String ownerId = res.getName();
             	// ownerId is the slingId of the owner of the announcement (ie of the peer of the connector).
             	// let's check if the we have that owner's announcement in the cache
-            	
+
             	if (ownAnnouncementsCache.containsKey(ownerId)) {
             		// fine then, we'll leave this announcement untouched
             		continue;
@@ -518,7 +526,7 @@ public class AnnouncementRegistryImpl im
             	// otherwise this announcement is likely from an earlier incarnation
             	// of this instance - hence stale - hence we must remove it now
             	//  (SLING-4139)
-            	ResourceHelper.deleteResource(resourceResolver, 
+            	ResourceHelper.deleteResource(resourceResolver,
             			res.getPath());
             	requiresCommit = true;
             }
@@ -548,8 +556,8 @@ public class AnnouncementRegistryImpl im
         ResourceResolver resourceResolver = null;
         try {
             resourceResolver = resourceResolverFactory
-                    .getAdministrativeResourceResolver(null);
-            ResourceHelper.deleteResource(resourceResolver, 
+                    .getServiceResourceResolver(null);
+            ResourceHelper.deleteResource(resourceResolver,
                     config.getClusterInstancesPath()
                                 + "/"
                                 + slingId
@@ -575,6 +583,7 @@ public class AnnouncementRegistryImpl im
         }
     }
 
+    @Override
     public synchronized Collection<InstanceDescription> listInstances(final ClusterView localClusterView) {
         logger.debug("listInstances: start. localClusterView: {}", localClusterView);
         final Collection<InstanceDescription> instances = new LinkedList<InstanceDescription>();

Modified: sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/AbstractClusterTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/AbstractClusterTest.java?rev=1769802&r1=1769801&r2=1769802&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/AbstractClusterTest.java (original)
+++ sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/AbstractClusterTest.java Tue Nov 15 12:38:35 2016
@@ -36,6 +36,7 @@ import java.util.concurrent.Semaphore;
 
 import org.apache.log4j.Level;
 import org.apache.log4j.LogManager;
+import org.apache.log4j.spi.RootLogger;
 import org.apache.sling.commons.testing.junit.categories.Slow;
 import org.apache.sling.discovery.ClusterView;
 import org.apache.sling.discovery.InstanceDescription;
@@ -62,17 +63,17 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public abstract class AbstractClusterTest {
-	
+
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
-    
+
     private class SimpleClusterView {
-    	
+
     	private VirtualInstance[] instances;
 
     	SimpleClusterView(VirtualInstance... instances) {
     		this.instances = instances;
     	}
-    	
+
     	@Override
     	public String toString() {
     	    String instanceSlingIds = "";
@@ -100,10 +101,10 @@ public abstract class AbstractClusterTes
     private Level logLevel;
 
     protected abstract VirtualInstanceBuilder newBuilder();
-    
+
     @Before
     public void setup() throws Exception {
-        final org.apache.log4j.Logger discoveryLogger = LogManager.getRootLogger().getLogger("org.apache.sling.discovery");
+        final org.apache.log4j.Logger discoveryLogger = RootLogger.getLogger("org.apache.sling.discovery");
         logLevel = discoveryLogger.getLevel();
         discoveryLogger.setLevel(Level.TRACE);
         logger.debug("here we are");
@@ -140,10 +141,10 @@ public abstract class AbstractClusterTes
         instance3 = null;
         instance4 = null;
         instance5 = null;
-        final org.apache.log4j.Logger discoveryLogger = LogManager.getRootLogger().getLogger("org.apache.sling.discovery");
+        final org.apache.log4j.Logger discoveryLogger = RootLogger.getLogger("org.apache.sling.discovery");
         discoveryLogger.setLevel(logLevel);
     }
-    
+
     /** test leader behaviour with ascending slingIds, SLING-3253 **/
     @Test
     public void testLeaderAsc() throws Throwable {
@@ -206,11 +207,11 @@ public abstract class AbstractClusterTes
         }
         instance1.heartbeatsAndCheckView();
         instance2.heartbeatsAndCheckView();
-        
+
         // now they must be in the same cluster, so in a cluster of size 1
         assertEquals(2, instance1.getClusterViewService().getLocalClusterView().getInstances().size());
         assertEquals(2, instance2.getClusterViewService().getLocalClusterView().getInstances().size());
-        
+
         // the first instance should be the leader - since it was started first
         assertTrue(instance1.getLocalInstanceDescription().isLeader());
         assertFalse(instance2.getLocalInstanceDescription().isLeader());
@@ -231,11 +232,11 @@ public abstract class AbstractClusterTes
     public void testStaleAnnouncementsVisibleToClusterPeers4139() throws Throwable {
         logger.info("testStaleAnnouncementsVisibleToClusterPeers4139: start");
     	final String instance1SlingId = prepare4139();
-        
+
         // remove topology connector from instance3 to instance1
         // -> corresponds to stop pinging
         // (nothing to assert additionally here)
-        
+
         // start instance 1
         instance1Restarted = newBuilder().setDebugName("firstInstance")
                 .useRepositoryOf(instance2)
@@ -247,13 +248,13 @@ public abstract class AbstractClusterTes
         runHeartbeatOnceWith(instance1Restarted, instance2, instance3);
         Thread.sleep(500);
         runHeartbeatOnceWith(instance1Restarted, instance2, instance3);
-        
+
         // facts: connector 3->1 does not exist actively anymore,
-        //        instance 1+2 should build a cluster, 
+        //        instance 1+2 should build a cluster,
         //        instance 3 should be isolated
         logger.info("instance1Restarted.dump: "+instance1Restarted.slingId);
         instance1Restarted.dumpRepo();
-        
+
         logger.info("instance2.dump: "+instance2.slingId);
         instance2.dumpRepo();
 
@@ -266,10 +267,10 @@ public abstract class AbstractClusterTes
         instance1Restarted.stop();
         logger.info("testStaleAnnouncementsVisibleToClusterPeers4139: end");
     }
-    
+
     /**
      * Tests a situation where a connector was done to instance1, which eventually
-     * crashed, then the connector is done to instance2. Meanwhile instance1 
+     * crashed, then the connector is done to instance2. Meanwhile instance1
      * got restarted and this test assures that the instance3 is not reported
      * twice in the topology. Did not happen before 4139, but should never afterwards neither
      */
@@ -277,13 +278,13 @@ public abstract class AbstractClusterTes
     public void testDuplicateInstanceIn2Clusters4139() throws Throwable {
         logger.info("testDuplicateInstanceIn2Clusters4139: start");
         final String instance1SlingId = prepare4139();
-        
+
         // remove topology connector from instance3 to instance1
         // -> corresponds to stop pinging
         // (nothing to assert additionally here)
         // instead, now start a connector from instance3 to instance2
         pingConnector(instance3, instance2);
-        
+
         // start instance 1
         instance1Restarted = newBuilder().setDebugName("firstInstance")
                 .useRepositoryOf(instance2)
@@ -300,7 +301,7 @@ public abstract class AbstractClusterTes
         logger.info("instance3.slingId: "+instance3.slingId);
         instance1Restarted.dumpRepo();
         assertSameTopology(new SimpleClusterView(instance1Restarted, instance2), new SimpleClusterView(instance3));
-        
+
         Thread.sleep(500);
         runHeartbeatOnceWith(instance1Restarted, instance2, instance3);
         pingConnector(instance3, instance2);
@@ -316,16 +317,16 @@ public abstract class AbstractClusterTes
 
         logger.info("testDuplicateInstanceIn2Clusters4139: end");
     }
-    
+
 /*    ok, this test should do the following:
          * cluster A with instance 1 and instance 2
          * cluster B with instance 3 and instance 4
          * cluster C with instance 5
-         
+
          * initially, instance3 is pinging instance1, and instance 5 is pinging instance1 as well (MAC hub)
           * that should result in instance3 and 5 to inherit the rest from instance1
-         * then simulate load balancer switching from instance1 to instance2 - hence pings go to instance2 
-         * 
+         * then simulate load balancer switching from instance1 to instance2 - hence pings go to instance2
+         *
          */
     @Category(Slow.class) //TODO: this takes env 45sec
     @Test
@@ -333,10 +334,10 @@ public abstract class AbstractClusterTes
         final int MIN_EVENT_DELAY = 1;
 
         tearDown(); // reset any setup that was done - we start with a different setup than the default one
-        final org.apache.log4j.Logger discoveryLogger = LogManager.getRootLogger().getLogger("org.apache.sling.discovery");
+        final org.apache.log4j.Logger discoveryLogger = RootLogger.getLogger("org.apache.sling.discovery");
         logLevel = discoveryLogger.getLevel();
         discoveryLogger.setLevel(Level.DEBUG);
-        
+
         instance1 = newBuilder().setDebugName("instance1")
                 .newRepository("/var/discovery/clusterA/", true)
                 .setConnectorPingTimeout(10 /* sec */)
@@ -375,7 +376,7 @@ public abstract class AbstractClusterTes
         assertSameTopology(new SimpleClusterView(instance1, instance2));
         assertSameTopology(new SimpleClusterView(instance3, instance4));
         assertSameTopology(new SimpleClusterView(instance5));
-        
+
         // create a topology connector from instance3 to instance1
         // -> corresponds to starting to ping
         runHeartbeatOnceWith(instance1, instance2, instance3, instance4, instance5);
@@ -386,7 +387,7 @@ public abstract class AbstractClusterTes
         pingConnector(instance3, instance1);
         pingConnector(instance5, instance1);
         Thread.sleep(500);
-        
+
         // make asserts on the topology
         logger.info("testConnectorSwitching4139: instance1.slingId="+instance1.slingId);
         logger.info("testConnectorSwitching4139: instance2.slingId="+instance2.slingId);
@@ -394,11 +395,11 @@ public abstract class AbstractClusterTes
         logger.info("testConnectorSwitching4139: instance4.slingId="+instance4.slingId);
         logger.info("testConnectorSwitching4139: instance5.slingId="+instance5.slingId);
         instance1.dumpRepo();
-        
-        assertSameTopology(new SimpleClusterView(instance1, instance2), 
-                new SimpleClusterView(instance3, instance4), 
+
+        assertSameTopology(new SimpleClusterView(instance1, instance2),
+                new SimpleClusterView(instance3, instance4),
                 new SimpleClusterView(instance5));
-        
+
         // simulate a crash of instance1, resulting in load-balancer to switch the pings
         boolean success = false;
         for(int i=0; i<25; i++) {
@@ -419,7 +420,7 @@ public abstract class AbstractClusterTes
             }
             logger.info("testConnectorSwitching4139: looping cos ping1="+ping1+", ping2="+ping2);
             Thread.sleep(1000); // 25x1000ms = 25sec max - (vs 10sec timeout)
-            
+
         }
         assertTrue(success);
         // one final heartbeat
@@ -429,8 +430,8 @@ public abstract class AbstractClusterTes
 
         instance2.dumpRepo();
 
-        assertSameTopology(new SimpleClusterView(instance2), 
-                new SimpleClusterView(instance3, instance4), 
+        assertSameTopology(new SimpleClusterView(instance2),
+                new SimpleClusterView(instance3, instance4),
                 new SimpleClusterView(instance5));
 
         // restart instance1, crash instance4
@@ -455,7 +456,7 @@ public abstract class AbstractClusterTes
             // an establishedView as failing upon detecting a view change
             // when the view changes, we're sending TOPOLOGY_CHANGING to listeners
             // so getTopology() should also return isCurrent==false - which
-            // means that doing a ping will also fail, cos that wants to 
+            // means that doing a ping will also fail, cos that wants to
             // get a current topology to send as an announcement.
             // which is a long way of saying: we cannot do an assert here
             // since instance3 *can* have an undefined cluster view..
@@ -500,8 +501,8 @@ public abstract class AbstractClusterTes
         instance1Restarted.dumpRepo();
         assertTrue(success);
 
-        assertSameTopology(new SimpleClusterView(instance1Restarted, instance2), 
-                new SimpleClusterView(instance3), 
+        assertSameTopology(new SimpleClusterView(instance1Restarted, instance2),
+                new SimpleClusterView(instance3),
                 new SimpleClusterView(instance5));
         instance1Restarted.stop();
 
@@ -514,10 +515,10 @@ public abstract class AbstractClusterTes
         final int MIN_EVENT_DELAY = 1;
 
         tearDown(); // reset any setup that was done - we start with a different setup than the default one
-        final org.apache.log4j.Logger discoveryLogger = LogManager.getRootLogger().getLogger("org.apache.sling.discovery");
+        final org.apache.log4j.Logger discoveryLogger = RootLogger.getLogger("org.apache.sling.discovery");
         logLevel = discoveryLogger.getLevel();
         discoveryLogger.setLevel(Level.DEBUG);
-        
+
         instance1 = newBuilder().setDebugName("instance1")
                 .newRepository("/var/discovery/clusterA/", true)
                 .setConnectorPingTimeout(15 /* sec */)
@@ -547,25 +548,25 @@ public abstract class AbstractClusterTes
         assertSameTopology(new SimpleClusterView(instance1, instance2));
         assertSameTopology(new SimpleClusterView(instance3));
         assertSameTopology(new SimpleClusterView(instance5));
-        
+
         // create a topology connector from instance3 to instance1
         // -> corresponds to starting to ping
         pingConnector(instance3, instance1);
         pingConnector(instance5, instance1);
         pingConnector(instance3, instance1);
         pingConnector(instance5, instance1);
-        
+
         // make asserts on the topology
         logger.info("testDuplicateInstance3726: instance1.slingId="+instance1.slingId);
         logger.info("testDuplicateInstance3726: instance2.slingId="+instance2.slingId);
         logger.info("testDuplicateInstance3726: instance3.slingId="+instance3.slingId);
         logger.info("testDuplicateInstance3726: instance5.slingId="+instance5.slingId);
         instance1.dumpRepo();
-        
-        assertSameTopology(new SimpleClusterView(instance1, instance2), 
-                new SimpleClusterView(instance3/*, instance4*/), 
+
+        assertSameTopology(new SimpleClusterView(instance1, instance2),
+                new SimpleClusterView(instance3/*, instance4*/),
                 new SimpleClusterView(instance5));
-        
+
         // simulate a crash of instance1, resulting in load-balancer to switch the pings
         instance1.stopViewChecker();
         boolean success = false;
@@ -587,7 +588,7 @@ public abstract class AbstractClusterTes
             }
             logger.info("testDuplicateInstance3726: looping");
             Thread.sleep(1000); // 25x1000ms = 25sec max - (vs 15sec timeout)
-            
+
         }
         assertTrue(success);
         // one final heartbeat
@@ -597,8 +598,8 @@ public abstract class AbstractClusterTes
 
         instance2.dumpRepo();
 
-        assertSameTopology(new SimpleClusterView(instance2), 
-                new SimpleClusterView(instance3), 
+        assertSameTopology(new SimpleClusterView(instance2),
+                new SimpleClusterView(instance3),
                 new SimpleClusterView(instance5));
 
         // restart instance1, start instance4
@@ -614,7 +615,7 @@ public abstract class AbstractClusterTes
         for(int i=0; i<3; i++) {
             runHeartbeatOnceWith(instance1Restarted, instance2, instance3, instance4, instance5);
             Thread.sleep(250);
-            // since instance4 just started - hooked to instance3 
+            // since instance4 just started - hooked to instance3
             // it is possible that it doesn't just have a topology
             // yet - so we cannot do:
             //assertTrue(pingConnector(instance3, instance2));
@@ -635,8 +636,8 @@ public abstract class AbstractClusterTes
         logger.info("testDuplicateInstance3726: instance5.slingId="+instance5.slingId);
         assertTrue(success);
 
-        assertSameTopology(new SimpleClusterView(instance1Restarted, instance2), 
-                new SimpleClusterView(instance3, instance4), 
+        assertSameTopology(new SimpleClusterView(instance1Restarted, instance2),
+                new SimpleClusterView(instance3, instance4),
                 new SimpleClusterView(instance5));
         instance1Restarted.stop();
         logger.info("testDuplicateInstance3726: end");
@@ -646,7 +647,7 @@ public abstract class AbstractClusterTes
         if (clusters==null) {
             return;
         }
-        for(int i=0; i<clusters.length; i++) { // go through all clusters 
+        for(int i=0; i<clusters.length; i++) { // go through all clusters
             final SimpleClusterView aCluster = clusters[i];
             assertSameClusterIds(aCluster.instances);
             for(int j=0; j<aCluster.instances.length; j++) { // and all instances therein
@@ -676,7 +677,7 @@ public abstract class AbstractClusterTes
 
     /**
      * Tests a situation where a connector was done to instance1, which eventually
-     * crashed, then the connector is done to instance4 (which is in a separate, 3rd cluster). 
+     * crashed, then the connector is done to instance4 (which is in a separate, 3rd cluster).
      * Meanwhile instance1 got restarted and this test assures that the instance3 is not reported
      * twice in the topology. This used to happen prior to SLING-4139
      */
@@ -684,11 +685,11 @@ public abstract class AbstractClusterTes
     public void testStaleInstanceIn3Clusters4139() throws Throwable {
         logger.info("testStaleInstanceIn3Clusters4139: start");
         final String instance1SlingId = prepare4139();
-        
+
         // remove topology connector from instance3 to instance1
         // -> corresponds to stop pinging
         // (nothing to assert additionally here)
-        
+
         // start instance4 in a separate cluster
         instance4 = newBuilder().setDebugName("remoteInstance4")
                 .newRepository("/var/discovery/implremote4/", false)
@@ -700,12 +701,12 @@ public abstract class AbstractClusterTes
         } catch(UndefinedClusterViewException e) {
             // ok
         }
-        
+
         // instead, now start a connector from instance3 to instance2
         instance4.heartbeatsAndCheckView();
         instance4.heartbeatsAndCheckView();
         pingConnector(instance3, instance4);
-        
+
         // start instance 1
         instance1Restarted = newBuilder().setDebugName("firstInstance")
                 .useRepositoryOf(instance2)
@@ -726,7 +727,7 @@ public abstract class AbstractClusterTes
                 new SimpleClusterView(instance3),
                 new SimpleClusterView(instance4));
         assertSameTopology(new SimpleClusterView(instance1Restarted, instance2));
-        
+
         Thread.sleep(100);
         runHeartbeatOnceWith(instance1Restarted, instance2, instance3, instance4);
         pingConnector(instance3, instance4);
@@ -746,7 +747,7 @@ public abstract class AbstractClusterTes
         Thread.sleep(100);
         runHeartbeatOnceWith(instance1Restarted, instance2, instance3, instance4);
         pingConnector(instance3, instance4);
-        
+
         // now the situation should be as follows:
         logger.info("iteration 2");
         logger.info("instance1Restarted.slingId: "+instance1Restarted.slingId);
@@ -762,7 +763,7 @@ public abstract class AbstractClusterTes
 
         logger.info("testStaleInstanceIn3Clusters4139: end");
     }
-    
+
     /**
      * Preparation steps for SLING-4139 tests:
      * Creates two clusters: A: with instance1 and 2, B with instance 3
@@ -788,7 +789,7 @@ public abstract class AbstractClusterTes
         Thread.sleep(100);
         runHeartbeatOnceWith(instance1, instance2);
         assertSameClusterIds(instance1, instance2);
-        
+
         // now launch the remote instance
         instance3 = newBuilder().setDebugName("remoteInstance")
                 .newRepository("/var/discovery/implremote/", false)
@@ -807,7 +808,7 @@ public abstract class AbstractClusterTes
         assertEquals(0, instance2.getAnnouncementRegistry().listLocalIncomingAnnouncements().size());
         assertEquals(0, instance3.getAnnouncementRegistry().listLocalAnnouncements().size());
         assertEquals(0, instance3.getAnnouncementRegistry().listLocalIncomingAnnouncements().size());
-        
+
         // create a topology connector from instance3 to instance1
         // -> corresponds to starting to ping
         instance3.heartbeatsAndCheckView();
@@ -817,7 +818,7 @@ public abstract class AbstractClusterTes
         // make asserts on the topology
         instance1.dumpRepo();
         assertSameTopology(new SimpleClusterView(instance1, instance2), new SimpleClusterView(instance3));
-        
+
         // kill instance 1
         logger.info("instance1.slingId="+instance1.slingId);
         logger.info("instance2.slingId="+instance2.slingId);
@@ -842,7 +843,7 @@ public abstract class AbstractClusterTes
         instance3.getConfig().setViewCheckTimeout(Integer.MAX_VALUE /* no timeout */); // set instance3's heartbeatTimeout back to Integer.MAX_VALUE /* no timeout */
 		return instance1SlingId;
 	}
-    
+
     private void assertNotSameClusterIds(VirtualInstance... instances) throws UndefinedClusterViewException {
     	if (instances==null) {
     		fail("must not pass empty set of instances here");
@@ -998,12 +999,12 @@ public abstract class AbstractClusterTes
 //        statusDetails = null;
 	}
 
-	private Announcement ping(VirtualInstance to, final Announcement incomingTopologyAnnouncement) 
+	private Announcement ping(VirtualInstance to, final Announcement incomingTopologyAnnouncement)
 	        throws UndefinedClusterViewException {
 		final String slingId = to.slingId;
 		final ClusterViewService clusterViewService = to.getClusterViewService();
 		final AnnouncementRegistry announcementRegistry = to.getAnnouncementRegistry();
-		
+
 		incomingTopologyAnnouncement.removeInherited(slingId);
 
         final Announcement replyAnnouncement = new Announcement(
@@ -1034,6 +1035,7 @@ public abstract class AbstractClusterTes
                 announcementRegistry.addAllExcept(replyAnnouncement, clusterView,
                         new AnnouncementFilter() {
 
+                            @Override
                             public boolean accept(final String receivingSlingId, Announcement announcement) {
                                 if (announcement.getPrimaryKey().equals(
                                         incomingTopologyAnnouncement
@@ -1055,11 +1057,12 @@ public abstract class AbstractClusterTes
         final ClusterView clusterView = from.getClusterViewService().getLocalClusterView();
         topologyAnnouncement.setLocalCluster(clusterView);
         from.getAnnouncementRegistry().addAllExcept(topologyAnnouncement, clusterView, new AnnouncementFilter() {
-            
+
+            @Override
             public boolean accept(final String receivingSlingId, final Announcement announcement) {
                 // filter out announcements that are of old cluster instances
                 // which I dont really have in my cluster view at the moment
-                final Iterator<InstanceDescription> it = 
+                final Iterator<InstanceDescription> it =
                         clusterView.getInstances().iterator();
                 while(it.hasNext()) {
                     final InstanceDescription instance = it.next();
@@ -1119,18 +1122,18 @@ public abstract class AbstractClusterTes
         Thread.sleep(500);
         instance1.heartbeatsAndCheckView();
         instance2.heartbeatsAndCheckView();
-        
+
         String newClusterId1 = instance1.getClusterViewService()
                 .getLocalClusterView().getId();
         String newClusterId2 = instance2.getClusterViewService()
                 .getLocalClusterView().getId();
         // both cluster ids must be the same
         assertEquals(newClusterId1, newClusterId1);
-        
+
         instance1.dumpRepo();
         assertEquals(2, instance1.getClusterViewService().getLocalClusterView().getInstances().size());
         assertEquals(2, instance2.getClusterViewService().getLocalClusterView().getInstances().size());
-        
+
         // let instance2 'die' by now longer doing heartbeats
 	// SLING-4302 : then set the heartbeatTimeouts back to 1 sec to have them properly time out with the sleeps applied below
         instance2.getConfig().setViewCheckTimeout(1);
@@ -1168,7 +1171,7 @@ public abstract class AbstractClusterTes
 		assertEquals(newClusterId1, actualClusterId);
         logger.info("testStableClusterId: end");
     }
-    
+
     @Test
     public void testClusterView() throws Exception {
         logger.info("testClusterView: start");
@@ -1399,26 +1402,27 @@ public abstract class AbstractClusterTes
         throw new IllegalStateException("instance not found: instance="
                 + instance + ", slingId=" + slingId);
     }
-    
+
     class LongRunningListener implements TopologyEventListener {
-        
+
         String failMsg = null;
-        
+
         boolean initReceived = false;
         int noninitReceived;
 
         private Semaphore changedSemaphore = new Semaphore(0);
-        
+
         public void assertNoFail() {
             if (failMsg!=null) {
                 fail(failMsg);
             }
         }
-        
+
         public Semaphore getChangedSemaphore() {
             return changedSemaphore;
         }
-        
+
+        @Override
         public void handleTopologyEvent(TopologyEvent event) {
             if (failMsg!=null) {
                 failMsg += "/ Already failed, got another event; "+event;
@@ -1442,7 +1446,7 @@ public abstract class AbstractClusterTes
             noninitReceived++;
         }
     }
-    
+
     /**
      * Test plan:
      *  * have a discoveryservice with two listeners registered
@@ -1457,7 +1461,7 @@ public abstract class AbstractClusterTes
      *    and that the first listener is still busy, make
      *    sure that once the first listener finishes, that
      *    the second listener still gets the event
-     * @throws Throwable 
+     * @throws Throwable
      */
     @Category(Slow.class) //TODO: this takes env 15sec
     @Test
@@ -1475,7 +1479,7 @@ public abstract class AbstractClusterTes
         instance1.heartbeatsAndCheckView();
         logger.info("testLongRunningListener : instance 2 should now be considered dead");
 //        instance1.dumpRepo();
-        
+
         LongRunningListener longRunningListener1 = new LongRunningListener();
         AssertingTopologyEventListener fastListener2 = new AssertingTopologyEventListener();
         fastListener2.addExpected(Type.TOPOLOGY_INIT);
@@ -1489,7 +1493,7 @@ public abstract class AbstractClusterTes
         Thread.sleep(2500); // SLING-4755: async event sending requires some minimal wait time nowadays
         assertEquals(0, fastListener2.getRemainingExpectedCount());
         assertTrue(longRunningListener1.initReceived);
-        
+
         // after INIT, now do an actual change where listener1 will do a long-running handling
         fastListener2.addExpected(Type.TOPOLOGY_CHANGING);
         fastListener2.addExpected(Type.TOPOLOGY_CHANGED);
@@ -1504,7 +1508,7 @@ public abstract class AbstractClusterTes
         instance1.heartbeatsAndCheckView();
         instance2.heartbeatsAndCheckView();
         Thread.sleep(500);
-        
+
         instance1.dumpRepo();
         longRunningListener1.assertNoFail();
         // nothing unexpected should arrive at listener2:
@@ -1521,12 +1525,13 @@ public abstract class AbstractClusterTes
         assertEquals(1, fastListener2.getRemainingExpectedCount());
         assertEquals(1, longRunningListener1.noninitReceived);
         assertTrue(longRunningListener1.getChangedSemaphore().hasQueuedThreads());
-        
+
         // now let's simulate SLING-4755: deactivation while longRunningListener1 does long processing
         // - which is simulated by waiting on changedSemaphore.
         final List<Exception> asyncException = new LinkedList<Exception>();
         Thread th = new Thread(new Runnable() {
 
+            @Override
             public void run() {
                 try {
                     instance1.stop();
@@ -1536,7 +1541,7 @@ public abstract class AbstractClusterTes
                     }
                 }
             }
-            
+
         });
         th.start();
         logger.info("Waiting max 4 sec...");
@@ -1557,7 +1562,7 @@ public abstract class AbstractClusterTes
                 fail("async exceptions: "+asyncException.size()+", first: "+asyncException.get(0));
             }
         }
-        
+
         // now the test consists of
         // a) the fact that we reached this place without unlocking the changedSemaphore
         // b) when we now unlock the changedSemaphore the remaining events should flush through
@@ -1569,5 +1574,5 @@ public abstract class AbstractClusterTes
         assertFalse(longRunningListener1.getChangedSemaphore().hasQueuedThreads());
     }
 
-    
+
 }

Modified: sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/AbstractSingleInstanceTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/AbstractSingleInstanceTest.java?rev=1769802&r1=1769801&r2=1769802&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/AbstractSingleInstanceTest.java (original)
+++ sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/AbstractSingleInstanceTest.java Tue Nov 15 12:38:35 2016
@@ -30,7 +30,7 @@ import java.util.Map;
 import java.util.UUID;
 
 import org.apache.log4j.Level;
-import org.apache.log4j.LogManager;
+import org.apache.log4j.spi.RootLogger;
 import org.apache.sling.discovery.ClusterView;
 import org.apache.sling.discovery.InstanceDescription;
 import org.apache.sling.discovery.TopologyEvent;
@@ -55,12 +55,12 @@ public abstract class AbstractSingleInst
     String propertyValue;
 
     private Level logLevel;
-    
+
     protected abstract VirtualInstanceBuilder newBuilder();
 
     @Before
     public void setup() throws Exception {
-        final org.apache.log4j.Logger discoveryLogger = LogManager.getRootLogger().getLogger("org.apache.sling.discovery");
+        final org.apache.log4j.Logger discoveryLogger = RootLogger.getLogger("org.apache.sling.discovery");
         logLevel = discoveryLogger.getLevel();
         discoveryLogger.setLevel(Level.DEBUG);
         logger.info("setup: creating new standalone instance");
@@ -74,7 +74,7 @@ public abstract class AbstractSingleInst
 
     @After
     public void tearDown() throws Exception {
-        final org.apache.log4j.Logger discoveryLogger = LogManager.getRootLogger().getLogger("org.apache.sling.discovery");
+        final org.apache.log4j.Logger discoveryLogger = RootLogger.getLogger("org.apache.sling.discovery");
         discoveryLogger.setLevel(logLevel);
         logger.info("tearDown: stopping standalone instance");
         if (instance!=null) {
@@ -99,7 +99,7 @@ public abstract class AbstractSingleInst
         instance.heartbeatsAndCheckView();
         // wait 4000ms for the vote to happen
         Thread.sleep(4000);
-        
+
         assertNotNull(instance.getClusterViewService().getLocalClusterView());
         ClusterView cv = instance.getClusterViewService().getLocalClusterView();
         logger.info("cluster view: id=" + cv.getId());
@@ -155,14 +155,14 @@ public abstract class AbstractSingleInst
                 .getProperty(UUID.randomUUID().toString()));
         logger.info("testPropertyProviders: end");
     }
-    
+
     @Test
     public void testInvalidProperties() throws Throwable {
         logger.info("testInvalidProperties: start");
-        
+
         instance.heartbeatsAndCheckView();
         instance.heartbeatsAndCheckView();
-        
+
         final String propertyValue = UUID.randomUUID().toString();
         Thread.sleep(2000);
         doTestProperty(UUID.randomUUID().toString(), propertyValue, propertyValue);
@@ -187,7 +187,7 @@ public abstract class AbstractSingleInst
                 instance.getClusterViewService().getLocalClusterView()
                         .getInstances().get(0).getProperty(propertyName));
 	}
-    
+
     @Test
     public void testTopologyEventListeners() throws Throwable {
         logger.info("testTopologyEventListeners: start");
@@ -270,7 +270,7 @@ public abstract class AbstractSingleInst
         } catch(UndefinedClusterViewException e) {
             // ok
         }
-        
+
         ada.addExpected(Type.TOPOLOGY_INIT);
         instance.heartbeatsAndCheckView();
         Thread.sleep(1000);
@@ -292,5 +292,5 @@ public abstract class AbstractSingleInst
         instance.assertEstablishedView();
         logger.info("testBootstrap: end");
     }
-    
+
 }

Modified: sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/AbstractTopologyEventTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/AbstractTopologyEventTest.java?rev=1769802&r1=1769801&r2=1769802&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/AbstractTopologyEventTest.java (original)
+++ sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/AbstractTopologyEventTest.java Tue Nov 15 12:38:35 2016
@@ -24,7 +24,7 @@ import static org.junit.Assert.assertNot
 import static org.junit.Assert.assertTrue;
 
 import org.apache.log4j.Level;
-import org.apache.log4j.LogManager;
+import org.apache.log4j.spi.RootLogger;
 import org.apache.sling.discovery.TopologyEvent;
 import org.apache.sling.discovery.TopologyEvent.Type;
 import org.apache.sling.discovery.TopologyView;
@@ -33,7 +33,6 @@ import org.apache.sling.discovery.base.i
 import org.apache.sling.discovery.base.its.setup.mock.AssertingTopologyEventListener;
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -50,14 +49,14 @@ public abstract class AbstractTopologyEv
     private VirtualInstance instance2;
 
     private Level logLevel;
-    
+
     @Before
     public void setup() throws Exception {
-        final org.apache.log4j.Logger discoveryLogger = LogManager.getRootLogger().getLogger("org.apache.sling.discovery");
+        final org.apache.log4j.Logger discoveryLogger = RootLogger.getLogger("org.apache.sling.discovery");
         logLevel = discoveryLogger.getLevel();
         discoveryLogger.setLevel(Level.DEBUG);
     }
-    
+
     @After
     public void tearDown() throws Throwable {
         if (instance1!=null) {
@@ -70,16 +69,16 @@ public abstract class AbstractTopologyEv
             instance2.stop();
             instance2 = null;
         }
-        final org.apache.log4j.Logger discoveryLogger = LogManager.getRootLogger().getLogger("org.apache.sling.discovery");
+        final org.apache.log4j.Logger discoveryLogger = RootLogger.getLogger("org.apache.sling.discovery");
         discoveryLogger.setLevel(logLevel);
     }
-    
+
     public abstract VirtualInstanceBuilder newBuilder();
-    
+
     /**
      * Tests the fact that the INIT event is delayed until voting has succeeded
      * (which is the default with SLIGN-5030 and SLING-4959
-     * @throws Throwable 
+     * @throws Throwable
      */
     @Test
     public void testDelayedInitEvent() throws Throwable {
@@ -92,7 +91,7 @@ public abstract class AbstractTopologyEv
         l1.addExpected(Type.TOPOLOGY_INIT);
         instance1.bindTopologyEventListener(l1);
         logger.info("testDelayedInitEvent: instance1 created, no events expected yet. slingId="+instance1.slingId);
-        
+
         instance1.heartbeatsAndCheckView();
         Thread.sleep(1200);
         instance1.heartbeatsAndCheckView();
@@ -104,7 +103,7 @@ public abstract class AbstractTopologyEv
         assertEquals(1, l1.getEvents().size()); // one event
         assertEquals(0, l1.getRemainingExpectedCount()); // the expected one
         assertEquals(0, l1.getUnexpectedCount());
-        
+
         logger.info("testDelayedInitEvent: creating instance2");
         instance2 = newBuilder().setDebugName("secondInstanceB")
                 .useRepositoryOf(instance1)
@@ -118,10 +117,10 @@ public abstract class AbstractTopologyEv
         l1Two.addExpected(Type.TOPOLOGY_INIT);
         logger.info("testDelayedInitEvent: listener instance1.l1Two added - it expects an INIT now");
         instance1.bindTopologyEventListener(l1Two);
-        
+
         Thread.sleep(500); // SLING-4755: async event sending requires some minimal wait time nowadays
 
-        // just because instance2 is started doesn't kick off any events yet 
+        // just because instance2 is started doesn't kick off any events yet
         // since instance2 didn't send heartbeats yet
         assertEquals(1, l1.getEvents().size()); // one event
         assertEquals(0, l1.getRemainingExpectedCount()); // the expected one
@@ -131,8 +130,8 @@ public abstract class AbstractTopologyEv
         assertEquals(1, l1Two.getEvents().size());
         assertEquals(0, l1Two.getRemainingExpectedCount()); // the expected one
         assertEquals(0, l1Two.getUnexpectedCount());
-        
-        
+
+
         // the second & third heartbeat though triggers the voting etc
         logger.info("testDelayedInitEvent: two more heartbeats should trigger events");
         l1.addExpected(Type.TOPOLOGY_CHANGING);
@@ -174,7 +173,7 @@ public abstract class AbstractTopologyEv
         assertEquals(3, l1Two.getEvents().size());
         logger.info("testDelayedInitEvent: end");
     }
-    
+
     @Test
     public void testGetDuringDelay() throws Throwable {
         instance1 = newBuilder().setDebugName("firstInstanceA")
@@ -184,12 +183,12 @@ public abstract class AbstractTopologyEv
         AssertingTopologyEventListener l1 = new AssertingTopologyEventListener("instance1.l1");
         l1.addExpected(TopologyEvent.Type.TOPOLOGY_INIT);
         instance1.bindTopologyEventListener(l1);
-        
+
         TopologyView earlyTopo = instance1.getDiscoveryService().getTopology();
         assertNotNull(earlyTopo);
         assertFalse(earlyTopo.isCurrent());
         assertEquals(1, earlyTopo.getInstances().size());
-        
+
         for(int i=0; i<4; i++) {
             instance1.heartbeatsAndCheckView();
             Thread.sleep(125);
@@ -199,14 +198,14 @@ public abstract class AbstractTopologyEv
         assertEquals(instance1.getSlingId(), secondTopo.getInstances().iterator().next().getSlingId());
         assertTrue(secondTopo.isCurrent());
         instance1.dumpRepo();
-        
+
         assertEarlyAndFirstClusterViewIdMatches(earlyTopo, secondTopo);
 
         Thread.sleep(500);
         // should have gotten the INIT, hence 0 remaining expected events
         assertEquals(0, l1.getRemainingExpectedCount());
         assertEquals(0, l1.getUnexpectedCount());
-        
+
         l1.addExpected(TopologyEvent.Type.TOPOLOGY_CHANGING);
         instance2 = newBuilder().setDebugName("secondInstanceB")
                 .useRepositoryOf(instance1)
@@ -221,7 +220,7 @@ public abstract class AbstractTopologyEv
             instance1.heartbeatsAndCheckView();
             Thread.sleep(750);
         }
-        
+
         assertEquals(0, l1.getUnexpectedCount());
         TopologyView topo2 = instance2.getDiscoveryService().getTopology();
         assertTrue(topo2.isCurrent());
@@ -229,7 +228,7 @@ public abstract class AbstractTopologyEv
         TopologyView topo1 = instance1.getDiscoveryService().getTopology();
         assertTrue(topo1.isCurrent());
         assertEquals(2, topo1.getInstances().size());
-        
+
         l1.addExpected(TopologyEvent.Type.TOPOLOGY_CHANGED);
         Thread.sleep(5000);
         assertEquals(0, l1.getRemainingExpectedCount());
@@ -243,5 +242,5 @@ public abstract class AbstractTopologyEv
     }
 
     public abstract void assertEarlyAndFirstClusterViewIdMatches(TopologyView earlyTopo, TopologyView secondTopo);
-    
+
 }
\ No newline at end of file

Modified: sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/setup/VirtualInstance.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/setup/VirtualInstance.java?rev=1769802&r1=1769801&r2=1769802&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/setup/VirtualInstance.java (original)
+++ sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/setup/VirtualInstance.java Tue Nov 15 12:38:35 2016
@@ -118,12 +118,13 @@ public class VirtualInstance {
 			stopping_ = true;
 			this.notifyAll();
 		}
-		
+
 		public boolean hasStopped() {
 		    return stopped_;
 		}
 
-		public void run() {
+		@Override
+        public void run() {
 		    try{
 		        doRun();
 		    } finally {
@@ -131,7 +132,7 @@ public class VirtualInstance {
                 logger.info("Instance ["+slingId+"] stopped.");
 		    }
 		}
-		
+
 		public void doRun() {
 			while(true) {
 				synchronized(this) {
@@ -157,7 +158,7 @@ public class VirtualInstance {
 		}
 
     }
-    
+
     public VirtualInstance(VirtualInstanceBuilder builder) throws Exception {
         this.builder = builder;
     	this.slingId = builder.getSlingId();
@@ -187,7 +188,7 @@ public class VirtualInstance {
         osgiMock.addServices(builder.getAdditionalServices(this));
 
         resourceResolver = resourceResolverFactory
-                .getAdministrativeResourceResolver(null);
+                .getServiceResourceResolver(null);
 
         if (builder.isResetRepo()) {
             //SLING-4587 : do resetRepo before creating the observationListener
@@ -199,11 +200,11 @@ public class VirtualInstance {
 
         osgiMock.activateAll();
     }
-    
+
     public void setDelay(String operationDescriptor, long delayMillis) {
         delay.setDelay(operationDescriptor, delayMillis);
     }
-    
+
     @Override
     public String toString() {
         return "a [Test]Instance[slingId="+slingId+", debugName="+debugName+"]";
@@ -357,7 +358,7 @@ public class VirtualInstance {
     public void dumpRepo() throws Exception {
         VirtualInstanceHelper.dumpRepo(resourceResolverFactory);
     }
-    
+
     public ResourceResolverFactory getResourceResolverFactory() {
         return resourceResolverFactory;
     }

Modified: sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/setup/VirtualInstanceHelper.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/setup/VirtualInstanceHelper.java?rev=1769802&r1=1769801&r2=1769802&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/setup/VirtualInstanceHelper.java (original)
+++ sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/setup/VirtualInstanceHelper.java Tue Nov 15 12:38:35 2016
@@ -36,15 +36,15 @@ public class VirtualInstanceHelper {
 
     public static void dumpRepo(ResourceResolverFactory resourceResolverFactory) throws Exception {
         Session session = resourceResolverFactory
-                .getAdministrativeResourceResolver(null).adaptTo(Session.class);
+                .getServiceResourceResolver(null).adaptTo(Session.class);
         logger.info("dumpRepo: ====== START =====");
         logger.info("dumpRepo: repo = " + session.getRepository());
-    
+
         dump(session.getRootNode());
-    
+
         // session.logout();
         logger.info("dumpRepo: ======  END  =====");
-    
+
         session.logout();
     }
 
@@ -54,7 +54,7 @@ public class VirtualInstanceHelper {
             // ignore that one
             return;
         }
-    
+
         PropertyIterator pi = node.getProperties();
         StringBuilder sb = new StringBuilder();
         while (pi.hasNext()) {
@@ -72,7 +72,7 @@ public class VirtualInstanceHelper {
                 sb.append("<unknown type=" + p.getType() + "/>");
             }
         }
-    
+
         StringBuffer depth = new StringBuffer();
         for(int i=0; i<node.getDepth(); i++) {
             depth.append(" ");

Modified: sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/setup/mock/DummyResourceResolverFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/setup/mock/DummyResourceResolverFactory.java?rev=1769802&r1=1769801&r2=1769802&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/setup/mock/DummyResourceResolverFactory.java (original)
+++ sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/setup/mock/DummyResourceResolverFactory.java Tue Nov 15 12:38:35 2016
@@ -38,26 +38,40 @@ public class DummyResourceResolverFactor
     private ArtificialDelay delay;
 
     public DummyResourceResolverFactory() {
-        
+
     }
-    
+
     public void setSlingRepository(SlingRepository repository) {
         this.repository = repository;
     }
-    
+
     public void setArtificialDelay(ArtificialDelay delay) {
         this.delay = delay;
     }
-    
+
     @Override
     public ResourceResolver getResourceResolver(Map<String, Object> authenticationInfo) throws LoginException {
         throw new IllegalStateException("not yet implemented");
     }
 
+
+    @Override
+    public ResourceResolver getServiceResourceResolver(Map<String, Object> arg0) throws LoginException {
+        try {
+            MockedResourceResolver mockedResourceResolver =
+                    new MockedResourceResolver(repository, delay);
+            repository = (SlingRepository) mockedResourceResolver.getRepository();
+            return mockedResourceResolver;
+        } catch (RepositoryException e) {
+            throw new LoginException(e);
+        }
+    }
+
     @Override
+    @Deprecated
     public ResourceResolver getAdministrativeResourceResolver(Map<String, Object> authenticationInfo) throws LoginException {
         try {
-            MockedResourceResolver mockedResourceResolver = 
+            MockedResourceResolver mockedResourceResolver =
                     new MockedResourceResolver(repository, delay);
             repository = (SlingRepository) mockedResourceResolver.getRepository();
             return mockedResourceResolver;

Modified: sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/setup/mock/DummyViewChecker.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/setup/mock/DummyViewChecker.java?rev=1769802&r1=1769801&r2=1769802&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/setup/mock/DummyViewChecker.java (original)
+++ sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/setup/mock/DummyViewChecker.java Tue Nov 15 12:38:35 2016
@@ -18,7 +18,6 @@
  */
 package org.apache.sling.discovery.base.its.setup.mock;
 
-import org.apache.felix.scr.annotations.Reference;
 import org.apache.sling.api.resource.ResourceResolverFactory;
 import org.apache.sling.commons.scheduler.Scheduler;
 import org.apache.sling.discovery.base.commons.BaseViewChecker;
@@ -28,7 +27,7 @@ import org.apache.sling.discovery.base.c
 import org.apache.sling.settings.SlingSettingsService;
 
 public class DummyViewChecker extends BaseViewChecker {
-    
+
     protected SlingSettingsService slingSettingsService;
 
     protected ResourceResolverFactory resourceResolverFactory;

Modified: sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockedResourceResolver.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockedResourceResolver.java?rev=1769802&r1=1769801&r2=1769802&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockedResourceResolver.java (original)
+++ sling/trunk/bundles/extensions/discovery/base/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockedResourceResolver.java Tue Nov 15 12:38:35 2016
@@ -44,13 +44,10 @@ import org.apache.sling.api.resource.Res
 import org.apache.sling.commons.testing.jcr.RepositoryProvider;
 import org.apache.sling.commons.testing.jcr.RepositoryUtil;
 import org.apache.sling.jcr.api.SlingRepository;
-import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class MockedResourceResolver implements ResourceResolver {
 
-    private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
     private final SlingRepository repository;
 
 	private Session session;
@@ -66,7 +63,7 @@ public class MockedResourceResolver impl
     public MockedResourceResolver(SlingRepository repositoryOrNull) throws RepositoryException {
         this(repositoryOrNull, null);
     }
-    
+
     public MockedResourceResolver(SlingRepository repositoryOrNull, ArtificialDelay delay) throws RepositoryException {
         this.delay = delay;
     	if (repositoryOrNull==null) {
@@ -108,6 +105,7 @@ public class MockedResourceResolver impl
     }
 
 
+    @Override
     @SuppressWarnings("unchecked")
     public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
         if (type.equals(Session.class)) {
@@ -122,27 +120,33 @@ public class MockedResourceResolver impl
         throw new UnsupportedOperationException("Not implemented");
     }
 
+    @Override
     public Resource resolve(HttpServletRequest request, String absPath) {
         throw new UnsupportedOperationException("Not implemented");
     }
 
+    @Override
     public Resource resolve(String absPath) {
         throw new UnsupportedOperationException("Not implemented");
     }
 
+    @Override
     @Deprecated
     public Resource resolve(HttpServletRequest request) {
         throw new UnsupportedOperationException("Not implemented");
     }
 
+    @Override
     public String map(String resourcePath) {
         throw new UnsupportedOperationException("Not implemented");
     }
 
+    @Override
     public String map(HttpServletRequest request, String resourcePath) {
         throw new UnsupportedOperationException("Not implemented");
     }
 
+    @Override
     public Resource getResource(String path) {
         Session session;
         try {
@@ -156,6 +160,7 @@ public class MockedResourceResolver impl
         return new MockedResource(this, path, "nt:unstructured");
     }
 
+    @Override
     public Resource getResource(Resource base, String path) {
         if (base.getPath().equals("/")) {
             return getResource("/" + path);
@@ -164,20 +169,24 @@ public class MockedResourceResolver impl
         }
     }
 
+    @Override
     public String[] getSearchPath() {
         throw new UnsupportedOperationException("Not implemented");
     }
 
+    @Override
     public Iterator<Resource> listChildren(Resource parent) {
         try {
             Node node = parent.adaptTo(Node.class);
             final NodeIterator nodes = node.getNodes();
             return new Iterator<Resource>() {
 
+                @Override
                 public void remove() {
                     throw new UnsupportedOperationException();
                 }
 
+                @Override
                 public Resource next() {
                     Node next = nodes.nextNode();
                     try {
@@ -189,6 +198,7 @@ public class MockedResourceResolver impl
                     }
                 }
 
+                @Override
                 public boolean hasNext() {
                     return nodes.hasNext();
                 }
@@ -198,28 +208,34 @@ public class MockedResourceResolver impl
         }
     }
 
+    @Override
     public Iterable<Resource> getChildren(Resource parent) {
         throw new UnsupportedOperationException("Not implemented");
     }
 
+    @Override
     public Iterator<Resource> findResources(String query, String language) {
         throw new UnsupportedOperationException("Not implemented");
     }
 
+    @Override
     public Iterator<Map<String, Object>> queryResources(String query,
             String language) {
         throw new UnsupportedOperationException("Not implemented");
     }
 
+    @Override
     public ResourceResolver clone(Map<String, Object> authenticationInfo)
             throws LoginException {
         throw new UnsupportedOperationException("Not implemented");
     }
 
+    @Override
     public boolean isLive() {
         throw new UnsupportedOperationException("Not implemented");
     }
 
+    @Override
     public void close() {
         Iterator<MockedResource> it = resources.iterator();
         while (it.hasNext()) {
@@ -238,18 +254,22 @@ public class MockedResourceResolver impl
         resources.add(mockedResource);
     }
 
+    @Override
     public String getUserID() {
         throw new UnsupportedOperationException("Not implemented");
     }
 
+    @Override
     public Iterator<String> getAttributeNames() {
         throw new UnsupportedOperationException("Not implemented");
     }
 
+    @Override
     public Object getAttribute(String name) {
         throw new UnsupportedOperationException("Not implemented");
     }
 
+    @Override
     public void delete(Resource resource) throws PersistenceException {
         if (resources.contains(resource)) {
             resources.remove(resource);
@@ -264,6 +284,7 @@ public class MockedResourceResolver impl
         }
     }
 
+    @Override
     public Resource create(Resource parent, String name,
             Map<String, Object> properties) throws PersistenceException {
         final Node parentNode = parent.adaptTo(Node.class);
@@ -305,6 +326,7 @@ public class MockedResourceResolver impl
         }
     }
 
+    @Override
     public void revert() {
         try {
             this.session.refresh(false);
@@ -313,6 +335,7 @@ public class MockedResourceResolver impl
         }
     }
 
+    @Override
     public void commit() throws PersistenceException {
         if (delay!=null) {
             delay.delay("pre.commit");
@@ -324,28 +347,39 @@ public class MockedResourceResolver impl
         }
     }
 
+    @Override
     public boolean hasChanges() {
         throw new UnsupportedOperationException("Not implemented");
     }
 
+    @Override
     public String getParentResourceType(Resource resource) {
         // TODO Auto-generated method stub
         return null;
     }
 
+    @Override
     public String getParentResourceType(String resourceType) {
         // TODO Auto-generated method stub
         return null;
     }
 
+    @Override
     public boolean isResourceType(Resource resource, String resourceType) {
         // TODO Auto-generated method stub
         return false;
     }
 
+    @Override
     public void refresh() {
         // TODO Auto-generated method stub
 
     }
 
+    @Override
+    public boolean hasChildren(Resource arg0) {
+        // TODO Auto-generated method stub
+        return this.getChildren(arg0).iterator().hasNext();
+    }
+
 }

Modified: sling/trunk/bundles/extensions/discovery/commons/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/IdMapService.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/commons/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/IdMapService.java?rev=1769802&r1=1769801&r2=1769802&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/commons/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/IdMapService.java (original)
+++ sling/trunk/bundles/extensions/discovery/commons/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/IdMapService.java Tue Nov 15 12:38:35 2016
@@ -48,7 +48,6 @@ import org.apache.sling.settings.SlingSe
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.event.Event;
 
 /**
  * The IdMapService is responsible for storing a slingId-clusterNodeId
@@ -67,9 +66,9 @@ public class IdMapService extends Abstra
 
     @Reference
     private DiscoveryLiteConfig commonsConfig;
-    
+
     private boolean initialized = false;
-    
+
     private String slingId;
 
     private long me;
@@ -100,9 +99,9 @@ public class IdMapService extends Abstra
     protected void activate(BundleContext bundleContext) {
         this.bundleContext = bundleContext;
         registerEventHandler();
-        
+
         startBackgroundCheck("IdMapService-initializer", new BackgroundCheck() {
-            
+
             @Override
             public boolean check() {
                 try {
@@ -114,7 +113,7 @@ public class IdMapService extends Abstra
             }
         }, null, -1, 1000 /* = 1sec interval */);
     }
-    
+
     @Deactivate
     protected void deactivate() {
         if (eventHandlerRegistration != null) {
@@ -124,7 +123,7 @@ public class IdMapService extends Abstra
         // SLING-5592: cancel the potentially running background thread
         cancelPreviousBackgroundCheck();
     }
-    
+
     private void registerEventHandler() {
         if (bundleContext == null) {
             logger.info("registerEventHandler: bundleContext is null - cannot register");
@@ -146,16 +145,16 @@ public class IdMapService extends Abstra
 
     /** Get or create a ResourceResolver **/
     private ResourceResolver getResourceResolver() throws LoginException {
-        return resourceResolverFactory.getAdministrativeResourceResolver(null);
+        return resourceResolverFactory.getServiceResourceResolver(null);
     }
-    
+
     public synchronized long getMyId() {
         if (!initialized) {
             return -1;
         }
         return me;
     }
-    
+
     /** for testing only **/
     public synchronized boolean waitForInit(long timeout) {
         long start = System.currentTimeMillis();
@@ -176,7 +175,7 @@ public class IdMapService extends Abstra
         }
         return initialized;
     }
-    
+
     public synchronized boolean isInitialized() {
         return initialized;
     }
@@ -189,7 +188,7 @@ public class IdMapService extends Abstra
         ResourceResolver resourceResolver = null;
         try{
             resourceResolver = getResourceResolver();
-            DiscoveryLiteDescriptor descriptor = 
+            DiscoveryLiteDescriptor descriptor =
                     DiscoveryLiteDescriptor.getDescriptorFrom(resourceResolver);
             long me = descriptor.getMyId();
             final Resource resource = ResourceHelper.getOrCreateResource(resourceResolver, getIdMapPath());
@@ -242,9 +241,9 @@ public class IdMapService extends Abstra
                 resourceResolver.close();
             }
         }
-        
+
     }
-    
+
     public synchronized void clearCache() {
         if (!idMapCache.isEmpty()) {
             logger.debug("clearCache: clearing idmap cache");
@@ -265,7 +264,7 @@ public class IdMapService extends Abstra
             // force a cache invalidation).
             // we can either rely on observation - or combine that with
             // an invalidation of once per minute
-            // (note that this means we'll be reading 
+            // (note that this means we'll be reading
             // /var/discovery/oak/idMap once per minute - but that sounds
             // perfectly fine)
             clearCache();
@@ -294,10 +293,10 @@ public class IdMapService extends Abstra
                 logger.info("toSlingId: mapping for "+oldEntry.getKey()+" to "+oldEntry.getValue()+" disappeared.");
             }
         }
-        
+
         return idMapCache.get(clusterNodeId);
     }
-    
+
     private Map<Integer, String> readIdMap(ResourceResolver resourceResolver) throws PersistenceException {
         Resource resource = ResourceHelper.getOrCreateResource(resourceResolver, getIdMapPath());
         ValueMap idmapValueMap = resource.adaptTo(ValueMap.class);

Modified: sling/trunk/bundles/extensions/discovery/commons/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/OakBacklogClusterSyncService.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/commons/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/OakBacklogClusterSyncService.java?rev=1769802&r1=1769801&r2=1769802&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/commons/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/OakBacklogClusterSyncService.java (original)
+++ sling/trunk/bundles/extensions/discovery/commons/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/OakBacklogClusterSyncService.java Tue Nov 15 12:38:35 2016
@@ -50,10 +50,10 @@ public class OakBacklogClusterSyncServic
         HAS_BACKLOG /* when oak's discovery lite descriptor indicated that there is still some backlog */,
         NO_BACKLOG /* when oak's discovery lite descriptor declared we're backlog-free now */
     }
-    
+
     @Reference
     private IdMapService idMapService;
-    
+
     @Reference
     protected DiscoveryLiteConfig commonsConfig;
 
@@ -64,7 +64,7 @@ public class OakBacklogClusterSyncServic
     protected SlingSettingsService settingsService;
 
     private ClusterSyncHistory consistencyHistory = new ClusterSyncHistory();
-    
+
     public static OakBacklogClusterSyncService testConstructorAndActivate(
             final DiscoveryLiteConfig commonsConfig,
             final IdMapService idMapService,
@@ -74,7 +74,7 @@ public class OakBacklogClusterSyncServic
         service.activate();
         return service;
     }
-    
+
     /**
      * for testing only!
      * @param resourceResolverFactory
@@ -82,7 +82,7 @@ public class OakBacklogClusterSyncServic
      * @param syncTokenTimeoutMillis timeout value in millis after which the
      * sync-token process is cancelled - or -1 if no timeout should be used there
      * @param backlogWaitTimeoutMillis timeout value in millis after which
-     * the waiting-while-backlog should be cancelled - or -1 if no timeout should be 
+     * the waiting-while-backlog should be cancelled - or -1 if no timeout should be
      * used there
      * @throws LoginException when the login for initialization failed
      * @throws JSONException when the descriptor wasn't proper json at init time
@@ -108,26 +108,26 @@ public class OakBacklogClusterSyncServic
         service.settingsService = settingsService;
         return service;
     }
-    
+
     @Activate
     protected void activate() {
         this.slingId = getSettingsService().getSlingId();
         logger.info("activate: activated with slingId="+slingId);
     }
-    
+
     public void setConsistencyHistory(ClusterSyncHistory consistencyHistory) {
         this.consistencyHistory = consistencyHistory;
     }
-    
+
     public ClusterSyncHistory getConsistencyHistory() {
         return consistencyHistory;
     }
-    
+
     /** Get or create a ResourceResolver **/
     protected ResourceResolver getResourceResolver() throws LoginException {
-        return resourceResolverFactory.getAdministrativeResourceResolver(null);
+        return resourceResolverFactory.getServiceResourceResolver(null);
     }
-    
+
     @Override
     public void cancelSync() {
         cancelPreviousBackgroundCheck();
@@ -144,10 +144,10 @@ public class OakBacklogClusterSyncServic
     }
 
     private void waitWhileBacklog(final BaseTopologyView view, final Runnable runnable) {
-        // start backgroundChecking until the backlogStatus 
+        // start backgroundChecking until the backlogStatus
         // is NO_BACKLOG
         startBackgroundCheck("OakBacklogClusterSyncService-backlog-waiting", new BackgroundCheck() {
-            
+
             @Override
             public boolean check() {
                 try {
@@ -176,37 +176,37 @@ public class OakBacklogClusterSyncServic
             }
         }, runnable, getCommonsConfig().getClusterSyncServiceTimeoutMillis(), getCommonsConfig().getClusterSyncServiceIntervalMillis());
     }
-    
+
     private BacklogStatus getBacklogStatus(BaseTopologyView view) {
         logger.trace("getBacklogStatus: start");
         ResourceResolver resourceResolver = null;
         try{
             resourceResolver = getResourceResolver();
-            DiscoveryLiteDescriptor descriptor = 
+            DiscoveryLiteDescriptor descriptor =
                     DiscoveryLiteDescriptor.getDescriptorFrom(resourceResolver);
 
             // backlog-free means:
-            // 1) 'deactivating' must be empty 
+            // 1) 'deactivating' must be empty
             //     (otherwise we indeed have a backlog)
             // 2) all active ids of the descriptor must have a mapping to slingIds
             //     (otherwise the init failed or is pending for some instance(s))
-            // 3) all 'active' instances must be in the view 
-            //     (otherwise discovery lite might not yet consider 
+            // 3) all 'active' instances must be in the view
+            //     (otherwise discovery lite might not yet consider
             //     an instance dead but discovery-service does)
             // instead what is fine from a backlog point of view
             // * instances in the view but listed as 'inactive'
             //     (this might be the case for just-started instances)
             // * instances in the view but not contained in the descriptor at all
             //     (this might be the case for just-started instances)
-            
+
             int[] activeIds = descriptor.getActiveIds();
             int[] deactivatingIds = descriptor.getDeactivatingIds();
             // we're not worried about 'inactive' ones - as that could
             // be a larger list filled with legacy entries too
-            // plus once the instance is inactive there's no need to 
+            // plus once the instance is inactive there's no need to
             // check anything further - that one is then backlog-free
-            
-            // 1) 'deactivating' must be empty 
+
+            // 1) 'deactivating' must be empty
             if (deactivatingIds.length!=0) {
                 logger.info("getBacklogStatus: there are deactivating instances: "+Arrays.toString(deactivatingIds));
                 return BacklogStatus.HAS_BACKLOG;
@@ -217,7 +217,7 @@ public class OakBacklogClusterSyncServic
             for (InstanceDescription instance : cluster.getInstances()) {
                 slingIds.add(instance.getSlingId());
             }
-            
+
             for(int i=0; i<activeIds.length; i++) {
                 int activeId = activeIds[i];
                 String slingId = idMapService.toSlingId(activeId, resourceResolver);