incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r689045 - in /incubator/sling/trunk: jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractSlingRepository.java launchpad/app/pom.xml launchpad/jcrapp/pom.xml
Date Tue, 26 Aug 2008 12:20:45 GMT
Author: bdelacretaz
Date: Tue Aug 26 05:20:45 2008
New Revision: 689045

URL: http://svn.apache.org/viewvc?rev=689045&view=rev
Log:
SLING-506 - Repository Pinger pinged too often

Modified:
    incubator/sling/trunk/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractSlingRepository.java
    incubator/sling/trunk/launchpad/app/pom.xml
    incubator/sling/trunk/launchpad/jcrapp/pom.xml

Modified: incubator/sling/trunk/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractSlingRepository.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractSlingRepository.java?rev=689045&r1=689044&r2=689045&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractSlingRepository.java
(original)
+++ incubator/sling/trunk/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractSlingRepository.java
Tue Aug 26 05:20:45 2008
@@ -151,10 +151,10 @@
     private Loader loader;
 
     // the poll interval used while the repository is not active
-    private long pollTimeInActive;
+    private long pollTimeInActiveSeconds;
 
     // the poll interval used while the repository is active
-    private long pollTimeActive;
+    private long pollTimeActiveSeconds;
 
     // whether the repository checker task should be active. this field
     // is managed by the startRepositoryPinger and stopRepositoryPinger methods
@@ -732,14 +732,14 @@
         if (seconds < MIN_POLL) {
             seconds = DEFAULT_POLL_ACTIVE;
         }
-        pollTimeActive = 1000L * seconds;
+        pollTimeActiveSeconds = seconds;
     }
 
     private void setPollTimeInActive(int seconds) {
         if (seconds < MIN_POLL) {
             seconds = DEFAULT_POLL_INACTIVE;
         }
-        pollTimeInActive = 1000L * seconds;
+        pollTimeInActiveSeconds = seconds;
     }
 
     private void startRepositoryPinger() {
@@ -883,10 +883,11 @@
     }
 
     public void run() {
-        // start polling with min value to be faster at system startup
+        // start polling with a small value to be faster at system startup
         // we'll increase the polling time after each try
-        long pollTime = MIN_POLL;
-        final long pollTimeIncrement = 1;
+        long pollTimeMsec = 100L;
+        final long MSEC = 1000L;
+        final int pollTimeFactor = 2;
         Object waitLock = repositoryPinger;
 
         try {
@@ -898,41 +899,52 @@
                     try {
                         // no debug logging, see SLING-505
                         // log(LogService.LOG_DEBUG, "Waiting " + pollTime + " seconds before
checking repository");
-                        waitLock.wait(pollTime * 1000L);
+                        waitLock.wait(pollTimeMsec);
                     } catch (InterruptedException ie) {
                         // don't care, go ahead
                     }
                 }
 
-                // only apply any checks if we are running after waiting
+                long newPollTime = pollTimeMsec;
                 if (running) {
 
                     Repository repo = repository;
+                    boolean ok = false;
                     if (repo == null) {
-
+                        // No Repository yet, try to start
                         if (startRepository()) {
-                            pollTime = pollTimeActive;
+                            log(LogService.LOG_INFO, "Repository started successfully");

+                            ok = true;
+                            newPollTime = pollTimeActiveSeconds * MSEC;
+                        } else {
+                            // ramp up poll time, up to the max of our configured times
+                            newPollTime = Math.min(pollTimeMsec * pollTimeFactor, Math.max(pollTimeInActiveSeconds,
pollTimeActiveSeconds) * MSEC);
                         }
 
-                    } else if (!pingAndCheck()) {
-
+                    } else if (pingAndCheck()) {
+                        ok = true;
+                        newPollTime = pollTimeActiveSeconds * MSEC;
+                        
+                    } else {
+                        // Repository disappeared
                         log(LogService.LOG_INFO,
-                            "run: Repository not accessible, unregistering service");
+                            "run: Repository not accessible anymore, unregistering service");
                         stopRepository();
-                        pollTime = Math.min(pollTime + pollTimeIncrement, pollTimeInActive);
-
-                    } else {
-
-                        // no debug logging, see SLING-505
-                        // log(LogService.LOG_DEBUG,
-                        //    "run: Repository available, checking again in "
-                        //        + pollTime + " seconds");
+                        newPollTime = pollTimeInActiveSeconds * MSEC;
+                    }
+                    
+                    if(newPollTime != pollTimeMsec) {
+                        pollTimeMsec = newPollTime;
+                        log(LogService.LOG_DEBUG, 
+                                "Repository Pinger interval set to " + pollTimeMsec + " msec,
repository is "
+                                + (ok ? "available" : "NOT available")
+                                );
                     }
                 }
             }
 
         } finally {
-            // whatever goes on, make sure the repository is disposed off
+            // whatever goes on, make sure the repository is disposed of
             // at the end of the thread....
             stopRepository();
         }

Modified: incubator/sling/trunk/launchpad/app/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/app/pom.xml?rev=689045&r1=689044&r2=689045&view=diff
==============================================================================
--- incubator/sling/trunk/launchpad/app/pom.xml (original)
+++ incubator/sling/trunk/launchpad/app/pom.xml Tue Aug 26 05:20:45 2008
@@ -364,7 +364,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.jcr.jackrabbit.server</artifactId>
-            <version>2.0.2-incubator</version>
+            <version>2.0.3-incubator-SNAPSHOT</version>
             <optional>true</optional>
         </dependency>
         <dependency>

Modified: incubator/sling/trunk/launchpad/jcrapp/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/jcrapp/pom.xml?rev=689045&r1=689044&r2=689045&view=diff
==============================================================================
--- incubator/sling/trunk/launchpad/jcrapp/pom.xml (original)
+++ incubator/sling/trunk/launchpad/jcrapp/pom.xml Tue Aug 26 05:20:45 2008
@@ -204,7 +204,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.jcr.jackrabbit.server</artifactId>
-            <version>2.0.2-incubator</version>
+            <version>2.0.3-incubator-SNAPSHOT</version>
             <optional>true</optional>
         </dependency>
         <dependency>



Mime
View raw message