You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by th...@apache.org on 2009/09/15 16:11:46 UTC

svn commit: r815339 - in /jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api: ./ management/

Author: thomasm
Date: Tue Sep 15 14:11:46 2009
New Revision: 815339

URL: http://svn.apache.org/viewvc?rev=815339&view=rev
Log:
JCR-1865 Add the Data Store to the Jackrabbit API

Added:
    jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/JackrabbitRepositoryFactory.java
    jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/management/
    jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/management/DataStoreGarbageCollector.java
    jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/management/MarkEventListener.java
    jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/management/RepositoryManager.java
Modified:
    jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/JackrabbitSession.java
    jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/JackrabbitValue.java

Added: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/JackrabbitRepositoryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/JackrabbitRepositoryFactory.java?rev=815339&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/JackrabbitRepositoryFactory.java (added)
+++ jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/JackrabbitRepositoryFactory.java Tue Sep 15 14:11:46 2009
@@ -0,0 +1,37 @@
+/*
+ * 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.api;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.RepositoryFactory;
+import org.apache.jackrabbit.api.management.RepositoryManager;
+
+/**
+ * Classes that implement this interface additionally provide management features.
+ */
+public interface JackrabbitRepositoryFactory extends RepositoryFactory {
+
+    /**
+     * Get the repository management component. Only the factory that created
+     * the given repository may retrieve the manager.
+     *
+     * @param repository the repository to manage
+     * @return the manager
+     */
+    RepositoryManager getRepositoryManager(JackrabbitRepository repository) throws RepositoryException;
+
+}

Modified: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/JackrabbitSession.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/JackrabbitSession.java?rev=815339&r1=815338&r2=815339&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/JackrabbitSession.java (original)
+++ jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/JackrabbitSession.java Tue Sep 15 14:11:46 2009
@@ -54,4 +54,5 @@
      * @see UserManager
      */
     UserManager getUserManager() throws AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException;
+
 }
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/JackrabbitValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/JackrabbitValue.java?rev=815339&r1=815338&r2=815339&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/JackrabbitValue.java (original)
+++ jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/JackrabbitValue.java Tue Sep 15 14:11:46 2009
@@ -48,9 +48,9 @@
      * The identifier is opaque, meaning it can have any format and size, however
      * it is at normally about 50 characters and at most 255 characters long.
      * The string only contains Unicode code points from 32 to 127 (including).
-     * 
+     *
      * @return the unique identifier or null
      */
-    public String getContentIdentity();
+    String getContentIdentity();
 
 }

Added: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/management/DataStoreGarbageCollector.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/management/DataStoreGarbageCollector.java?rev=815339&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/management/DataStoreGarbageCollector.java (added)
+++ jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/management/DataStoreGarbageCollector.java Tue Sep 15 14:11:46 2009
@@ -0,0 +1,104 @@
+/*
+ * 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.api.management;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * Garbage collector for DataStore. This implementation is iterates through all
+ * nodes and reads the binary properties. To detect nodes that are moved while
+ * the scan runs, event listeners are started. Like the well known garbage
+ * collection in Java, the items that are still in use are marked. Currently
+ * this achieved by updating the modified date of the entries. Newly added
+ * entries are detected because the modified date is changed when they are
+ * added.
+ * <p>
+ * Example code to run the data store garbage collection:
+ * <pre>
+ * DataStoreGarbageCollector gc = ((JackrabbitSession)session).createDataStoreGarbageCollector();
+ * gc.mark();
+ * gc.sweep();
+ * </pre>
+ */
+public interface DataStoreGarbageCollector {
+
+    /**
+     * 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 millis the number of milliseconds to sleep
+     */
+    void setSleepBetweenNodes(long millis);
+
+    /**
+     * Get the delay between scanning items.
+     *
+     * @return the number of milliseconds to sleep
+     */
+    long getSleepBetweenNodes();
+
+    /**
+     * 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
+     */
+    void setMarkEventListener(MarkEventListener callback);
+
+    /**
+     * Enable or disable using the IterablePersistenceManager interface
+     * to scan the items. This is important for clients that need
+     * the complete Node implementation in the ScanEventListener
+     * callback.
+     *
+     * @param allow true if using the IterablePersistenceManager interface is allowed
+     */
+    void setPersistenceManagerScan(boolean allow);
+
+    /**
+     * Check if using the IterablePersistenceManager interface is allowed.
+     *
+     * @return true if using IterablePersistenceManager is possible.
+     */
+    boolean isPersistenceManagerScan();
+
+    /**
+     * Scan the repository. The garbage collector will iterate over all nodes in the repository
+     * and update the last modified date. If all persistence managers implement the
+     * IterablePersistenceManager interface, this mechanism is used; if not, the garbage
+     * collector scans the repository using the JCR API starting from the root node.
+     *
+     * @throws RepositoryException
+     */
+    void mark() throws RepositoryException;
+
+    /**
+     * Delete all unused items in the data store.
+     *
+     * @return the number of deleted items
+     * @throws RepositoryException
+     */
+    int sweep() throws RepositoryException;
+
+    /**
+     * Cleanup resources used internally by this instance.
+     */
+    void close();
+
+}

Added: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/management/MarkEventListener.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/management/MarkEventListener.java?rev=815339&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/management/MarkEventListener.java (added)
+++ jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/management/MarkEventListener.java Tue Sep 15 14:11:46 2009
@@ -0,0 +1,32 @@
+/*
+ * 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.api.management;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+/**
+ * The listener interface for receiving garbage collection scan events.
+ */
+public interface MarkEventListener {
+
+    /**
+     * This method is called before a node is scanned.
+     */
+    void beforeScanning(Node n) throws RepositoryException;
+
+}
\ No newline at end of file

Added: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/management/RepositoryManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/management/RepositoryManager.java?rev=815339&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/management/RepositoryManager.java (added)
+++ jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/management/RepositoryManager.java Tue Sep 15 14:11:46 2009
@@ -0,0 +1,50 @@
+/*
+ * 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.api.management;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * The repository manager provides life-cycle management features for
+ * repositories.
+ *
+ * Not all implementations are required to implement all features,
+ * for example some implementations may not support starting a repository after
+ * is has been stopped.
+ */
+public interface RepositoryManager {
+
+    /**
+     * Shuts down the repository. A Jackrabbit repository instance contains
+     * a acquired resources and cached data that needs to be released and
+     * persisted when the repository is no longer used. This method handles
+     * all these shutdown tasks and <em>should</em> therefore be called by the
+     * client application once the repository instance is no longer used.
+     * <p>
+     * Possible errors are logged rather than thrown as exceptions as there
+     * is little that a client application could do in such a case.
+     */
+    void stop();
+
+    /**
+     * Create a data store garbage collector for this repository.
+     *
+     * @return the data store garbage collector if the data store is enabled, null otherwise
+     */
+    DataStoreGarbageCollector createDataStoreGarbageCollector() throws RepositoryException;
+
+}