jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r492164 - in /jackrabbit/trunk/jackrabbit-core: applications/test/workspaces/default/workspace.xml src/main/config/repository.xml src/main/java/org/apache/jackrabbit/core/SearchManager.java
Date Wed, 03 Jan 2007 14:43:04 GMT
Author: mreutegg
Date: Wed Jan  3 06:43:02 2007
New Revision: 492164

URL: http://svn.apache.org/viewvc?view=rev&rev=492164
Log:
JCR-694: Remove query handler idleTime

Modified:
    jackrabbit/trunk/jackrabbit-core/applications/test/workspaces/default/workspace.xml
    jackrabbit/trunk/jackrabbit-core/src/main/config/repository.xml
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SearchManager.java

Modified: jackrabbit/trunk/jackrabbit-core/applications/test/workspaces/default/workspace.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/applications/test/workspaces/default/workspace.xml?view=diff&rev=492164&r1=492163&r2=492164
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/applications/test/workspaces/default/workspace.xml (original)
+++ jackrabbit/trunk/jackrabbit-core/applications/test/workspaces/default/workspace.xml Wed
Jan  3 06:43:02 2007
@@ -36,11 +36,6 @@
   -->
   <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
     <param name="path" value="${wsp.home}/index" />
-    <!--
-        Set to zero for test purpose. This is *not* recommended at all for a
-        real system!
-    -->
-    <param name="idleTime" value="0"/>
   </SearchIndex>
 </Workspace>
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/config/repository.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/config/repository.xml?view=diff&rev=492164&r1=492163&r2=492164
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/config/repository.xml (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/config/repository.xml Wed Jan  3 06:43:02 2007
@@ -96,9 +96,6 @@
             - analyzer: class name of a lucene analyzer to use for fulltext indexing of text.
             - queryClass: class name that implements the javax.jcr.query.Query interface.
               this class must extend the class: org.apache.jackrabbit.core.query.AbstractQueryImpl
-            - idleTime: idle time in seconds after which an unused query handler is shut
down.
-              If the query handler is later used again it is automatically started.
-              Default value -1 disables this feature.
             - respectDocumentOrder: If true and the query does not contain an 'order by'
clause,
               result nodes will be in document order. For better performance when queries
return
               a lot of nodes set to 'false'.
@@ -123,7 +120,6 @@
             <param name="autoRepair" value="true"/>
             <param name="analyzer" value="org.apache.lucene.analysis.standard.StandardAnalyzer"/>
             <param name="queryClass" value="org.apache.jackrabbit.core.query.QueryImpl"/>
-            <param name="idleTime" value="-1"/>
             <param name="respectDocumentOrder" value="true"/>
             <param name="resultFetchSize" value="2147483647"/>
         </SearchIndex>

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SearchManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SearchManager.java?view=diff&rev=492164&r1=492163&r2=492164
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SearchManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SearchManager.java
Wed Jan  3 06:43:02 2007
@@ -33,7 +33,6 @@
 import org.apache.jackrabbit.name.NoPrefixDeclaredException;
 import org.apache.jackrabbit.name.Path;
 import org.apache.jackrabbit.name.PathFormat;
-import org.apache.jackrabbit.util.Timer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -45,15 +44,12 @@
 import javax.jcr.query.Query;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.Properties;
 import java.util.Set;
-import java.util.WeakHashMap;
 
 /**
  * Acts as a global entry point to execute queries and index nodes.
@@ -94,23 +90,6 @@
     private static final String DEFAULT_QUERY_IMPL_CLASS = QueryImpl.class.getName();
 
     /**
-     * Class instance that is shared for all <code>SearchManager</code> instances.
-     * Each workspace will schedule a task to check if the query handler can
-     * be shutdown after it had been idle for some time.
-     */
-    private static final Timer IDLE_TIMER = new Timer(true);
-
-    /**
-     * Idle time in seconds after which the query handler is shut down.
-     */
-    private static final int DEFAULT_IDLE_TIME = -1;
-
-    /**
-     * The time when the query handler was last accessed.
-     */
-    private long lastAccess = System.currentTimeMillis();
-
-    /**
      * The search configuration.
      */
     private final SearchConfig config;
@@ -169,29 +148,6 @@
     private final String queryImplClassName;
 
     /**
-     * Task that checks if the query handler can be shut down because it
-     * had been idle for {@link #idleTime} seconds.
-     */
-    private final Timer.Task idleChecker;
-
-    /**
-     * Idle time in seconds. After the query handler had been idle for this
-     * amount of time it is shut down. Defaults to -1 and causes the search
-     * manager to never shut down.
-     */
-    private int idleTime;
-
-    /**
-     * Weakly references all {@link javax.jcr.query.Query} instances created
-     * by this <code>SearchManager</code>.
-     * If this map is empty and this search manager had been idle for at least
-     * {@link #idleTime} seconds, then the query handler is shut down.
-     */
-    private final Map activeQueries = Collections.synchronizedMap(new WeakHashMap() {
-
-    });
-
-    /**
      * Creates a new <code>SearchManager</code>.
      *
      * @param config the search configuration.
@@ -232,11 +188,10 @@
 
         Properties params = config.getParameters();
         queryImplClassName = params.getProperty(PARAM_QUERY_IMPL, DEFAULT_QUERY_IMPL_CLASS);
-        String idleTimeString = params.getProperty(PARAM_IDLE_TIME, String.valueOf(DEFAULT_IDLE_TIME));
-        try {
-            idleTime = Integer.decode(idleTimeString).intValue();
-        } catch (NumberFormatException e) {
-            idleTime = DEFAULT_IDLE_TIME;
+        if (params.containsKey(PARAM_IDLE_TIME)) {
+            String msg = "Parameter 'idleTime' is not supported anymore. " +
+                    "Please use 'maxIdleTime' in the repository configuration.";
+            log.warn(msg);
         }
 
         if (excludedNodeId != null) {
@@ -246,28 +201,6 @@
 
         // initialize query handler
         initializeQueryHandler();
-
-        idleChecker = new Timer.Task() {
-            public void run() {
-                if (lastAccess + (idleTime * 1000) < System.currentTimeMillis()) {
-                    int inUse = activeQueries.size();
-                    if (inUse == 0) {
-                        try {
-                            shutdownQueryHandler();
-                        } catch (IOException e) {
-                            log.warn("Unable to shutdown idle query handler", e);
-                        }
-                    } else {
-                        log.debug("SearchManager is idle but " + inUse
-                                + " queries are still in use.");
-                    }
-                }
-            }
-        };
-
-        if (idleTime > -1) {
-            IDLE_TIMER.schedule(idleChecker, 0, 1000);
-        }
     }
 
     /**
@@ -276,7 +209,6 @@
      */
     public void close() {
         try {
-            idleChecker.cancel();
             shutdownQueryHandler();
 
             if (fs != null) {
@@ -307,7 +239,6 @@
                              String statement,
                              String language)
             throws InvalidQueryException, RepositoryException {
-        ensureInitialized();
         AbstractQueryImpl query = createQueryInstance();
         query.init(session, itemMgr, handler, statement, language);
         return query;
@@ -329,7 +260,6 @@
                              ItemManager itemMgr,
                              Node node)
             throws InvalidQueryException, RepositoryException {
-        ensureInitialized();
         AbstractQueryImpl query = createQueryInstance();
         query.init(session, itemMgr, handler, node);
         return query;
@@ -447,7 +377,6 @@
 
         if (removedNodes.size() > 0 || addedNodes.size() > 0) {
             try {
-                ensureInitialized();
                 handler.updateNodes(removedIds, addedStates);
             } catch (RepositoryException e) {
                 log.error("Error indexing node.", e);
@@ -475,8 +404,6 @@
         try {
             Object obj = Class.forName(queryImplClassName).newInstance();
             if (obj instanceof AbstractQueryImpl) {
-                // track query instances
-                activeQueries.put(obj, null);
                 return (AbstractQueryImpl) obj;
             } else {
                 throw new IllegalArgumentException(queryImplClassName
@@ -514,23 +441,10 @@
      * @throws IOException if an error occurs while shutting down the query
      *                     handler.
      */
-    private synchronized void shutdownQueryHandler() throws IOException {
+    private void shutdownQueryHandler() throws IOException {
         if (handler != null) {
             handler.close();
             handler = null;
-        }
-    }
-
-    /**
-     * Ensures that the query handler is initialized and updates the last
-     * access to the current time.
-     *
-     * @throws RepositoryException if the query handler cannot be initialized.
-     */
-    private synchronized void ensureInitialized() throws RepositoryException {
-        lastAccess = System.currentTimeMillis();
-        if (handler == null) {
-            initializeQueryHandler();
         }
     }
 }



Mime
View raw message