org.opencms.search
Class CmsIndexingThreadManager

java.lang.Object
  extended byjava.lang.Thread
      extended byorg.opencms.search.CmsIndexingThreadManager
All Implemented Interfaces:
Runnable

public class CmsIndexingThreadManager
extends Thread

Implements the management of indexing threads.

Since:
6.0.0
Version:
$Revision: 1.21 $
Author:
Carsten Weinholz

Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
CmsIndexingThreadManager(I_CmsReport report, long timeout, String indexName)
          Creates and starts a thread manager for indexing threads.
 
Method Summary
 void createIndexingThread(CmsObject cms, IndexWriter writer, A_CmsIndexResource res, CmsSearchIndex index)
          Creates and starts a new indexing thread for a resource.
 void finished()
          Signals the thread manager that a thread has finished its job and will exit immediately.
 int getCounter()
          Gets the current thread (file) count.
 boolean isRunning()
          Returns if the indexing manager still have indexing threads.
 void reportStatistics()
          Writes statistical information to the report.
 void run()
          Starts the thread manager to look for non-terminated threads
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CmsIndexingThreadManager

public CmsIndexingThreadManager(I_CmsReport report,
                                long timeout,
                                String indexName)
Creates and starts a thread manager for indexing threads.

Parameters:
report - the report to write out progress information
timeout - timeout after a thread is abandoned
indexName - the name of the index
Method Detail

createIndexingThread

public void createIndexingThread(CmsObject cms,
                                 IndexWriter writer,
                                 A_CmsIndexResource res,
                                 CmsSearchIndex index)
Creates and starts a new indexing thread for a resource.

After an indexing thread was started, the manager suspends itself and waits for an amount of time specified by the timeout value. If the timeout value is reached, the indexing thread is aborted by an interrupt signal.

Parameters:
cms - the cms object
writer - the write to write the index
res - the resource
index - the index

finished

public void finished()
Signals the thread manager that a thread has finished its job and will exit immediately.


getCounter

public int getCounter()
Gets the current thread (file) count.

Returns:
the current thread count

isRunning

public boolean isRunning()
Returns if the indexing manager still have indexing threads.

Returns:
true if the indexing manager still have indexing threads

reportStatistics

public void reportStatistics()
Writes statistical information to the report.

The method reports the total number of threads started (equals to the number of indexed files), the number of returned threads (equals to the number of successfully indexed files), and the number of abandoned threads (hanging threads reaching the timeout).


run

public void run()
Starts the thread manager to look for non-terminated threads

The thread manager looks all 10 minutes if threads are not returned and reports the number to the log file.

See Also:
Runnable.run()