incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stefane...@apache.org
Subject svn commit: r1510397 - in /sling/trunk/bundles/extensions/discovery/impl: pom.xml src/main/java/org/apache/sling/discovery/impl/common/heartbeat/HeartbeatHandler.java
Date Mon, 05 Aug 2013 08:58:01 GMT
Author: stefanegli
Date: Mon Aug  5 08:58:01 2013
New Revision: 1510397

URL: http://svn.apache.org/r1510397
Log:
SLING-2968 : issue remote heartbeat calls only after startup has finished - using startuplistener
for that. RTC not needed. only added launchpad.api dependency to pom.xml.

Modified:
    sling/trunk/bundles/extensions/discovery/impl/pom.xml
    sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/common/heartbeat/HeartbeatHandler.java

Modified: sling/trunk/bundles/extensions/discovery/impl/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/impl/pom.xml?rev=1510397&r1=1510396&r2=1510397&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/impl/pom.xml (original)
+++ sling/trunk/bundles/extensions/discovery/impl/pom.xml Mon Aug  5 08:58:01 2013
@@ -185,5 +185,11 @@
             <version>1.0.2</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+                <groupId>org.apache.sling</groupId>
+                <artifactId>org.apache.sling.launchpad.api</artifactId>
+                <version>1.1.0</version>
+                <type>bundle</type>
+        </dependency>
     </dependencies>
 </project>

Modified: sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/common/heartbeat/HeartbeatHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/common/heartbeat/HeartbeatHandler.java?rev=1510397&r1=1510396&r2=1510397&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/common/heartbeat/HeartbeatHandler.java
(original)
+++ sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/common/heartbeat/HeartbeatHandler.java
Mon Aug  5 08:58:01 2013
@@ -46,6 +46,8 @@ import org.apache.sling.discovery.impl.c
 import org.apache.sling.discovery.impl.common.resource.ResourceHelper;
 import org.apache.sling.discovery.impl.topology.announcement.AnnouncementRegistry;
 import org.apache.sling.discovery.impl.topology.connector.ConnectorRegistry;
+import org.apache.sling.launchpad.api.StartupListener;
+import org.apache.sling.launchpad.api.StartupMode;
 import org.apache.sling.settings.SlingSettingsService;
 import org.osgi.framework.BundleException;
 import org.osgi.service.component.ComponentContext;
@@ -60,8 +62,8 @@ import org.slf4j.LoggerFactory;
  * remote TopologyConnectorServlets.
  */
 @Component
-@Service(value = { HeartbeatHandler.class })
-public class HeartbeatHandler implements Runnable {
+@Service(value = { HeartbeatHandler.class, StartupListener.class })
+public class HeartbeatHandler implements Runnable, StartupListener {
 
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
@@ -119,6 +121,26 @@ public class HeartbeatHandler implements
     /** keep a reference to the component context **/
     private ComponentContext context;
     
+    /** SLING-2968 : start issuing remote heartbeats only after startup finished **/
+    private boolean startupFinished = false;
+    
+    public void inform(StartupMode mode, boolean finished) {
+    	if (finished) {
+    		startupFinished(mode);
+    	}
+    }
+
+    public void startupFinished(StartupMode mode) {
+    	synchronized(lock) {
+    		startupFinished = true;
+    		issueHeartbeat();
+    	}
+    }
+    
+    public void startupProgress(float ratio) {
+    	// we dont care
+    }
+    
     @Activate
     protected void activate(ComponentContext context) {
     	synchronized(lock) {
@@ -237,6 +259,10 @@ public class HeartbeatHandler implements
             logger.error("issueRemoteHeartbeats: connectorRegistry is null");
             return;
         }
+        if (!startupFinished) {
+        	logger.debug("issueRemoteHeartbeats: not issuing remote heartbeat yet, startup not
yet finished");
+        	return;
+        }
         connectorRegistry.pingOutgoingConnectors();
     }
 



Mime
View raw message