jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1540692 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/kernel/ main/java/org/apache/jackrabbit/oak/plugins/mongomk/ main/java/org/apache/jackrabbit/oak/plugins/segment/ main/java/org/apache/jackrabbit/oak/spi/...
Date Mon, 11 Nov 2013 12:17:07 GMT
Author: mduerig
Date: Mon Nov 11 12:17:06 2013
New Revision: 1540692

URL: http://svn.apache.org/r1540692
Log:
OAK-1143: [scala] Repository init throws "illegal cyclic reference involving class ChangeDispatcher"
Remove dependency on NodeStore from ChangeDispatcher. ChangeDispatcher does not poll for external
changes anymore.

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStoreBranch.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/ChangeDispatcher.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/CommitQueueTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java?rev=1540692&r1=1540691&r2=1540692&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
Mon Nov 11 12:17:06 2013
@@ -118,7 +118,7 @@ public class KernelNodeStore implements 
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
-        changeDispatcher = new ChangeDispatcher(this);
+        changeDispatcher = new ChangeDispatcher(root);
     }
 
     public KernelNodeStore(MicroKernel kernel) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStore.java?rev=1540692&r1=1540691&r2=1540692&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStore.java
Mon Nov 11 12:17:06 2013
@@ -286,7 +286,7 @@ public final class MongoNodeStore
             }
             getRevisionComparator().add(headRevision, Revision.newRevision(0));
         }
-        dispatcher = new ChangeDispatcher(this);
+        dispatcher = new ChangeDispatcher(getRoot());
         commitQueue = new CommitQueue(this, dispatcher);
         backgroundThread = new Thread(
                 new BackgroundOperation(this, isDisposed),

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStoreBranch.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStoreBranch.java?rev=1540692&r1=1540691&r2=1540692&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStoreBranch.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStoreBranch.java
Mon Nov 11 12:17:06 2013
@@ -61,7 +61,7 @@ public class MongoNodeStoreBranch
 
     public MongoNodeStoreBranch(MongoNodeStore store,
                                 MongoNodeState base) {
-        super(store, new ChangeDispatcher(store), base);
+        super(store, new ChangeDispatcher(store.getRoot()), base);
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java?rev=1540692&r1=1540691&r2=1540692&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java
Mon Nov 11 12:17:06 2013
@@ -60,7 +60,7 @@ public class SegmentNodeStore implements
         this.journal = store.getJournal(journal);
         this.head = new SegmentNodeState(
                 store.getWriter().getDummySegment(), this.journal.getHead());
-        this.changeDispatcher = new ChangeDispatcher(this);
+        this.changeDispatcher = new ChangeDispatcher(getRoot());
     }
 
     public SegmentNodeStore(SegmentStore store) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/ChangeDispatcher.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/ChangeDispatcher.java?rev=1540692&r1=1540691&r2=1540692&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/ChangeDispatcher.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/ChangeDispatcher.java
Mon Nov 11 12:17:06 2013
@@ -36,10 +36,10 @@ import javax.annotation.Nullable;
 
 import com.google.common.collect.Sets;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.jackrabbit.oak.spi.state.NodeStore;
 
 /**
- * A {@code ChangeDispatcher} instance records changes to a {@link NodeStore}
+ * A {@code ChangeDispatcher} instance records changes to a
+ * {@link org.apache.jackrabbit.oak.spi.state.NodeStore}
  * and dispatches them to interested parties.
  * <p>
  * Actual changes are reported by calling {@link #beforeCommit(NodeState)},
@@ -62,18 +62,16 @@ import org.apache.jackrabbit.oak.spi.sta
  */
 public class ChangeDispatcher implements Observable {
     private final Set<Listener> listeners = Sets.newHashSet();
-    private final NodeStore store;
 
     @Nonnull
     private volatile NodeState root;
 
     /**
-     * Create a new instance for recording changes to {@code store}.
-     * @param store  the node store to record changes for
+     * Create a new instance for recording changes to a {@code NodeStore}
+     * @param root  current root node state of the node store
      */
-    public ChangeDispatcher(@Nonnull NodeStore store) {
-        this.store = store;
-        this.root = checkNotNull(store.getRoot());
+    public ChangeDispatcher(@Nonnull NodeState root) {
+        this.root = checkNotNull(root);
     }
 
     /**
@@ -157,18 +155,6 @@ public class ChangeDispatcher implements
         changeCount.incrementAndGet();
     }
 
-    private void externalChange() {
-        if (!inLocalCommit()) {
-            long c = changeCount.get();
-            NodeState root = store.getRoot();  // Need to get root outside sync. See OAK-959
-            synchronized (this) {
-                if (c == changeCount.get() && !inLocalCommit()) {
-                    externalChange(root);
-                }
-            }
-        }
-    }
-
     private synchronized void externalChange(NodeState root) {
         if (!root.equals(this.root)) {
             add(root, null);
@@ -230,9 +216,6 @@ public class ChangeDispatcher implements
         public void run() {
             try {
                 while (!stopping) {
-                    if (commits.isEmpty()) {
-                        externalChange();
-                    }
                     Commit commit = commits.poll(100, TimeUnit.MILLISECONDS);
                     if (commit != null) {
                         observer.contentChanged(commit.getRoot(), commit.getCommitInfo());

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/CommitQueueTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/CommitQueueTest.java?rev=1540692&r1=1540691&r2=1540692&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/CommitQueueTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/CommitQueueTest.java
Mon Nov 11 12:17:06 2013
@@ -44,7 +44,7 @@ public class CommitQueueTest {
     @Test
     public void concurrentCommits() throws Exception {
         final MongoNodeStore store = new MongoMK.Builder().getNodeStore();
-        ChangeDispatcher dispatcher = new ChangeDispatcher(store);
+        ChangeDispatcher dispatcher = new ChangeDispatcher(store.getRoot());
         AtomicBoolean running = new AtomicBoolean(true);
         final CommitQueue queue = new CommitQueue(store, dispatcher);
         final List<Exception> exceptions = Collections.synchronizedList(new ArrayList<Exception>());



Mime
View raw message