jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r604872 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/ main/java/org/apache/jackrabbit/core/data/ main/java/org/apache/jackrabbit/core/data/db/ main/java/org/apache/jackrabbit/core/persistence/ main/java/o...
Date Mon, 17 Dec 2007 14:02:30 GMT
Author: thomasm
Date: Mon Dec 17 06:02:28 2007
New Revision: 604872

URL: http://svn.apache.org/viewvc?rev=604872&view=rev
Log:
JCR-1138 Data store garbage collection: use IterablePersistenceManager if possible

Added:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/IterablePersistenceManager.java
  (with props)
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/Pool.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/TempFileInputStream.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/   (props changed)
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/PersistenceManagerIteratorTest.java

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=604872&r1=604871&r2=604872&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
Mon Dec 17 06:02:28 2007
@@ -58,22 +58,28 @@
 
 import org.apache.commons.collections.IteratorUtils;
 import org.apache.commons.collections.map.ReferenceMap;
+import org.apache.jackrabbit.core.RepositoryImpl.WorkspaceInfo;
 import org.apache.jackrabbit.core.config.AccessManagerConfig;
 import org.apache.jackrabbit.core.config.WorkspaceConfig;
+import org.apache.jackrabbit.core.data.GarbageCollector;
 import org.apache.jackrabbit.core.lock.LockManager;
 import org.apache.jackrabbit.core.nodetype.NodeDefinitionImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl;
+import org.apache.jackrabbit.core.persistence.IterablePersistenceManager;
+import org.apache.jackrabbit.core.persistence.PersistenceManager;
 import org.apache.jackrabbit.core.security.AMContext;
 import org.apache.jackrabbit.core.security.AccessManager;
 import org.apache.jackrabbit.core.security.AuthContext;
 import org.apache.jackrabbit.core.security.SecurityConstants;
+import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.LocalItemStateManager;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.SessionItemStateManager;
 import org.apache.jackrabbit.core.state.SharedItemStateManager;
 import org.apache.jackrabbit.core.util.Dumpable;
 import org.apache.jackrabbit.core.version.VersionManager;
+import org.apache.jackrabbit.core.version.VersionManagerImpl;
 import org.apache.jackrabbit.core.xml.DocViewSAXEventGenerator;
 import org.apache.jackrabbit.core.xml.ImportHandler;
 import org.apache.jackrabbit.core.xml.SessionImporter;
@@ -588,6 +594,39 @@
      */
     public void removeListener(SessionListener listener) {
         listeners.remove(listener);
+    }
+    
+    /**
+     * Create a data store garbage collector for this repository.
+     * 
+     * @throws ItemStateException 
+     * @throws RepositoryException
+     */
+    public GarbageCollector createDataStoreGarbageCollector() throws RepositoryException,
ItemStateException {
+        ArrayList pmList = new ArrayList();
+        VersionManagerImpl vm = (VersionManagerImpl)rep.getVersionManager();
+        PersistenceManager pm = vm.getPersistenceManager();
+        pmList.add(pm);
+        String[] wspNames = rep.getWorkspaceNames();
+        SystemSession[] sysSessions = new SystemSession[wspNames.length];
+        for (int i = 0; i < wspNames.length; i++) {
+            String wspName = wspNames[i];
+            WorkspaceInfo wspInfo = rep.getWorkspaceInfo(wspName);
+            sysSessions[i] = rep.getSystemSession(wspName);
+            pm = wspInfo.getPersistenceManager();
+            pmList.add(pm);
+        }
+        IterablePersistenceManager[] ipmList = new IterablePersistenceManager[pmList.size()];
+        for (int i = 0; i < pmList.size(); i++) {
+            pm = (PersistenceManager) pmList.get(i);
+            if (!(pm instanceof IterablePersistenceManager)) {
+                ipmList = null;
+                break;
+            }
+            ipmList[i] = (IterablePersistenceManager) pm;
+        }
+        GarbageCollector gc = new GarbageCollector(this, ipmList, sysSessions);
+        return gc;
     }
 
     //--------------------------------------------------------< NameResolver >

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java?rev=604872&r1=604871&r2=604872&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java
Mon Dec 17 06:02:28 2007
@@ -16,11 +16,22 @@
  */
 package org.apache.jackrabbit.core.data;
 
+import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.PropertyId;
 import org.apache.jackrabbit.core.RepositoryImpl;
+import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.observation.SynchronousEventListener;
+import org.apache.jackrabbit.core.persistence.IterablePersistenceManager;
+import org.apache.jackrabbit.core.state.ItemStateException;
+import org.apache.jackrabbit.core.state.NodeState;
+import org.apache.jackrabbit.core.state.PropertyState;
+import org.apache.jackrabbit.core.value.InternalValue;
+import org.apache.jackrabbit.spi.Name;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Set;
 
 import javax.jcr.Item;
 import javax.jcr.Node;
@@ -49,31 +60,47 @@
  */
 public class GarbageCollector {
 
-    private final ScanEventListener callback;
+    private ScanEventListener callback;
 
-    private final int sleepBetweenNodes;
+    private int sleepBetweenNodes;
     
     private int testDelay;
 
-    private DataStore store;
+    private final DataStore store;
 
     private long startScanTimestamp;
 
-    private ArrayList listeners = new ArrayList();
+    private final ArrayList listeners = new ArrayList();
+
+    private final IterablePersistenceManager[] pmList;
+    
+    private final Session[] sessionList;
 
     // TODO It should be possible to stop and restart a garbage collection scan.
-    // TODO It may be possible to delete files early, see rememberNode()
 
     /**
      * Create a new garbage collector. 
-     * To display the progress, a callback object may be used.
+     * This method is usually not called by the application, it is called
+     * by SessionImpl.createDataStoreGarbageCollector().
      * 
-     * @param callback if set, this is called while scanning
-     * @param sleepBetweenNodes the number of milliseconds to sleep in the main scan loop
(0 if the scan should run at full speed)
+     * @param list the persistence managers
      */
-    public GarbageCollector(ScanEventListener callback, int sleepBetweenNodes) {
-        this.sleepBetweenNodes = sleepBetweenNodes;
-        this.callback = callback;
+    public GarbageCollector(SessionImpl session, IterablePersistenceManager[] list, Session[]
sessionList) {
+        RepositoryImpl rep = (RepositoryImpl) session.getRepository();
+        store = rep.getDataStore();
+        this.pmList = list;
+        this.sessionList = sessionList;
+    }
+
+    /**
+     * Set the delay between scanning items.
+     * The main scan loop sleeps this many milliseconds after
+     * scanning a node. The default is 0, meaning the scan should run at full speed.
+     * 
+     * @param sleepBetweenNodes the number of milliseconds to sleep 
+     */
+    public void setSleepBetweenNodes(int millis) {
+        this.sleepBetweenNodes = millis;
     }
     
     /**
@@ -84,16 +111,44 @@
     public void setTestDelay(int testDelay) {
         this.testDelay = testDelay;
     }
+    
+    /**
+     * Set the event listener. If set, the event listener will be called 
+     * for each item that is scanned. This mechanism can be used
+     * to display the progress.
+     * 
+     * @param callback if set, this is called while scanning
+     */
+    public void setScanEventListener(ScanEventListener callback) {
+        this.callback = callback;
+    }
 
-    public void scan(Session session) throws RepositoryException,
-            IllegalStateException, IOException {
+    /**
+     * Scan the repository.
+     * 
+     * @throws RepositoryException
+     * @throws IllegalStateException
+     * @throws IOException
+     * @throws ItemStateException 
+     */
+    public void scan() throws RepositoryException,
+            IllegalStateException, IOException, ItemStateException {
         long now = System.currentTimeMillis();
         if (startScanTimestamp == 0) {
-            RepositoryImpl rep = (RepositoryImpl) session.getRepository();
-            store = rep.getDataStore();
             startScanTimestamp = now;
             store.updateModifiedDateOnAccess(startScanTimestamp);
         }
+        
+        if (pmList == null) {
+            for (int i = 0; i < sessionList.length; i++) {
+                scanNodes(sessionList[i]);
+            }
+        } else {
+            scanPersistenceManagers();
+        }
+    }
+    
+    private void scanNodes(Session session) throws UnsupportedRepositoryOperationException,
RepositoryException, IllegalStateException, IOException {
 
         // add a listener to get 'new' nodes
         // actually, new nodes are not the problem, but moved nodes
@@ -103,6 +158,30 @@
         // reading usually doesn't, but when scanning, it does
         recurse(session.getRootNode(), sleepBetweenNodes);
     }
+    
+    private void scanPersistenceManagers() throws ItemStateException, RepositoryException
{
+        for (int i = 0; i < pmList.length; i++) {
+            IterablePersistenceManager pm = pmList[i];
+            Iterator it = pm.getAllNodeIds(null, 0);
+            while (it.hasNext()) {
+                NodeId id = (NodeId) it.next();
+                NodeState state = pm.load(id);
+                Set propertyNames = state.getPropertyNames();
+                for (Iterator nameIt = propertyNames.iterator(); nameIt
+                        .hasNext();) {
+                    Name name = (Name) nameIt.next();
+                    PropertyId pid = new PropertyId(id, name);
+                    PropertyState ps = pm.load(pid);
+                    if (ps.getType() == PropertyType.BINARY) {
+                        InternalValue[] values = ps.getValues();
+                        for (int j = 0; j < values.length; j++) {
+                            values[j].getBLOBFileValue().getLength();
+                        }
+                    }
+                }
+            }
+        }
+    }
 
     public void stopScan() throws RepositoryException {
         checkScanStarted();
@@ -176,6 +255,7 @@
 
     private void rememberNode(String path) {
         // Do nothing at the moment
+        // TODO It may be possible to delete some items early
         /*
          * To delete files early in the garbage collection scan, we could do
          * this:

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java?rev=604872&r1=604871&r2=604872&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java
Mon Dec 17 06:02:28 2007
@@ -51,7 +51,7 @@
  * 
  * Configuration:<br>
  * <ul>
- * <li>&lt;param name="className" value="org.apache.jackrabbit.core.data.FileDataStore"/>
+ * <li>&lt;param name="className" value="org.apache.jackrabbit.core.data.db.DbDataStore"/>
  * <li>&lt;param name="{@link #setUrl(String) url}" value="jdbc:postgresql:test"/>
  * <li>&lt;param name="{@link #setUser(String) user}" value="sa"/>
  * <li>&lt;param name="{@link #setPassword(String) password}" value="sa"/>
@@ -157,25 +157,79 @@
      */
     protected String tablePrefix = "";
     
+    /**
+     * This is the property 'table'
+     * in the [databaseType].properties file, initialized with the default value.
+     */
     protected String tableSQL = "DATASTORE";
+    
+    /**
+     * This is the property 'createTable'
+     * in the [databaseType].properties file, initialized with the default value.
+     */
     protected String createTableSQL = 
         "CREATE TABLE ${tablePrefix}${table}(ID VARCHAR(255) PRIMARY KEY, LENGTH BIGINT,
LAST_MODIFIED BIGINT, DATA BLOB)";
+
+    /**
+     * This is the property 'insertTemp'
+     * in the [databaseType].properties file, initialized with the default value.
+     */
     protected String insertTempSQL = 
         "INSERT INTO ${tablePrefix}${table} VALUES(?, 0, ?, NULL)";
+
+    /**
+     * This is the property 'updateData'
+     * in the [databaseType].properties file, initialized with the default value.
+     */
     protected String updateDataSQL = 
         "UPDATE ${tablePrefix}${table} SET DATA=? WHERE ID=?";
+    
+    /**
+     * This is the property 'updateLastModified'
+     * in the [databaseType].properties file, initialized with the default value.
+     */
     protected String updateLastModifiedSQL = 
         "UPDATE ${tablePrefix}${table} SET LAST_MODIFIED=? WHERE ID=? AND LAST_MODIFIED<?";
+
+    /**
+     * This is the property 'update'
+     * in the [databaseType].properties file, initialized with the default value.
+     */
     protected String updateSQL = 
         "UPDATE ${tablePrefix}${table} SET ID=?, LENGTH=?, LAST_MODIFIED=? WHERE ID=? AND
NOT EXISTS(SELECT ID FROM ${tablePrefix}${table} WHERE ID=?)";
+
+    /**
+     * This is the property 'delete'
+     * in the [databaseType].properties file, initialized with the default value.
+     */
     protected String deleteSQL = 
         "DELETE FROM ${tablePrefix}${table} WHERE ID=?";
+    
+    /**
+     * This is the property 'deleteOlder'
+     * in the [databaseType].properties file, initialized with the default value.
+     */
     protected String deleteOlderSQL = 
         "DELETE FROM ${tablePrefix}${table} WHERE LAST_MODIFIED<?";
+    
+    /**
+     * This is the property 'selectMeta'
+     * in the [databaseType].properties file, initialized with the default value.
+     */
     protected String selectMetaSQL = 
         "SELECT LENGTH, LAST_MODIFIED FROM ${tablePrefix}${table} WHERE ID=?";
+    
+    /**
+     * This is the property 'selectAll'
+     * in the [databaseType].properties file, initialized with the default value.
+     */
     protected String selectAllSQL = 
         "SELECT ID FROM ${tablePrefix}${table}";
+
+    /**
+     * This is the property 'selectData'
+     * in the [databaseType].properties file, initialized with the default value.
+     */
     protected String selectDataSQL = 
         "SELECT ID, DATA FROM ${tablePrefix}${table} WHERE ID=?";
     
@@ -721,7 +775,9 @@
     
     protected ConnectionRecoveryManager getConnection() throws DataStoreException {
         try {
-            return (ConnectionRecoveryManager) connectionPool.get();
+            ConnectionRecoveryManager conn = (ConnectionRecoveryManager) connectionPool.get();
+            conn.setAutoReconnect(true);
+            return conn;
         } catch (InterruptedException e) {
             throw new DataStoreException("Interrupted", e);
         } catch (RepositoryException e) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/Pool.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/Pool.java?rev=604872&r1=604871&r2=604872&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/Pool.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/Pool.java
Mon Dec 17 06:02:28 2007
@@ -26,8 +26,6 @@
  * Implementation of a simple ConnectionRecoveryManager pool.
  * The maximum number of pooled objects can be set, and if more objects
  * are requested the pool waits until one object is put back.
- * 
- * @author Thomas Mueller
  */
 public class Pool {
     protected final int maxSize;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/TempFileInputStream.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/TempFileInputStream.java?rev=604872&r1=604871&r2=604872&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/TempFileInputStream.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/TempFileInputStream.java
Mon Dec 17 06:02:28 2007
@@ -11,8 +11,6 @@
 
 /**
  * An input stream from a temp file that self-destructs when fully read or closed.
- * 
- * @author Thomas Mueller
  */
 public class TempFileInputStream extends InputStream {
     

Added: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/IterablePersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/IterablePersistenceManager.java?rev=604872&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/IterablePersistenceManager.java
(added)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/IterablePersistenceManager.java
Mon Dec 17 06:02:28 2007
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.core.persistence;
+
+import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.NodeIdIterator;
+import org.apache.jackrabbit.core.state.ItemStateException;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * The iterable persistence manager can return the list of node ids that are stored.
+ * Possible applications are backup, migration (copying a workspace or repository),
+ * and data store garbage collection.
+ */
+public interface IterablePersistenceManager extends PersistenceManager {
+    
+    /**
+     * Get all node ids. 
+     * A typical application will call this method multiple times, where 'after'
+     * is the last row read. The maxCount parameter defines the maximum number of 
+     * node ids returned, 0 meaning no limit. The order of the node ids is specific for the

+     * given persistent manager. Items that are added concurrently may not be included.
+     * 
+     * @param after the lower limit, or null for no limit.
+     * @param maxCount the maximum number of node ids to return, or 0 for no limit.
+     * @return an iterator of all bundles.
+     * @throws ItemStateException if an error while loading occurs.
+     * @throws RepositoryException if a repository exception occurs
+     */
+    NodeIdIterator getAllNodeIds(NodeId after, int maxCount)
+            throws ItemStateException, RepositoryException;
+
+}

Propchange: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/IterablePersistenceManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java?rev=604872&r1=604871&r2=604872&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
Mon Dec 17 06:02:28 2007
@@ -29,11 +29,11 @@
 import org.apache.jackrabbit.core.state.PropertyState;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.core.NodeIdIterator;
 import org.apache.jackrabbit.core.PropertyId;
 import org.apache.jackrabbit.core.NamespaceRegistryImpl;
 import org.apache.jackrabbit.core.nodetype.PropDefId;
 import org.apache.jackrabbit.core.value.InternalValue;
+import org.apache.jackrabbit.core.persistence.IterablePersistenceManager;
 import org.apache.jackrabbit.core.persistence.PMContext;
 import org.apache.jackrabbit.core.persistence.PersistenceManager;
 import org.apache.jackrabbit.core.persistence.bundle.util.StringIndex;
@@ -52,7 +52,6 @@
 import java.util.Set;
 
 import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
 
 /**
  * The <code>AbstractBundlePersistenceManager</code> acts as base for all
@@ -83,7 +82,7 @@
  * </ul>
  */
 public abstract class AbstractBundlePersistenceManager implements 
-        PersistenceManager, CachingPersistenceManager {
+    PersistenceManager, CachingPersistenceManager, IterablePersistenceManager {
 
     /** the cvs/svn id */
     static final String CVS_ID = "$URL$ $Rev$ $Date$";
@@ -712,21 +711,5 @@
             bundles.put(bundle);
         }
     }
-
-    /**
-     * Get all node ids. 
-     * A typical application will call this method multiple times, where 'after'
-     * is the last row read. The maxCount parameter defines the maximum number of 
-     * node ids returned, 0 meaning no limit. The order of the node ids is specific for the

-     * given persistent manager. Items that are added concurrently may not be included.
-     * 
-     * @param after the lower limit, or null for no limit.
-     * @param maxCount the maximum number of node ids to return, or 0 for no limit.
-     * @return an iterator of all bundles.
-     * @throws ItemStateException if an error while loading occurs.
-     * @throws RepositoryException if a repository exception occurs
-     */
-    public abstract NodeIdIterator getAllNodeIds(NodeId after, int maxCount)
-            throws ItemStateException, RepositoryException;
 
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java?rev=604872&r1=604871&r2=604872&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
Mon Dec 17 06:02:28 2007
@@ -182,6 +182,15 @@
     public VirtualItemStateProvider getVirtualItemStateProvider() {
         return versProvider;
     }
+    
+    /**
+     * Return the persistence manager.
+     * 
+     * @return the persistence manager
+     */
+    public PersistenceManager getPersistenceManager() {
+        return pMgr;
+    }
 
     /**
      * {@inheritDoc}

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Dec 17 06:02:28 2007
@@ -0,0 +1 @@
+benchmark

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java?rev=604872&r1=604871&r2=604872&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java
Mon Dec 17 06:02:28 2007
@@ -17,6 +17,8 @@
 package org.apache.jackrabbit.core.data;
 
 import org.apache.jackrabbit.core.RepositoryImpl;
+import org.apache.jackrabbit.core.SessionImpl;
+import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.test.AbstractJCRTest;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -65,11 +67,12 @@
         session.save();
         Thread.sleep(1000);
         
-        GarbageCollector gc = new GarbageCollector(this, 0);
+        GarbageCollector gc = ((SessionImpl)session).createDataStoreGarbageCollector();
+        gc.setScanEventListener(this);
         gc.setTestDelay(1000);
         
         LOG.debug("scanning...");
-        gc.scan(session);
+        gc.scan();
         int count = listIdentifiers(gc);
         LOG.debug("stop scanning; currently " + count + " identifiers");
         gc.stopScan();
@@ -82,10 +85,11 @@
         deleteMyNodes();
     }
     
-    private void runGC(Session session, boolean all) throws RepositoryException, IOException
{
-        GarbageCollector gc = new GarbageCollector(this, 0);
+    private void runGC(Session session, boolean all) throws RepositoryException, IOException,
ItemStateException {
+        GarbageCollector gc = ((SessionImpl)session).createDataStoreGarbageCollector();
+        gc.setScanEventListener(this);
         gc.setTestDelay(1000);
-        gc.scan(session);
+        gc.scan();
         gc.stopScan();
         if (all) {
             gc.getDataStore().clearInUse();

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/PersistenceManagerIteratorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/PersistenceManagerIteratorTest.java?rev=604872&r1=604871&r2=604872&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/PersistenceManagerIteratorTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/PersistenceManagerIteratorTest.java
Mon Dec 17 06:02:28 2007
@@ -19,6 +19,8 @@
 import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.NodeIdIterator;
 import org.apache.jackrabbit.core.RepositoryImpl;
+import org.apache.jackrabbit.core.config.RepositoryConfig;
+import org.apache.jackrabbit.core.config.WorkspaceConfig;
 import org.apache.jackrabbit.core.persistence.PersistenceManager;
 import org.apache.jackrabbit.core.persistence.bundle.AbstractBundlePersistenceManager;
 import org.apache.jackrabbit.test.AbstractJCRTest;
@@ -27,6 +29,8 @@
 import org.slf4j.LoggerFactory;
 
 import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Iterator;
 
 import javax.jcr.Node;
 import javax.jcr.Repository;
@@ -52,15 +56,18 @@
             return;
         }
 
-        // TODO: make getWorkspaceNames public or create a utility class
-
         RepositoryImpl r = (RepositoryImpl) rep;
-        Method m = r.getClass().getDeclaredMethod("getWorkspaceNames",
-                new Class[0]);
-        m.setAccessible(true);
-        String[] names = (String[]) m.invoke(r, new Object[0]);
+        RepositoryConfig conf = r.getConfig();
+        Collection coll = conf.getWorkspaceConfigs();
+        String[] names = new String[coll.size()];
+        Iterator wspIt = coll.iterator();
+        for(int i = 0; wspIt.hasNext(); i++) {
+            WorkspaceConfig wsc = (WorkspaceConfig) wspIt.next();
+            names[i] = wsc.getName();
+        }
+
         for (int i = 0; i < names.length; i++) {
-            m = r.getClass().getDeclaredMethod("getWorkspaceInfo", new Class[] { String.class
});
+            Method m = r.getClass().getDeclaredMethod("getWorkspaceInfo", new Class[] { String.class
});
             m.setAccessible(true);
             Object info = m.invoke(r, new String[] { names[i] });
             m = info.getClass().getDeclaredMethod("getPersistenceManager", new Class[0]);



Mime
View raw message