Skip to content
Snippets Groups Projects
Commit 7e80a293 authored by srosse's avatar srosse
Browse files

OO-1522: make the number of threads in the indexer pool configurable, set the...

OO-1522: make the number of threads in the indexer pool configurable, set the priority of these threads the minimal
parent 1e74461a
No related branches found
No related tags found
No related merge requests found
......@@ -130,7 +130,7 @@
<!-- Files bigger than maxFileSize (and on fileSizeSuffixes-list) will be excluded from index -->
maxFileSize=10485760
<!-- Control indexer prozess -->
folderPoolSize=4
folderPoolSize=${search.folder.pool.size}
<!-- Define automatic restart time window e.g. 01:00-02:59 restartWindowStart=1 restartWindowEnd=3 -->
restartWindowStart=${restart.window.start}
restartWindowEnd=${restart.window.end}
......
......@@ -40,8 +40,10 @@ import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.lucene.LucenePackage;
......@@ -79,6 +81,8 @@ public class OlatFullIndexer {
private static final OLog log = Tracing.createLoggerFor(OlatFullIndexer.class);
private static final int INDEX_MERGE_FACTOR = 1000;
private static final int MAX_WAITING_COUNT = 600;// = 10Min
private static final IndexerThreadFactory indexWriterThreadFactory = new IndexerThreadFactory("writer");
private static final IndexerThreadFactory indexWorkersThreadFactory = new IndexerThreadFactory("worker");
private String indexPath;
private String tempIndexPath;
......@@ -232,11 +236,11 @@ public class OlatFullIndexer {
if(indexerExecutor == null) {
BlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>(2);
indexerExecutor = new ThreadPoolExecutor(indexerPoolSize, indexerPoolSize, 0L, TimeUnit.MILLISECONDS,
queue, new ThreadPoolExecutor.CallerRunsPolicy());
queue, indexWorkersThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy());
}
if(indexerWriterExecutor == null) {
BlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>(2);
indexerWriterExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, queue);
indexerWriterExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, queue, indexWriterThreadFactory);
}
File tempIndexDir = new File(tempIndexPath);
......@@ -488,4 +492,32 @@ public class OlatFullIndexer {
return Boolean.TRUE;
}
}
private static class IndexerThreadFactory implements ThreadFactory {
private static final AtomicInteger poolNumber = new AtomicInteger(1);
private final ThreadGroup group;
private final AtomicInteger threadNumber = new AtomicInteger(1);
private final String namePrefix;
IndexerThreadFactory(String prefix) {
SecurityManager s = System.getSecurityManager();
group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
namePrefix = "index-" + prefix + "-" +
poolNumber.getAndIncrement() +
"-thread-";
}
public Thread newThread(Runnable r) {
Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0);
if (t.isDaemon()) {
t.setDaemon(false);
}
if (t.getPriority() != Thread.MIN_PRIORITY) {
t.setPriority(Thread.MIN_PRIORITY);
}
return t;
}
}
}
......@@ -693,6 +693,9 @@ search.indexing.cronjob.expression=0 0 3 * * ?
#examples:
# never fire: 0 0 0 1 1 ? 3000
# size of the thread pools for the text extractors
search.folder.pool.size=4
########################################################################
# REST API
########################################################################
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment