You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2010/05/27 15:39:09 UTC

svn commit: r948833 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: RepositoryContext.java RepositoryImpl.java SessionImpl.java WorkspaceImpl.java

Author: jukka
Date: Thu May 27 13:39:09 2010
New Revision: 948833

URL: http://svn.apache.org/viewvc?rev=948833&view=rev
Log:
JCR-2640: Internal repository context

Use the RepositoryContext to track the ClusterNode instance, if one is configured.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java?rev=948833&r1=948832&r2=948833&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java Thu May 27 13:39:09 2010
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.core;
 
+import org.apache.jackrabbit.core.cluster.ClusterNode;
 import org.apache.jackrabbit.core.data.DataStore;
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.id.NodeId;
@@ -62,11 +63,16 @@ public class RepositoryContext {
     private FileSystem fileSystem;
 
     /**
-     * The data store of this repository, can be <code>null</code>.
+     * The data store of this repository, or <code>null</code>.
      */
     private DataStore dataStore;
 
     /**
+     * The cluster node instance of this repository, or <code>null</code>.
+     */
+    private ClusterNode clusterNode;
+
+    /**
      * Creates a component context for the given repository.
      *
      * @param repository repository instance
@@ -206,4 +212,24 @@ public class RepositoryContext {
         this.dataStore = dataStore;
     }
 
+    /**
+     * Returns the cluster node instance of this repository, or
+     * <code>null</code> if clustering is not enabled.
+     *
+     * @return cluster node
+     */
+    public ClusterNode getClusterNode() {
+        return clusterNode;
+    }
+
+    /**
+     * Sets the cluster node instance of this repository.
+     *
+     * @param clusterNode cluster node
+     */
+    public void setClusterNode(ClusterNode clusterNode) {
+        assert clusterNode != null;
+        this.clusterNode = clusterNode;
+    }
+
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?rev=948833&r1=948832&r2=948833&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java Thu May 27 13:39:09 2010
@@ -73,7 +73,6 @@ import org.apache.jackrabbit.core.config
 import org.apache.jackrabbit.core.config.WorkspaceConfig;
 import org.apache.jackrabbit.core.data.DataStore;
 import org.apache.jackrabbit.core.data.DataStoreException;
-import org.apache.jackrabbit.core.fs.BasedFileSystem;
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.fs.FileSystemException;
 import org.apache.jackrabbit.core.fs.FileSystemResource;
@@ -208,11 +207,6 @@ public class RepositoryImpl extends Abst
     private RepositoryLockMechanism repLock;
 
     /**
-     * Clustered node used, <code>null</code> if clustering is not configured.
-     */
-    private ClusterNode clusterNode;
-
-    /**
      * Shutdown lock for guaranteeing that no new sessions are started during
      * repository shutdown and that a repository shutdown is not initiated
      * during a login. Each session login acquires a read lock while the
@@ -318,8 +312,10 @@ public class RepositoryImpl extends Abst
             // initialize optional clustering
             // put here before setting up any other external event source that a cluster node
             // will be interested in
+            ClusterNode clusterNode = null;
             if (repConfig.getClusterConfig() != null) {
                 clusterNode = createClusterNode();
+                context.setClusterNode(clusterNode);
                 context.getNamespaceRegistry().setEventChannel(clusterNode);
                 context.getNodeTypeRegistry().setEventChannel(clusterNode);
 
@@ -430,16 +426,6 @@ public class RepositoryImpl extends Abst
     }
 
     /**
-     * Get the cluster node. Returns <code>null</code> if this repository
-     * is not running clustered.
-     *
-     * @return cluster node
-     */
-    public ClusterNode getClusterNode() {
-        return clusterNode;
-    }
-
-    /**
      * Returns the {@link org.apache.jackrabbit.core.security.JackrabbitSecurityManager SecurityManager}
      * of this <code>Repository</code>
      *
@@ -710,7 +696,10 @@ public class RepositoryImpl extends Abst
             }
 
             // needed to get newly created workspace config file content when runnin in clustered environment
-            StringBuffer workspaceConfigContent = clusterNode != null ? new StringBuffer() : null;
+            StringBuffer workspaceConfigContent = null;
+            if (context.getClusterNode() != null) {
+                workspaceConfigContent = new StringBuffer();
+            }
 
             // create the workspace configuration
             WorkspaceConfig config = repConfig.createWorkspaceConfig(workspaceName, workspaceConfigContent);
@@ -1044,6 +1033,7 @@ public class RepositoryImpl extends Abst
         log.info("Shutting down repository...");
 
         // stop optional cluster node
+        ClusterNode clusterNode = context.getClusterNode();
         if (clusterNode != null) {
             clusterNode.stop();
         }
@@ -1785,6 +1775,7 @@ public class RepositoryImpl extends Abst
                 if (lockMgr == null) {
                     lockMgr =
                         new LockManagerImpl(getSystemSession(), fs, executor);
+                    ClusterNode clusterNode = context.getClusterNode();
                     if (clusterNode != null && config.isClustered()) {
                         lockChannel = clusterNode.createLockChannel(getName());
                         lockMgr.setEventChannel(lockChannel);
@@ -1926,6 +1917,7 @@ public class RepositoryImpl extends Abst
                 } catch (Exception e) {
                     log.error("Unable to add vmgr: " + e.toString(), e);
                 }
+                ClusterNode clusterNode = context.getClusterNode();
                 if (clusterNode != null && config.isClustered()) {
                     updateChannel = clusterNode.createUpdateChannel(getName());
                     itemStateMgr.setEventChannel(updateChannel);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java?rev=948833&r1=948832&r2=948833&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java Thu May 27 13:39:09 2010
@@ -946,7 +946,7 @@ public class SessionImpl extends Abstrac
         sanityCheck();
 
         // JCR-1753: Ensure that we are up to date with cluster changes
-        ClusterNode cluster = rep.getClusterNode();
+        ClusterNode cluster = repositoryContext.getClusterNode();
         if (cluster != null && clusterSyncOnRefresh()) {
             try {
                 cluster.sync();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java?rev=948833&r1=948832&r2=948833&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java Thu May 27 13:39:09 2010
@@ -755,7 +755,7 @@ public class WorkspaceImpl extends Abstr
                         rep.getObservationDispatcher(wspConfig.getName()),
                         session,
                         session.getItemManager(),
-                        rep.getClusterNode());
+                        repositoryContext.getClusterNode());
             } catch (NoSuchWorkspaceException nswe) {
                 // should never get here
                 String msg = "internal error: failed to instantiate observation manager";