jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r475223 - in /jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core: ./ state/ version/
Date Wed, 15 Nov 2006 13:13:05 GMT
Author: stefan
Date: Wed Nov 15 05:13:04 2006
New Revision: 475223

URL: http://svn.apache.org/viewvc?view=rev&rev=475223
Log:
JCR-619: CacheManager (Memory Management in Jackrabbit)

Modified:
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/XAWorkspace.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/ItemStateCache.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/ItemStateReferenceCache.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/LRUItemStateCache.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/MLRUItemStateCache.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?view=diff&rev=475223&r1=475222&r2=475223
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
Wed Nov 15 05:13:04 2006
@@ -45,6 +45,9 @@
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.persistence.PMContext;
 import org.apache.jackrabbit.core.persistence.PersistenceManager;
+import org.apache.jackrabbit.core.state.CacheManager;
+import org.apache.jackrabbit.core.state.ItemStateCacheFactory;
+import org.apache.jackrabbit.core.state.ManagedMLRUItemStateCacheFactory;
 import org.apache.jackrabbit.core.state.SharedItemStateManager;
 import org.apache.jackrabbit.core.state.ChangeLog;
 import org.apache.jackrabbit.core.version.VersionManager;
@@ -210,6 +213,16 @@
     private final ReadWriteLock shutdownLock = new WriterPreferenceReadWriteLock();
 
     /**
+     * There is one cache manager per repository that manages the sizes of the caches used.
+     */
+    private final CacheManager cacheMgr = new CacheManager();
+
+    /**
+     * There is only one item state cache factory
+     */
+    private final ItemStateCacheFactory cacheFactory = new ManagedMLRUItemStateCacheFactory(cacheMgr);
+
+    /**
      * private constructor
      *
      * @param repConfig
@@ -321,6 +334,15 @@
     }
 
     /**
+     * Get the item state cache factory of this repository.
+     *
+     * @return the cache manager
+     */
+    public ItemStateCacheFactory getItemStateCacheFactory() {
+        return cacheFactory;
+    }
+
+    /**
      * Creates the version manager.
      *
      * @param vConfig the versioning config
@@ -341,7 +363,7 @@
                 ntReg);
 
         VersionManagerImpl vMgr = new VersionManagerImpl(pm, fs, ntReg, delegatingDispatcher,
-                VERSION_STORAGE_NODE_ID, SYSTEM_ROOT_NODE_ID);
+                VERSION_STORAGE_NODE_ID, SYSTEM_ROOT_NODE_ID, cacheFactory);
         if (clusterNode != null) {
             vMgr.setEventChannel(clusterNode.createUpdateChannel());
         }
@@ -1703,7 +1725,7 @@
                 // create item state manager
                 try {
                     itemStateMgr =
-                            new SharedItemStateManager(persistMgr, rootNodeId, ntReg, true);
+                            new SharedItemStateManager(persistMgr, rootNodeId, ntReg, true,
cacheFactory);
                     try {
                         itemStateMgr.addVirtualItemStateProvider(
                                 vMgr.getVirtualItemStateProvider());

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java?view=diff&rev=475223&r1=475222&r2=475223
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
Wed Nov 15 05:13:04 2006
@@ -21,13 +21,12 @@
 import org.apache.jackrabbit.core.lock.LockManager;
 import org.apache.jackrabbit.core.observation.EventStateCollection;
 import org.apache.jackrabbit.core.observation.EventStateCollectionFactory;
-import org.apache.jackrabbit.core.observation.ObservationDispatcher;
 import org.apache.jackrabbit.core.observation.ObservationManagerImpl;
 import org.apache.jackrabbit.core.query.QueryManagerImpl;
 import org.apache.jackrabbit.core.state.LocalItemStateManager;
 import org.apache.jackrabbit.core.state.SharedItemStateManager;
-import org.apache.jackrabbit.core.version.VersionImpl;
 import org.apache.jackrabbit.core.version.DateVersionSelector;
+import org.apache.jackrabbit.core.version.VersionImpl;
 import org.apache.jackrabbit.core.version.VersionSelector;
 import org.apache.jackrabbit.core.xml.ImportHandler;
 import org.apache.jackrabbit.core.xml.Importer;
@@ -168,6 +167,7 @@
             obsMgr.dispose();
             obsMgr = null;
         }
+        stateMgr.dispose();
     }
 
     /**
@@ -757,7 +757,7 @@
      * @return local item state manager
      */
     protected LocalItemStateManager createItemStateManager(SharedItemStateManager shared)
{
-        return new LocalItemStateManager(shared, this);
+        return new LocalItemStateManager(shared, this, rep.getItemStateCacheFactory());
     }
 
     //------------------------------------------< EventStateCollectionFactory >
@@ -774,4 +774,5 @@
         return ((ObservationManagerImpl) getObservationManager()).createEventStateCollection();
     }
 }
+
 

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java?view=diff&rev=475223&r1=475222&r2=475223
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java
Wed Nov 15 05:13:04 2006
@@ -131,7 +131,7 @@
          * Create array that contains all resources that paricipate in this
          * transactions. Because some resources depend on each other, there is
          * also a workspace scoped lock resource inserted, that guards the
-         * entire transaction from deadlocks (see JCR-335) 
+         * entire transaction from deadlocks (see JCR-335)
          */
         txResources = new InternalXAResource[] {
             ((XAWorkspace) wsp).getXAResourceBegin(),
@@ -158,7 +158,7 @@
             throws RepositoryException {
 
         VersionManagerImpl vMgr = (VersionManagerImpl) rep.getVersionManager();
-        return new XAVersionManager(vMgr, rep.getNodeTypeRegistry(), this);
+        return new XAVersionManager(vMgr, rep.getNodeTypeRegistry(), this, rep.getItemStateCacheFactory());
     }
 
     /**
@@ -370,6 +370,19 @@
      */
     private boolean isAssociated() {
         return tx != null;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public synchronized void logout() {
+        super.logout();
+        // dispose the caches
+        try {
+            ((XAVersionManager)versionMgr).close();
+        } catch(Exception e) {
+            log.warn("error while closing XAVersionManager", e);
+        }
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/XAWorkspace.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/XAWorkspace.java?view=diff&rev=475223&r1=475222&r2=475223
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/XAWorkspace.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/XAWorkspace.java
Wed Nov 15 05:13:04 2006
@@ -53,7 +53,7 @@
      * {@inheritDoc}
      */
     protected LocalItemStateManager createItemStateManager(SharedItemStateManager shared)
{
-        return new XAItemStateManager(shared, this);
+        return new XAItemStateManager(shared, this, rep.getItemStateCacheFactory());
     }
 
     /**
@@ -137,4 +137,4 @@
         };
     }
 
-}
\ No newline at end of file
+}

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/ItemStateCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/ItemStateCache.java?view=diff&rev=475223&r1=475222&r2=475223
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/ItemStateCache.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/ItemStateCache.java
Wed Nov 15 05:13:04 2006
@@ -108,4 +108,9 @@
      * @param id the id of the item that was modified.
      */
     void update(ItemId id);
+
+    /**
+     * Informs the cache that it is no longer in use.
+     */
+    void dispose();
 }

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/ItemStateReferenceCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/ItemStateReferenceCache.java?view=diff&rev=475223&r1=475222&r2=475223
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/ItemStateReferenceCache.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/ItemStateReferenceCache.java
Wed Nov 15 05:13:04 2006
@@ -66,8 +66,8 @@
      * <code>LRUItemStateCache</code> instance as internal secondary
      * cache.
      */
-    public ItemStateReferenceCache() {
-        this(new MLRUItemStateCache());
+    public ItemStateReferenceCache(ItemStateCacheFactory cacheFactory) {
+        this(cacheFactory.newItemStateCache());
     }
 
     /**
@@ -125,6 +125,13 @@
         cache.evict(id);
         // remove from primary cache
         refs.remove(id);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose() {
+        cache.dispose();
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/LRUItemStateCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/LRUItemStateCache.java?view=diff&rev=475223&r1=475222&r2=475223
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/LRUItemStateCache.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/LRUItemStateCache.java
Wed Nov 15 05:13:04 2006
@@ -134,4 +134,11 @@
     public Collection values() {
         return Collections.unmodifiableCollection(cache.values());
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose() {
+        cache.clear();
+    }
 }

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java?view=diff&rev=475223&r1=475222&r2=475223
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java
Wed Nov 15 05:13:04 2006
@@ -70,8 +70,8 @@
      * @param factory event state collection factory
      */
     public LocalItemStateManager(SharedItemStateManager sharedStateMgr,
-                                 EventStateCollectionFactory factory) {
-        cache = new ItemStateReferenceCache();
+                                 EventStateCollectionFactory factory, ItemStateCacheFactory
cacheFactory) {
+        cache = new ItemStateReferenceCache(cacheFactory);
         this.sharedStateMgr = sharedStateMgr;
         this.factory = factory;
 
@@ -344,6 +344,7 @@
         }
         // clear cache
         cache.evictAll();
+        cache.dispose();
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/MLRUItemStateCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/MLRUItemStateCache.java?view=diff&rev=475223&r1=475222&r2=475223
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/MLRUItemStateCache.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/MLRUItemStateCache.java
Wed Nov 15 05:13:04 2006
@@ -34,7 +34,7 @@
  * cache uses a rough estimate of the memory consuption of the cache item
  * states for calculating the maximum number of entries.
  */
-public class MLRUItemStateCache implements ItemStateCache {
+public class MLRUItemStateCache implements ItemStateCache, Cache {
     /** Logger instance */
     private static Logger log = LoggerFactory.getLogger(LRUItemStateCache.class);
 
@@ -45,11 +45,17 @@
     private long totalMem;
 
     /** the maximum of memory the cache may use */
-    private final long maxMem;
+    private long maxMem;
 
     /** the number of writes */
     private long numWrites = 0;
 
+    /** the access count */
+    private long accessCount = 0;
+
+    /** the cache access listeners */
+    private CacheAccessListener accessListener;
+
     /**
      * A cache for <code>ItemState</code> instances
      */
@@ -69,7 +75,7 @@
      *
      * @param maxMem the maximum amount of memory this cache may use.
      */
-    public MLRUItemStateCache(int maxMem) {
+    private MLRUItemStateCache(int maxMem) {
         this.maxMem = maxMem;
     }
 
@@ -88,6 +94,7 @@
      */
     public ItemState retrieve(ItemId id) {
         synchronized (cache) {
+            touch();
             Entry entry = (Entry) cache.remove(id);
             if (entry != null) {
                 // 'touch' item, by adding at end of list
@@ -104,6 +111,7 @@
      */
     public void update(ItemId id) {
         synchronized (cache) {
+            touch();
             Entry entry = (Entry) cache.get(id);
             if (entry != null) {
                 totalMem -= entry.size;
@@ -118,6 +126,7 @@
      */
     public void cache(ItemState state) {
         synchronized (cache) {
+            touch();
             ItemId id = state.getId();
             if (cache.containsKey(id)) {
                 log.warn("overwriting cached entry " + id);
@@ -126,22 +135,27 @@
             Entry entry = new Entry(state);
             cache.put(id, entry);
             totalMem += entry.size;
-            // remove items, if too many
-            while (totalMem > maxMem) {
-                id = (ItemId) cache.firstKey();
-                evict(id);
-            }
+            shrinkIfRequired();
             if (numWrites++%10000 == 0 && log.isDebugEnabled()) {
                 log.info(this + " size=" + cache.size() + ", " + totalMem + "/" + maxMem);
             }
         }
     }
 
+    private void shrinkIfRequired() {
+        // remove items, if too many
+        while (totalMem > maxMem) {
+            ItemId id = (ItemId) cache.firstKey();
+            evict(id);
+        }
+    }
+
     /**
      * {@inheritDoc}
      */
     public void evict(ItemId id) {
         synchronized (cache) {
+            touch();
             Entry entry = (Entry) cache.remove(id);
             if (entry != null) {
                 totalMem -= entry.size;
@@ -201,8 +215,87 @@
         }
     }
 
+    private void touch() {
+        accessCount++;
+        if ((accessCount % CacheAccessListener.ACCESS_INTERVAL) == 0) {
+            if (accessListener != null) {
+                accessListener.cacheAccessed();
+            }
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public long getAccessCount() {
+        return accessCount;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public long getMaxMemorySize() {
+        return maxMem;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public long getMemoryUsed() {
+        synchronized (cache) {
+            totalMem = 0;
+            Iterator iter = cache.values().iterator();
+            while (iter.hasNext()) {
+                Entry entry = (Entry) iter.next();
+                entry.recalc();
+                totalMem += entry.size;
+            }
+        }
+        return totalMem;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void resetAccessCount() {
+        synchronized (cache) {
+            accessCount = 0;
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setMaxMemorySize(long size) {
+        synchronized (cache) {
+            this.maxMem = size;
+            shrinkIfRequired();
+        }
+    }
+
+    /**
+     * Set the cache access listener. Only one listener per cache is supported.
+     *
+     * @param listener the new listener
+     */
+    public void setAccessListener(CacheAccessListener listener) {
+        this.accessListener = listener;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose() {
+        synchronized (cache) {
+            if(accessListener != null) {
+                accessListener.disposeCache(this);
+            }
+        }
+    }
+
+
     /**
-     * Internal cache entry
+     * Internal cache entry.
      */
     private static class Entry {
 
@@ -219,4 +312,5 @@
             size = 64 + state.calculateMemoryFootprint();
         }
     }
+
 }

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?view=diff&rev=475223&r1=475222&r2=475223
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
Wed Nov 15 05:13:04 2006
@@ -196,9 +196,10 @@
     public SharedItemStateManager(PersistenceManager persistMgr,
                                   NodeId rootNodeId,
                                   NodeTypeRegistry ntReg,
-                                  boolean usesReferences)
+                                  boolean usesReferences,
+                                  ItemStateCacheFactory cacheFactory)
             throws ItemStateException {
-        cache = new ItemStateReferenceCache();
+        cache = new ItemStateReferenceCache(cacheFactory);
         this.persistMgr = persistMgr;
         this.ntReg = ntReg;
         this.usesReferences = usesReferences;

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java?view=diff&rev=475223&r1=475222&r2=475223
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java
Wed Nov 15 05:13:04 2006
@@ -86,8 +86,8 @@
      * @param factory        event state collection factory
      */
     public XAItemStateManager(SharedItemStateManager sharedStateMgr,
-                              EventStateCollectionFactory factory) {
-        this(sharedStateMgr, factory, DEFAULT_ATTRIBUTE_NAME);
+                              EventStateCollectionFactory factory, ItemStateCacheFactory
cacheFactory) {
+        this(sharedStateMgr, factory, DEFAULT_ATTRIBUTE_NAME, cacheFactory);
     }
 
     /**
@@ -99,8 +99,9 @@
      */
     public XAItemStateManager(SharedItemStateManager sharedStateMgr,
                               EventStateCollectionFactory factory,
-                              String attributeName) {
-        super(sharedStateMgr, factory);
+                              String attributeName,
+                              ItemStateCacheFactory cacheFactory) {
+        super(sharedStateMgr, factory, cacheFactory);
 
         this.attributeName = attributeName;
     }

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java?view=diff&rev=475223&r1=475222&r2=475223
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
Wed Nov 15 05:13:04 2006
@@ -21,24 +21,25 @@
 import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.PropertyId;
 import org.apache.jackrabbit.core.SessionImpl;
-import org.apache.jackrabbit.core.persistence.PersistenceManager;
+import org.apache.jackrabbit.core.cluster.UpdateEventChannel;
+import org.apache.jackrabbit.core.cluster.UpdateEventListener;
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.observation.DelegatingObservationDispatcher;
 import org.apache.jackrabbit.core.observation.EventStateCollection;
 import org.apache.jackrabbit.core.observation.EventStateCollectionFactory;
+import org.apache.jackrabbit.core.persistence.PersistenceManager;
 import org.apache.jackrabbit.core.state.ChangeLog;
+import org.apache.jackrabbit.core.state.ItemState;
+import org.apache.jackrabbit.core.state.ItemStateCacheFactory;
 import org.apache.jackrabbit.core.state.ItemStateException;
+import org.apache.jackrabbit.core.state.ItemStateListener;
 import org.apache.jackrabbit.core.state.LocalItemStateManager;
 import org.apache.jackrabbit.core.state.NodeReferences;
 import org.apache.jackrabbit.core.state.NodeReferencesId;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.PropertyState;
 import org.apache.jackrabbit.core.state.SharedItemStateManager;
-import org.apache.jackrabbit.core.state.ItemStateListener;
-import org.apache.jackrabbit.core.state.ItemState;
-import org.apache.jackrabbit.core.cluster.UpdateEventChannel;
-import org.apache.jackrabbit.core.cluster.UpdateEventListener;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.virtual.VirtualItemStateProvider;
 import org.apache.jackrabbit.name.MalformedPathException;
@@ -129,7 +130,8 @@
     public VersionManagerImpl(PersistenceManager pMgr, FileSystem fs,
                               NodeTypeRegistry ntReg,
                               DelegatingObservationDispatcher obsMgr, NodeId rootId,
-                              NodeId rootParentId) throws RepositoryException {
+                              NodeId rootParentId,
+                              ItemStateCacheFactory cacheFactory) throws RepositoryException
{
         try {
             this.pMgr = pMgr;
             this.fs = fs;
@@ -156,9 +158,9 @@
                 pMgr.store(cl);
             }
             sharedStateMgr =
-                    new VersionItemStateManager(pMgr, rootId, ntReg);
+                    new VersionItemStateManager(pMgr, rootId, ntReg, cacheFactory);
 
-            stateMgr = new LocalItemStateManager(sharedStateMgr, escFactory);
+            stateMgr = new LocalItemStateManager(sharedStateMgr, escFactory, cacheFactory);
             stateMgr.addListener(this);
 
             NodeState nodeState = (NodeState) stateMgr.getItemState(rootId);
@@ -515,9 +517,10 @@
 
         public VersionItemStateManager(PersistenceManager persistMgr,
                                        NodeId rootNodeId,
-                                       NodeTypeRegistry ntReg)
+                                       NodeTypeRegistry ntReg,
+                                       ItemStateCacheFactory cacheFactory)
                 throws ItemStateException {
-            super(persistMgr, rootNodeId, ntReg, false);
+            super(persistMgr, rootNodeId, ntReg, false, cacheFactory);
         }
 
         protected void checkReferentialIntegrity(ChangeLog changes)

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java?view=diff&rev=475223&r1=475222&r2=475223
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
Wed Nov 15 05:13:04 2006
@@ -24,17 +24,18 @@
 import org.apache.jackrabbit.core.TransactionContext;
 import org.apache.jackrabbit.core.TransactionException;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
-import org.apache.jackrabbit.core.observation.EventStateCollectionFactory;
 import org.apache.jackrabbit.core.observation.EventStateCollection;
+import org.apache.jackrabbit.core.observation.EventStateCollectionFactory;
 import org.apache.jackrabbit.core.state.ChangeLog;
 import org.apache.jackrabbit.core.state.ItemState;
+import org.apache.jackrabbit.core.state.ItemStateCacheFactory;
 import org.apache.jackrabbit.core.state.ItemStateException;
+import org.apache.jackrabbit.core.state.ItemStateListener;
 import org.apache.jackrabbit.core.state.NoSuchItemStateException;
 import org.apache.jackrabbit.core.state.NodeReferences;
 import org.apache.jackrabbit.core.state.NodeReferencesId;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.XAItemStateManager;
-import org.apache.jackrabbit.core.state.ItemStateListener;
 import org.apache.jackrabbit.core.virtual.VirtualItemStateProvider;
 import org.apache.jackrabbit.core.virtual.VirtualNodeState;
 import org.apache.jackrabbit.core.virtual.VirtualPropertyState;
@@ -96,14 +97,14 @@
      * Creates a new instance of this class.
      */
     public XAVersionManager(VersionManagerImpl vMgr, NodeTypeRegistry ntReg,
-                            SessionImpl session)
+                            SessionImpl session, ItemStateCacheFactory cacheFactory)
             throws RepositoryException {
 
         this.vMgr = vMgr;
         this.ntReg = ntReg;
         this.session = session;
         this.stateMgr = new XAItemStateManager(vMgr.getSharedStateMgr(),
-                this, CHANGE_LOG_ATTRIBUTE_NAME);
+                this, CHANGE_LOG_ATTRIBUTE_NAME, cacheFactory);
 
         NodeState state;
         try {
@@ -199,6 +200,7 @@
      * {@inheritDoc}
      */
     public void close() throws Exception {
+        stateMgr.dispose();
     }
 
     //---------------------------------------------< VirtualItemStateProvider >



Mime
View raw message