jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpfis...@apache.org
Subject svn commit: r486557 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: cluster/ClusterNode.java cluster/Journal.java cluster/NamespaceEventListener.java state/SharedItemStateManager.java
Date Wed, 13 Dec 2006 09:24:07 GMT
Author: dpfister
Date: Wed Dec 13 01:24:06 2006
New Revision: 486557

URL: http://svn.apache.org/viewvc?view=rev&rev=486557
Log:
JCR-623 - Clustering
+ Don't log changes that occur before cluster node is started
+ Handle missing added nodes in external notifications more gracefully

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/Journal.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NamespaceEventListener.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java?view=diff&rev=486557&r1=486556&r2=486557
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
Wed Dec 13 01:24:06 2006
@@ -56,6 +56,21 @@
     private static final String SHORT_PADDING = "0000";
 
     /**
+     * Status constant.
+     */
+    private static final int NONE = 0;
+
+    /**
+     * Status constant.
+     */
+    private static final int STARTED = 1;
+
+    /**
+     * Status constant.
+     */
+    private static final int STOPPED = 2;
+
+    /**
      * Logger.
      */
     private static Logger log = LoggerFactory.getLogger(ClusterNode.class);
@@ -86,9 +101,9 @@
     private final Mutex syncLock = new Mutex();
 
     /**
-     * Flag indicating whether this cluster node is stopped.
+     * Status flag, one of {@link #NONE}, {@link #STARTED} or {@link #STOPPED}.
      */
-    private boolean stopped;
+    private int status;
 
     /**
      * Map of available lock listeners, indexed by workspace name.
@@ -150,11 +165,15 @@
      * @throws ClusterException if an error occurs
      */
     public synchronized void start() throws ClusterException {
-        sync();
+        if (status == NONE) {
+            sync();
 
-        Thread t = new Thread(this, "ClusterNode-" + clusterNodeId);
-        t.setDaemon(true);
-        t.start();
+            Thread t = new Thread(this, "ClusterNode-" + clusterNodeId);
+            t.setDaemon(true);
+            t.start();
+
+            status = STARTED;
+        }
     }
 
     /**
@@ -167,7 +186,7 @@
                     wait(syncDelay * 1000);
                 } catch (InterruptedException e) {}
 
-                if (stopped) {
+                if (status == STOPPED) {
                     return;
                 }
             }
@@ -203,7 +222,7 @@
      * {@inheritDoc}
      */
     public synchronized void stop() {
-        stopped = true;
+        status = STOPPED;
 
         notifyAll();
     }
@@ -217,6 +236,10 @@
      * @param owner lock owner
      */
     private void locked(String workspace, NodeId nodeId, boolean deep, String owner) {
+        if (status != STARTED) {
+            log.info("not started: lock operation ignored.");
+            return;
+        }
         boolean succeeded = false;
 
         try {
@@ -245,6 +268,10 @@
      * @param nodeId node id
      */
     private void unlocked(String workspace, NodeId nodeId) {
+        if (status != STARTED) {
+            log.info("not started: unlock operation ignored.");
+            return;
+        }
         boolean succeeded = false;
 
         try {
@@ -324,6 +351,10 @@
      * {@inheritDoc}
      */
     public void updateCreated() {
+        if (status != STARTED) {
+            log.info("not started: update create ignored.");
+            return;
+        }
         try {
             sync();
         } catch (ClusterException e) {
@@ -353,6 +384,10 @@
      * @param esc events as they will be delivered on success
      */
     private void updatePrepared(String workspace, ChangeLog changes, EventStateCollection
esc) {
+        if (status != STARTED) {
+            log.info("not started: update prepare ignored.");
+            return;
+        }
         boolean succeeded = false;
 
         try {
@@ -377,6 +412,10 @@
      * {@inheritDoc}
      */
     public void updateCommitted() {
+        if (status != STARTED) {
+            log.info("not started: update commit ignored.");
+            return;
+        }
         try {
             journal.commit();
         } catch (JournalException e) {
@@ -392,6 +431,10 @@
      * {@inheritDoc}
      */
     public void updateCancelled() {
+        if (status != STARTED) {
+            log.info("not started: update cancel ignored.");
+            return;
+        }
         journal.cancel();
     }
 
@@ -410,6 +453,10 @@
      * {@inheritDoc}
      */
     public void remapped(String oldPrefix, String newPrefix, String uri) {
+        if (status != STARTED) {
+            log.info("not started: namespace operation ignored.");
+            return;
+        }
         boolean succeeded = false;
 
         try {
@@ -441,6 +488,10 @@
      * {@inheritDoc}
      */
     public void registered(Collection ntDefs) {
+        if (status != STARTED) {
+            log.info("not started: nodetype operation ignored.");
+            return;
+        }
         boolean succeeded = false;
 
         try {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/Journal.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/Journal.java?view=diff&rev=486557&r1=486556&r2=486557
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/Journal.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/Journal.java
Wed Dec 13 01:24:06 2006
@@ -19,9 +19,7 @@
 import org.apache.jackrabbit.core.state.ChangeLog;
 import org.apache.jackrabbit.core.observation.EventStateCollection;
 import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.name.NamespaceResolver;
-import org.apache.jackrabbit.name.QName;
 
 import java.util.Collection;
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NamespaceEventListener.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NamespaceEventListener.java?view=diff&rev=486557&r1=486556&r2=486557
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NamespaceEventListener.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NamespaceEventListener.java
Wed Dec 13 01:24:06 2006
@@ -16,8 +16,6 @@
  */
 package org.apache.jackrabbit.core.cluster;
 
-import org.apache.jackrabbit.core.NodeId;
-
 import javax.jcr.RepositoryException;
 
 /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?view=diff&rev=486557&r1=486556&r2=486557
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
Wed Dec 13 01:24:06 2006
@@ -820,6 +820,9 @@
         ChangeLog shared = new ChangeLog();
 
         try {
+            // Build a copy of the external change log, consisting of shared
+            // states we have in our cache. Inform listeners about this
+            // change.
             acquireWriteLock();
             holdingWriteLock = true;
 
@@ -833,6 +836,12 @@
                         state.copy(currentState);
                         state.setModCount(currentState.getModCount());
                         shared.modified(state);
+                    } catch (NoSuchItemStateException e) {
+                        // This is likely to happen because a subsequent delete
+                        // of this very state has not yet been transmitted.
+                        String msg = "Unable to retrieve state: " + state.getId() + ", ignored.";
+                        log.info(msg);
+                        state.discard();
                     } catch (ItemStateException e) {
                         String msg = "Unable to retrieve state: " + state.getId();
                         log.warn(msg);



Mime
View raw message