diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/application/ApplicationImpl.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/application/ApplicationImpl.java index c8e7b7085..2ab2776a2 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/application/ApplicationImpl.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/application/ApplicationImpl.java @@ -210,9 +210,7 @@ public class ApplicationImpl implements Application { @Override public void shutdown() { - getFileStorage().shutdown(this); - getImageProcessor().shutdown(this); - getSearchEngine().shutdown(this); + // Nothing to do. } // ---------------------------------------------------------------------- diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/application/ApplicationSetup.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/application/ApplicationSetup.java index 21459ad3d..a6404e49c 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/application/ApplicationSetup.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/application/ApplicationSetup.java @@ -108,8 +108,6 @@ public class ApplicationSetup implements ServletContextListener { @Override public void contextDestroyed(ServletContextEvent sce) { - if (app != null) { - app.shutdown(); - } + // Nothing to do. } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/FilterByRoleLevelPermission.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/FilterByRoleLevelPermission.java index 9ac4905dc..548346da2 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/FilterByRoleLevelPermission.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/FilterByRoleLevelPermission.java @@ -129,7 +129,7 @@ public class FilterByRoleLevelPermission extends VitroFiltersImpl { /** * It would be nice if every ObjectPropertyStatement held a real * ObjectProperty. If it doesn't, we do the next best thing, but it - * won't recognize any applicaable Faux properties. + * won't recognize any applicable Faux properties. */ private ObjectProperty getOrCreateProperty(ObjectPropertyStatement ops) { if (ops.getProperty() != null) { diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/SearchIndexerImpl.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/SearchIndexerImpl.java index 66f7a55c6..727652447 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/SearchIndexerImpl.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/SearchIndexerImpl.java @@ -59,6 +59,8 @@ import edu.cornell.mannlib.vitro.webapp.searchindex.tasks.UpdateStatementsTask; import edu.cornell.mannlib.vitro.webapp.searchindex.tasks.UpdateUrisTask; import edu.cornell.mannlib.vitro.webapp.utils.configuration.ConfigurationBeanLoader; import edu.cornell.mannlib.vitro.webapp.utils.configuration.ConfigurationBeanLoaderException; +import edu.cornell.mannlib.vitro.webapp.utils.configuration.Property; +import edu.cornell.mannlib.vitro.webapp.utils.configuration.Validation; import edu.cornell.mannlib.vitro.webapp.utils.developer.DeveloperSettings; import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread; import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread.WorkLevel; @@ -73,6 +75,9 @@ import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread.Work * A thread pool is available so the tasks can create small units of work to be * run in parallel. Each task should block until all of its work units are * complete, to preserve the pattern of running one task at a time. + * + * The number of threads in the thread pool is specified in the application + * setup file. */ public class SearchIndexerImpl implements SearchIndexer { private static final Log log = LogFactory.getLog(SearchIndexerImpl.class); @@ -80,7 +85,9 @@ public class SearchIndexerImpl implements SearchIndexer { private final ListenerList listeners = new ListenerList(); private final TaskQueue taskQueue = new TaskQueue(); private final Scheduler scheduler = new Scheduler(taskQueue); - private final WorkerThreadPool pool = new WorkerThreadPool(); + + private Integer threadPoolSize; + private WorkerThreadPool pool; private ServletContext ctx; private List excluders; @@ -88,6 +95,27 @@ public class SearchIndexerImpl implements SearchIndexer { private Set uriFinders; private WebappDaoFactory wadf; + @Property(uri = "http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationSetup#threadPoolSize") + public void setThreadPoolSize(String size) { + if (threadPoolSize == null) { + threadPoolSize = Integer.parseInt(size); + } else { + throw new IllegalStateException( + "Configuration includes multiple values for threadPoolSize: " + + threadPoolSize + ", and " + size); + } + } + + @Validation + public void validate() throws Exception { + if (threadPoolSize == null) { + throw new IllegalStateException( + "Configuration did not include a value for threadPoolSize."); + } else { + this.pool = new WorkerThreadPool(threadPoolSize); + } + } + @Override public void startup(Application application, ComponentStartupStatus ss) { try { @@ -442,9 +470,9 @@ public class SearchIndexerImpl implements SearchIndexer { public static class WorkerThreadPool { private final ThreadPoolExecutor pool; - public WorkerThreadPool() { - this.pool = new ThreadPoolExecutor(10, 10, 10, TimeUnit.SECONDS, - new ArrayBlockingQueue(50), + public WorkerThreadPool(int threadPoolSize) { + this.pool = new ThreadPoolExecutor(threadPoolSize, threadPoolSize, + 10, TimeUnit.SECONDS, new ArrayBlockingQueue(50), new VitroBackgroundThread.Factory( "SearchIndexer_ThreadPool")); }