jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1518136 - /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RefreshManager.java
Date Wed, 28 Aug 2013 10:10:08 GMT
Author: mduerig
Date: Wed Aug 28 10:10:08 2013
New Revision: 1518136

URL: http://svn.apache.org/r1518136
Log:
OAK-960 Enable session refresh state coordination between multiple session in single thread
- Avoid spurious refreshes
- Simplify

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RefreshManager.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RefreshManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RefreshManager.java?rev=1518136&r1=1518135&r2=1518136&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RefreshManager.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RefreshManager.java
Wed Aug 28 10:10:08 2013
@@ -68,7 +68,7 @@ public class RefreshManager {
         this.refreshInterval = refreshInterval;
         this.threadSaveCount = threadSaveCount;
 
-        sessionSaveCount = getOr0(threadSaveCount);
+        sessionSaveCount = getThreadSaveCount();
     }
 
     /**
@@ -99,13 +99,19 @@ public class RefreshManager {
             if (refreshAtNextAccess || hasInThreadCommit() || timeElapsed >= refreshInterval)
{
                 // Refresh if forced or if the session has been idle too long
                 refreshAtNextAccess = false;
-                sessionSaveCount = getOr0(threadSaveCount);
+                sessionSaveCount = getThreadSaveCount();
                 return true;
             }
         }
 
         if (sessionOperation.isSave()) {
-            threadSaveCount.set(sessionSaveCount = (getOr0(threadSaveCount) + 1));
+            // Force refreshing on access through other sessions on the same thread
+            threadSaveCount.set(sessionSaveCount = (getThreadSaveCount() + 1));
+        }
+
+        if (sessionOperation.isRefresh()) {
+            // Avoid further refreshing if this is already a refresh operation
+            sessionSaveCount = getThreadSaveCount();
         }
 
         return false;
@@ -119,11 +125,11 @@ public class RefreshManager {
         // If the threadLocal counter differs from our seen sessionSaveCount so far then
         // some other session would have done a commit. If that is the case a refresh would
         // be required
-        return getOr0(threadSaveCount) != sessionSaveCount;
+        return getThreadSaveCount() != sessionSaveCount;
     }
 
-    private static int getOr0(ThreadLocal<Integer> threadLocal) {
-        Integer c = threadLocal.get();
+    private int getThreadSaveCount() {
+        Integer c = threadSaveCount.get();
         return c == null ? 0 : c;
     }
 }



Mime
View raw message