Author: mickw
Date: 2006-04-04 09:15:30 +0200 (Tue, 04 Apr 2006)
New Revision: 2699

Removed:
   trunk/src/webapp/WEB-INF/jboss-web.xml
Modified:
   trunk/pom.xml
   trunk/project.xml
   
trunk/src/java/no/schibstedsok/front/searchportal/command/AbstractSearchCommand.java
   trunk/src/java/no/schibstedsok/front/searchportal/command/SearchCommand.java
   
trunk/src/java/no/schibstedsok/front/searchportal/configuration/SearchMode.java
   
trunk/src/java/no/schibstedsok/front/searchportal/configuration/XMLSearchTabsCreator.java
   
trunk/src/java/no/schibstedsok/front/searchportal/executor/ParallelSearchCommandExecutor.java
   
trunk/src/java/no/schibstedsok/front/searchportal/executor/SearchCommandExecutor.java
   trunk/src/java/no/schibstedsok/front/searchportal/executor/SearchTask.java
   
trunk/src/java/no/schibstedsok/front/searchportal/executor/SearchTaskExecutorService.java
   
trunk/src/java/no/schibstedsok/front/searchportal/executor/SequentialSearchCommandExecutor.java
   
trunk/src/java/no/schibstedsok/front/searchportal/executor/ThreadPoolInspector.java
   
trunk/src/java/no/schibstedsok/front/searchportal/query/run/RunningQueryImpl.java
   trunk/src/java/no/schibstedsok/front/searchportal/servlet/SearchServlet.java
   
trunk/src/test/java/no/schibstedsok/front/searchportal/result/test/MockupSearchCommand.java
Log:
Java5's java.util.concurrent package now used!
Generics applied to the concurrent classes inside executor package.
Fix to tab variable being servlet instance member in SearchServlet.


Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml       2006-04-03 12:28:30 UTC (rev 2698)
+++ trunk/pom.xml       2006-04-04 07:15:30 UTC (rev 2699)
@@ -374,13 +374,6 @@
         </dependency>
 
         <dependency>
-            <groupId>backport-util-concurrent</groupId>
-            <artifactId>backport-util-concurrent</artifactId>
-            <version>2.0_01_pd</version>
-            <type>jar</type>
-        </dependency>
-
-        <dependency>
             <groupId>xstream</groupId>
             <artifactId>xstream</artifactId>
             <version>1.1.3</version>

Modified: trunk/project.xml
===================================================================
--- trunk/project.xml   2006-04-03 12:28:30 UTC (rev 2698)
+++ trunk/project.xml   2006-04-04 07:15:30 UTC (rev 2699)
@@ -299,15 +299,6 @@
             </properties>
         </dependency>
         <dependency>
-            <groupId>backport-util-concurrent</groupId>
-            <artifactId>backport-util-concurrent</artifactId>
-            <version>2.0_01_pd</version>
-            <type>jar</type>
-            <properties>
-                <war.bundle>true</war.bundle>
-            </properties>
-        </dependency>
-        <dependency>
             <groupId>xstream</groupId>
             <artifactId>xstream</artifactId>
             <version>1.1.3</version>

Modified: 
trunk/src/java/no/schibstedsok/front/searchportal/command/AbstractSearchCommand.java
===================================================================
--- 
trunk/src/java/no/schibstedsok/front/searchportal/command/AbstractSearchCommand.java
        2006-04-03 12:28:30 UTC (rev 2698)
+++ 
trunk/src/java/no/schibstedsok/front/searchportal/command/AbstractSearchCommand.java
        2006-04-04 07:15:30 UTC (rev 2699)
@@ -141,7 +141,7 @@
      * Called by thread executor
      * @return
      */
-    public Object call() {
+    public SearchResult call() {
         MDC.put(Site.NAME_KEY, context.getSite().getName());
 
         final String thread = Thread.currentThread().getName();

Modified: 
trunk/src/java/no/schibstedsok/front/searchportal/command/SearchCommand.java
===================================================================
--- 
trunk/src/java/no/schibstedsok/front/searchportal/command/SearchCommand.java    
    2006-04-03 12:28:30 UTC (rev 2698)
+++ 
trunk/src/java/no/schibstedsok/front/searchportal/command/SearchCommand.java    
    2006-04-04 07:15:30 UTC (rev 2699)
@@ -4,7 +4,7 @@
 */
 package no.schibstedsok.front.searchportal.command;
 
-import edu.emory.mathcs.backport.java.util.concurrent.Callable;
+import java.util.concurrent.Callable;
 import no.schibstedsok.common.ioc.BaseContext;
 import no.schibstedsok.front.searchportal.configuration.SearchConfiguration;
 import 
no.schibstedsok.front.searchportal.configuration.SearchConfigurationContext;
@@ -12,13 +12,14 @@
 import no.schibstedsok.front.searchportal.query.QueryContext;
 import no.schibstedsok.front.searchportal.query.run.RunningQuery;
 import no.schibstedsok.front.searchportal.query.run.RunningQueryContext;
+import no.schibstedsok.front.searchportal.result.SearchResult;
 import no.schibstedsok.front.searchportal.site.SiteContext;
 
 /**
  * @author <a href="mailto:[EMAIL PROTECTED]">Magnus Eklund</a>
  * @version <tt>$Revision$</tt>
  */
-public interface SearchCommand extends Callable {
+public interface SearchCommand extends Callable<SearchResult> {
 
     /** Being a factory for all the commands - it propagates all the 
contextual needs of the underlying commands it
      * creates.

Modified: 
trunk/src/java/no/schibstedsok/front/searchportal/configuration/SearchMode.java
===================================================================
--- 
trunk/src/java/no/schibstedsok/front/searchportal/configuration/SearchMode.java 
    2006-04-03 12:28:30 UTC (rev 2698)
+++ 
trunk/src/java/no/schibstedsok/front/searchportal/configuration/SearchMode.java 
    2006-04-04 07:15:30 UTC (rev 2699)
@@ -19,7 +19,7 @@
     private SearchCommandExecutor searchCommandExecutor = new 
SequentialSearchCommandExecutor();
     private String key;
 
-    private Collection searchConfigurations = new ArrayList();
+    private Collection<SearchConfiguration> searchConfigurations = new 
ArrayList<SearchConfiguration>();
     private String parentMode;
     private boolean queryAnalysisEnabled = false;
     
@@ -35,7 +35,7 @@
         this.key = key;
     }
 
-    public Collection getSearchConfigurations() {
+    public Collection<SearchConfiguration> getSearchConfigurations() {
         return searchConfigurations;
     }
 

Modified: 
trunk/src/java/no/schibstedsok/front/searchportal/configuration/XMLSearchTabsCreator.java
===================================================================
--- 
trunk/src/java/no/schibstedsok/front/searchportal/configuration/XMLSearchTabsCreator.java
   2006-04-03 12:28:30 UTC (rev 2698)
+++ 
trunk/src/java/no/schibstedsok/front/searchportal/configuration/XMLSearchTabsCreator.java
   2006-04-04 07:15:30 UTC (rev 2699)
@@ -11,6 +11,7 @@
 import com.thoughtworks.xstream.io.xml.DomDriver;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
 import javax.xml.parsers.DocumentBuilder;
 import no.schibstedsok.front.searchportal.configuration.loader.DocumentLoader;
 import 
no.schibstedsok.front.searchportal.configuration.loader.PropertiesLoader;
@@ -39,13 +40,8 @@
 
     private SearchTabs tabs;
 
-    /**
-     * No need to synchronise this. Worse that can happen is multiple 
identical INSTANCES are created at the same
-     * time. But only one will persist in the map.
-     *  There might be a reason to synchronise to avoid the multiple calls to 
the search-front-config context to obtain
-     * the resources to improve the performance. But I doubt this would gain 
much, if anything at all.
-     */
     private static final Map<Site,XMLSearchTabsCreator> INSTANCES = new 
HashMap<Site,XMLSearchTabsCreator>();
+    private static final ReentrantReadWriteLock INSTANCES_LOCK = new 
ReentrantReadWriteLock();
 
     private static final Log LOG = 
LogFactory.getLog(XMLSearchTabsCreator.class);
 
@@ -62,7 +58,9 @@
         propertyLoader = 
context.newPropertiesLoader(SearchConstants.CONFIGURATION_FILE, properties);
 
         initialiseXStream();
+        INSTANCES_LOCK.writeLock().lock();
         INSTANCES.put(context.getSite(), this);
+        INSTANCES_LOCK.writeLock().unlock();
     }
 
     public SearchTabs getSearchTabs() {
@@ -130,7 +128,11 @@
      **/
     public static SearchTabsCreator valueOf(final Context cxt) {
         final Site site = cxt.getSite();
+
+        INSTANCES_LOCK.readLock().lock();
         SearchTabsCreator instance = INSTANCES.get(site);
+        INSTANCES_LOCK.readLock().unlock();
+
         if (instance == null) {
             instance = new XMLSearchTabsCreator(cxt);
         }
@@ -165,4 +167,13 @@
         return stc;
     }
 
+    public static boolean remove(final Site site){
+
+        try{
+            INSTANCES_LOCK.writeLock().lock();
+            return null != INSTANCES.remove(site);
+        }finally{
+            INSTANCES_LOCK.writeLock().unlock();
+        }
+    }
 }

Modified: 
trunk/src/java/no/schibstedsok/front/searchportal/executor/ParallelSearchCommandExecutor.java
===================================================================
--- 
trunk/src/java/no/schibstedsok/front/searchportal/executor/ParallelSearchCommandExecutor.java
       2006-04-03 12:28:30 UTC (rev 2698)
+++ 
trunk/src/java/no/schibstedsok/front/searchportal/executor/ParallelSearchCommandExecutor.java
       2006-04-04 07:15:30 UTC (rev 2699)
@@ -1,8 +1,13 @@
 package no.schibstedsok.front.searchportal.executor;
 
-import edu.emory.mathcs.backport.java.util.concurrent.ExecutorService;
-import edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor;
-import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import no.schibstedsok.front.searchportal.result.SearchResult;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -15,12 +20,12 @@
  * @author <a href="mailto:[EMAIL PROTECTED]">Magnus Eklund</a>
  * @version <tt>$Revision$</tt>
  */
-public class ParallelSearchCommandExecutor implements SearchCommandExecutor {
+public final class ParallelSearchCommandExecutor implements 
SearchCommandExecutor {
 
     private static final int INSPECTOR_PERIOD = 300000;
 
     private transient static ExecutorService executor = new 
SearchTaskExecutorService();
-    private transient static Log log = 
LogFactory.getLog(ParallelSearchCommandExecutor.class);
+    private transient static Log LOG = 
LogFactory.getLog(ParallelSearchCommandExecutor.class);
     private transient static ThreadPoolInspector inspector = new 
ThreadPoolInspector((ThreadPoolExecutor) executor, INSPECTOR_PERIOD);
 
     /**
@@ -29,21 +34,27 @@
     public ParallelSearchCommandExecutor() {
     }
 
-    public List invokeAll(Collection callables, int timeoutInMillis)  {
+    public List<Future<SearchResult>> 
invokeAll(Collection<Callable<SearchResult>> callables, int timeoutInMillis)  {
+
+        final List<Future<SearchResult>> results = new 
ArrayList<Future<SearchResult>>();
         try {
-            return executor.invokeAll(callables, timeoutInMillis, 
TimeUnit.MILLISECONDS);
+            results.addAll( executor.invokeAll(callables, timeoutInMillis, 
TimeUnit.MILLISECONDS) );
+
+//            for( Callable<SearchResult> c : callables ){
+//                results.add( executor.submit(c) );
+//            }
         } catch (InterruptedException e) {
-            e.printStackTrace();  //To change body of catch statement use File 
| Settings | File Templates.
-            return null;
+            LOG.error(e);  //To change body of catch statement use File | 
Settings | File Templates.
         }
+        return results;
     }
 
     public void stop() {
-        log.info("Shutting down thread pool inspector");
+        LOG.info("Shutting down thread pool inspector");
         inspector.cancel();
         ThreadPoolExecutor threadPool = (ThreadPoolExecutor) executor;
-        log.info("Shutting down thread pool");
-        log.info(threadPool.getTaskCount() + " processed");
+        LOG.info("Shutting down thread pool");
+        LOG.info(threadPool.getTaskCount() + " processed");
         threadPool.shutdownNow();
     }
 }

Modified: 
trunk/src/java/no/schibstedsok/front/searchportal/executor/SearchCommandExecutor.java
===================================================================
--- 
trunk/src/java/no/schibstedsok/front/searchportal/executor/SearchCommandExecutor.java
       2006-04-03 12:28:30 UTC (rev 2698)
+++ 
trunk/src/java/no/schibstedsok/front/searchportal/executor/SearchCommandExecutor.java
       2006-04-04 07:15:30 UTC (rev 2699)
@@ -2,9 +2,12 @@
 
 import java.util.Collection;
 import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
+import no.schibstedsok.front.searchportal.result.SearchResult;
 
 /**
- * An object that executes a list of [EMAIL PROTECTED] 
edu.emory.mathcs.backport.java.util.concurrent.Callable} tasks.
+ * An object that executes a list of [EMAIL PROTECTED] 
java.util.concurrent.Callable} tasks.
  *
  * @author <a href="mailto:[EMAIL PROTECTED]">Magnus Eklund</a>
  * @version <tt>$Revision$</tt>
@@ -17,14 +20,15 @@
     void stop();
 
     /**
-     * Invoke all commands returning a list of [EMAIL PROTECTED] 
edu.emory.mathcs.backport.java.util.concurrent.Future}
+     * Invoke all commands returning a list of [EMAIL PROTECTED] 
java.util.concurrent.Future}
      * holding their results.
      *
-     * @param callables       The list of [EMAIL PROTECTED] 
edu.emory.mathcs.backport.java.util.concurrent.Callable} to execute.
+     * @param callables       The list of [EMAIL PROTECTED] 
java.util.concurrent.Callable} to execute.
      * @param timeoutInMillis The timeout in milliseconds
      * @return the list of Futures holding the results.
      * @throws InterruptedException
      */
-    List invokeAll(Collection callables, int timeoutInMillis) throws 
InterruptedException;
+    List<Future<SearchResult>> invokeAll(Collection<Callable<SearchResult>> 
callables, int timeoutInMillis)
+            throws InterruptedException;
 
 }

Modified: 
trunk/src/java/no/schibstedsok/front/searchportal/executor/SearchTask.java
===================================================================
--- trunk/src/java/no/schibstedsok/front/searchportal/executor/SearchTask.java  
2006-04-03 12:28:30 UTC (rev 2698)
+++ trunk/src/java/no/schibstedsok/front/searchportal/executor/SearchTask.java  
2006-04-04 07:15:30 UTC (rev 2699)
@@ -1,20 +1,20 @@
 package no.schibstedsok.front.searchportal.executor;
 
-import edu.emory.mathcs.backport.java.util.concurrent.ExecutionException;
-import edu.emory.mathcs.backport.java.util.concurrent.FutureTask;
-import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
-import edu.emory.mathcs.backport.java.util.concurrent.TimeoutException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.FutureTask;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 import no.schibstedsok.front.searchportal.command.SearchCommand;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import no.schibstedsok.front.searchportal.result.SearchResult;
+import org.apache.log4j.Logger;
 
 /**
  * @author <a href="mailto:[EMAIL PROTECTED]">Magnus Eklund</a>
  * @version <tt>$Revision$</tt>
  */
-public class SearchTask extends FutureTask {
+public class SearchTask extends FutureTask<SearchResult> {
 
-    private static Log log = 
LogFactory.getLog(SearchTaskExecutorService.class);
+    private static final Logger LOG = 
Logger.getLogger(SearchTaskExecutorService.class);
 
     private SearchCommand command;
 
@@ -29,35 +29,39 @@
     }
 
     public boolean cancel(boolean mayInterruptIfRunning) {
-        log.debug("Cancel called " + command);
+        LOG.debug("Cancel called " + command);
 
         return super.cancel(mayInterruptIfRunning);    //To change body of 
overridden methods use File | Settings | File Templates.
     }
 
-    public synchronized Object get() {
+    public synchronized SearchResult get() {
+
         try {
-            log.debug("Calling get on " + command);
+            LOG.debug("Calling get on " + command);
             return super.get();
+
         } catch (InterruptedException e) {
-            log.error("Search was interrupted " + command);
+            LOG.error("Search was interrupted " + command);
             return null;
         } catch (ExecutionException e) {
-            log.error("Search exited with error " + command, e);
+            LOG.error("Search exited with error " + command, e);
             return null;
         }
     }
 
-    public synchronized Object get(long timeout, TimeUnit unit) {
+    public synchronized SearchResult get(final long timeout, final TimeUnit 
unit) {
+
         try {
             return super.get(timeout, unit);
+
         } catch (InterruptedException e) {
-            log.error("Search was interrupted " + command);
+            LOG.error("Search was interrupted " + command);
             return null;
         } catch (ExecutionException e) {
-            log.error("Search exited with error ", e);
+            LOG.error("Search exited with error ", e);
             return null;
         } catch (TimeoutException e) {
-            log.error("Search timed out " + command);
+            LOG.error("Search timed out " + command);
             return null;
         }
     }

Modified: 
trunk/src/java/no/schibstedsok/front/searchportal/executor/SearchTaskExecutorService.java
===================================================================
--- 
trunk/src/java/no/schibstedsok/front/searchportal/executor/SearchTaskExecutorService.java
   2006-04-03 12:28:30 UTC (rev 2698)
+++ 
trunk/src/java/no/schibstedsok/front/searchportal/executor/SearchTaskExecutorService.java
   2006-04-04 07:15:30 UTC (rev 2699)
@@ -1,27 +1,34 @@
 package no.schibstedsok.front.searchportal.executor;
 
-import edu.emory.mathcs.backport.java.util.concurrent.*;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.SynchronousQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
 import no.schibstedsok.front.searchportal.command.SearchCommand;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import no.schibstedsok.front.searchportal.result.SearchResult;
+import org.apache.log4j.Logger;
 
 /**
  * @author <a href="mailto:[EMAIL PROTECTED]">Magnus Eklund</a>
  * @version <tt>$Revision$</tt>
  */
-public class SearchTaskExecutorService extends ThreadPoolExecutor {
+final class SearchTaskExecutorService extends ThreadPoolExecutor {
 
-    private static Log log = 
LogFactory.getLog(SearchTaskExecutorService.class);
+    private static final Logger LOG = 
Logger.getLogger(SearchTaskExecutorService.class);
 
     public SearchTaskExecutorService() {
         super(20, 100, 5L, TimeUnit.SECONDS, new SynchronousQueue());
     }
 
-    protected RunnableFuture newTaskFor(Callable callable) {
-        if (log.isDebugEnabled()) {
-            SearchCommand command = (SearchCommand) callable;
-            log.debug("Creating new search task " + 
command.getSearchConfiguration().getName());
+    protected SearchTask newTaskFor(Callable<SearchResult> callable) {
+
+        final SearchCommand command = (SearchCommand) callable;
+
+        if (LOG.isDebugEnabled()) {    
+            LOG.debug("Creating new search task " + 
command.getSearchConfiguration().getName());
         }
-        return new SearchTask((SearchCommand)callable);
+
+        return new SearchTask( command );
     }
 }

Modified: 
trunk/src/java/no/schibstedsok/front/searchportal/executor/SequentialSearchCommandExecutor.java
===================================================================
--- 
trunk/src/java/no/schibstedsok/front/searchportal/executor/SequentialSearchCommandExecutor.java
     2006-04-03 12:28:30 UTC (rev 2698)
+++ 
trunk/src/java/no/schibstedsok/front/searchportal/executor/SequentialSearchCommandExecutor.java
     2006-04-04 07:15:30 UTC (rev 2699)
@@ -4,7 +4,11 @@
  */
 package no.schibstedsok.front.searchportal.executor;
 
-import edu.emory.mathcs.backport.java.util.concurrent.Callable;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import no.schibstedsok.front.searchportal.command.SearchCommand;
+import no.schibstedsok.front.searchportal.result.SearchResult;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -19,31 +23,41 @@
  * @author <a href="mailto:[EMAIL PROTECTED]">Magnus Eklund</a>
  * @version <tt>$Revision$</tt>
  */
-public class SequentialSearchCommandExecutor implements SearchCommandExecutor {
+public final class SequentialSearchCommandExecutor implements 
SearchCommandExecutor {
 
     private static Log log = 
LogFactory.getLog(SequentialSearchCommandExecutor.class);
 
-    public List invokeAll(Collection callables, int timeoutInMillis) {
+    public List<Future<SearchResult>> 
invokeAll(Collection<Callable<SearchResult>> callables, int timeoutInMillis) {
 
-        List results = new ArrayList();
+        final List<Future<SearchResult>> results = new 
ArrayList<Future<SearchResult>>();
 
-        for (Iterator iterator = callables.iterator(); iterator.hasNext();) {
+        for (Callable<SearchResult> callable : callables) {
 
-            Callable callable = (Callable) iterator.next();
+            final SearchCommand command = (SearchCommand) callable;
+            try {
+                final SearchResult result = command.call();
 
-            try {
-                results.add(callable.call());
+                final SearchTask task = new SearchTask(command){
+                    public SearchResult get(final long timeout, final TimeUnit 
unit) {
+                        return get();
+                    }
+                    public boolean isDone() {
+                        return true;
+                    }
+                    public SearchResult get() {
+                        return result;
+                    }
+                };
+                results.add(task);
+            
             } catch (Exception e) {
-                log.error("Execution of callable failed", e);
+                log.error("Execution of search command failed", e);
             }
         }
 
         return results;
     }
 
-    public void start() {
-    }
-
     public void stop() {
     }
 }

Modified: 
trunk/src/java/no/schibstedsok/front/searchportal/executor/ThreadPoolInspector.java
===================================================================
--- 
trunk/src/java/no/schibstedsok/front/searchportal/executor/ThreadPoolInspector.java
 2006-04-03 12:28:30 UTC (rev 2698)
+++ 
trunk/src/java/no/schibstedsok/front/searchportal/executor/ThreadPoolInspector.java
 2006-04-04 07:15:30 UTC (rev 2699)
@@ -1,6 +1,6 @@
 package no.schibstedsok.front.searchportal.executor;
 
-import edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.ThreadPoolExecutor;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -18,17 +18,17 @@
     public ThreadPoolInspector(ThreadPoolExecutor threadPool, int msPeriod) {
         this.threadPool = threadPool;
         Timer t = new Timer();
-        log.info("Scheduling to run every " + msPeriod + "ms");
+        LOG.info("Scheduling to run every " + msPeriod + "ms");
         t.schedule(this, 0, msPeriod);
     }
 
-    private Log log = LogFactory.getLog(ThreadPoolInspector.class);
+    private static final Log LOG = 
LogFactory.getLog(ThreadPoolInspector.class);
 
     public void run() {
-        log.info("Thread pool size: " + threadPool.getPoolSize());
-        log.info("Largest size: " + threadPool.getLargestPoolSize());
-        log.info("Active threads: " + threadPool.getActiveCount());
-        log.info("Approx. task count: " + threadPool.getTaskCount());
-        log.info("Completed count: " + threadPool.getCompletedTaskCount());
+        LOG.info("Thread pool size: " + threadPool.getPoolSize());
+        LOG.info("Largest size: " + threadPool.getLargestPoolSize());
+        LOG.info("Active threads: " + threadPool.getActiveCount());
+        LOG.info("Approx. task count: " + threadPool.getTaskCount());
+        LOG.info("Completed count: " + threadPool.getCompletedTaskCount());
     }
 }

Modified: 
trunk/src/java/no/schibstedsok/front/searchportal/query/run/RunningQueryImpl.java
===================================================================
--- 
trunk/src/java/no/schibstedsok/front/searchportal/query/run/RunningQueryImpl.java
   2006-04-03 12:28:30 UTC (rev 2698)
+++ 
trunk/src/java/no/schibstedsok/front/searchportal/query/run/RunningQueryImpl.java
   2006-04-04 07:15:30 UTC (rev 2699)
@@ -5,7 +5,8 @@
 package no.schibstedsok.front.searchportal.query.run;
 
 
-import edu.emory.mathcs.backport.java.util.concurrent.CancellationException;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CancellationException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -15,6 +16,7 @@
 import java.util.Locale;
 import java.util.Map;
 import java.util.Vector;
+import java.util.concurrent.Future;
 import no.schibstedsok.common.ioc.BaseContext;
 import no.schibstedsok.common.ioc.ContextWrapper;
 import no.schibstedsok.front.searchportal.QueryTokenizer;
@@ -174,25 +176,21 @@
 
         try {
 
-            final Collection<SearchCommand> commands = new 
ArrayList<SearchCommand>();
+            final Collection<Callable<SearchResult>> commands = new 
ArrayList<Callable<SearchResult>>();
 
-            for (final Iterator iterator = 
context.getSearchMode().getSearchConfigurations().iterator(); 
iterator.hasNext();) {
-                final SearchConfiguration searchConfiguration = 
(SearchConfiguration) iterator.next();
+            for (SearchConfiguration searchConfiguration : 
context.getSearchMode().getSearchConfigurations() ) {
 
+                final SearchConfiguration sc = searchConfiguration;
                 final SearchCommand.Context searchCmdCxt = ContextWrapper.wrap(
                         SearchCommand.Context.class,
                             context,
-                            new SearchConfigurationContext() {
+                            new BaseContext() {
                                 public SearchConfiguration 
getSearchConfiguration() {
-                                    return searchConfiguration;
+                                    return sc;
                                 }
-                            },
-                            new RunningQueryContext() {
                                 public RunningQuery getRunningQuery() {
                                     return RunningQueryImpl.this;
                                 }
-                            },
-                            new QueryContext() {
                                 public Query getQuery() {
                                     return queryObj;
                                 }
@@ -251,38 +249,37 @@
 
             LOG.debug("run(): InvokeAll Commands.size=" + commands.size());
 
-            final List<SearchTask> results = 
context.getSearchMode().getExecutor().invokeAll(commands, 10000);
+            final List<Future<SearchResult>> results = 
context.getSearchMode().getExecutor().invokeAll(commands, 10000);
 
             // TODO This loop-(task.isDone()) code should become individual 
listeners to each executor to minimise time
             //  spent in task.isDone()
             boolean hitsToShow = false;
-            for (SearchTask task : results) {
+            for (Future<SearchResult> task : results) {
+                
+                if (task.isDone()) {
 
-                final SearchCommand command = task.getCommand();
-                final SearchConfiguration configuration = 
command.getSearchConfiguration();
+                    final SearchResult searchResult = task.get();
 
-                if (task.isDone()) {
-                    try {
-                        final SearchResult searchResult = (SearchResult) 
task.get();
+                    if (searchResult != null) {
 
-                        if (searchResult != null) {
-                            hitsToShow |= searchResult.getHitCount() > 0;
+                        final SearchCommand command = 
searchResult.getSearchCommand();
+                        final SearchConfiguration configuration = 
command.getSearchConfiguration();
 
-                            hits.put(configuration.getName(), 
Integer.valueOf(searchResult.getHitCount()));
+                        hitsToShow |= searchResult.getHitCount() > 0;
 
-                            final Integer score = 
scores.get(task.getCommand().getSearchConfiguration().getName());
+                        hits.put(configuration.getName(), 
Integer.valueOf(searchResult.getHitCount()));
 
-                            if (score != null && configuration.getRule() != 
null && score.intValue() >= configuration.getRuleThreshold()) {
-                                if (searchResult.getResults().size() > 0 && 
score.intValue() > 15) {
-                                    final Enrichment e = new 
Enrichment(score.intValue(), configuration.getName());
-                                    enrichments.add(e);
-                                }
+                        final Integer score = 
scores.get(configuration.getName());
+
+                        if (score != null && configuration.getRule() != null 
&& score.intValue() >= configuration.getRuleThreshold()) {
+                            if (searchResult.getResults().size() > 0 && 
score.intValue() > 15) {
+                                final Enrichment e = new 
Enrichment(score.intValue(), configuration.getName());
+                                enrichments.add(e);
                             }
                         }
-                    } catch (CancellationException e) {
-                        LOG.error("Task was cancelled " + task.getCommand());
                     }
                 }
+
             }
 
             Collections.sort(sources);

Modified: 
trunk/src/java/no/schibstedsok/front/searchportal/servlet/SearchServlet.java
===================================================================
--- 
trunk/src/java/no/schibstedsok/front/searchportal/servlet/SearchServlet.java    
    2006-04-03 12:28:30 UTC (rev 2698)
+++ 
trunk/src/java/no/schibstedsok/front/searchportal/servlet/SearchServlet.java    
    2006-04-04 07:15:30 UTC (rev 2699)
@@ -37,8 +37,8 @@
     private static final long serialVersionUID = 3068140845772756438L;
 
     private static final Logger LOG = Logger.getLogger(SearchServlet.class);
+    private static final String WARN_TABS_CLEANED = " status on cleaning tabs 
for ";
 
-
     private SearchTabs tabs;
 
     /** [EMAIL PROTECTED]
@@ -82,16 +82,13 @@
         }
 
         final Site site = (Site) 
httpServletRequest.getAttribute(Site.NAME_KEY);
+        final boolean forceReload = 
"tabs".equals(httpServletRequest.getParameter("reload"));
 
-        if (tabs == null
-                || (httpServletRequest.getParameter("reload") != null
-                        && 
httpServletRequest.getParameter("reload").equals("tabs"))) {
-
-            LOG.info("doGet(): ReLoading tabs");
-
-            tabs = loadSearchTabs(site);
-            LOG.warn("Tabs reloaded");
+        if( forceReload ){
+            final boolean cleaned = XMLSearchTabsCreator.remove(site);
+            LOG.warn(cleaned + WARN_TABS_CLEANED + site);
         }
+        final SearchTabs tabs = 
XMLSearchTabsCreator.valueOf(site).getSearchTabs();
 
         final String xmlParam = httpServletRequest.getParameter("xml");
 
@@ -174,10 +171,5 @@
             LOG.info("doGet(): Search took " + stopWatch + " " + 
query.getQueryString());
         }
     }
-    
-    private SearchTabs loadSearchTabs(final Site site) {
-        return XMLSearchTabsCreator.valueOf(site).getSearchTabs();
-    }
 
-
 }

Modified: 
trunk/src/test/java/no/schibstedsok/front/searchportal/result/test/MockupSearchCommand.java
===================================================================
--- 
trunk/src/test/java/no/schibstedsok/front/searchportal/result/test/MockupSearchCommand.java
 2006-04-03 12:28:30 UTC (rev 2698)
+++ 
trunk/src/test/java/no/schibstedsok/front/searchportal/result/test/MockupSearchCommand.java
 2006-04-04 07:15:30 UTC (rev 2699)
@@ -73,7 +73,7 @@
         return null;  //To change body of implemented methods use File | 
Settings | File Templates.
     }
 
-    public Object call() throws Exception {
+    public SearchResult call() throws Exception {
         return null;
     }
 }

Deleted: trunk/src/webapp/WEB-INF/jboss-web.xml
===================================================================
--- trunk/src/webapp/WEB-INF/jboss-web.xml      2006-04-03 12:28:30 UTC (rev 
2698)
+++ trunk/src/webapp/WEB-INF/jboss-web.xml      2006-04-04 07:15:30 UTC (rev 
2699)
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<jboss-web>
-  <!-- Uncomment the security-domain to enable security. You will
-       need to edit the htmladaptor login configuration to setup the
-       login modules used to authentication users.
-       <security-domain>java:/jaas/jua</security-domain>
-    -->
-  <context-root>/</context-root>
-</jboss-web>

_______________________________________________
Kernel-commits mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-commits

Reply via email to