|
DLESE Tools v1.6.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.dlese.dpc.index.FileIndexingService
public final class FileIndexingService
Indexes files into a SimpleLuceneIndex
and automatically updates the index
whenever changes to the files are made. This class uses a FileIndexingServiceWriter
to create the Lucene Document
s that are placed in the SimpleLuceneIndex
. This class looks for changes made to items in a directory of files
and updates the index automatically by adding, updating or deleting items as appropriate. The frequency
for update checkes is configurable. There should be only one instance of this class for each SimpleLuceneIndex
that is being populated with this class.
Field Summary | |
---|---|
static int |
INDEXING_ABORTED
Indicates that indexing was aborted by request |
static int |
INDEXING_DIR_DOES_NOT_EXIST
Indicates that indexing directory does not exist |
static int |
INDEXING_DIR_READ_ERROR
Indicates a read error on the directory |
static int |
INDEXING_ERROR
Indicates that indexing completed with a severe error |
static int |
INDEXING_ITEM_ERROR
Indicates that indexing completed successfully, but one or more item was indexed with errors |
static int |
INDEXING_SUCCESS
Indicates that indexing completed normally |
Constructor Summary | |
---|---|
FileIndexingService(SimpleLuceneIndex index,
long updateFrequency,
boolean saveDeletes,
String idFieldToRemove,
String fileIndexingServiceDataDir,
int maxNumFilesToIndex)
Indexes files to the given SimpleLuceneIndex , checking for changes in the
files and reindexing them at the given update frequency. |
|
FileIndexingService(SimpleLuceneIndex index,
long updateFrequency,
String fileIndexingServiceDataDir,
int maxNumFilesToIndex)
Indexes files to the given SimpleLuceneIndex , checking for changes in the
files and reindexing them at the given update frequency. |
Method Summary | |
---|---|
boolean |
addDirectory(File srcDir,
Class documentWriterClass,
HashMap documentWriterConfigAttributes,
FileIndexingPlugin plugin,
int indexingPriority)
Adds a directory of files to be monitored for changes, or replaces the current one if one exists with the same absolute path. |
boolean |
addDirectory(String sourceFileDirectory,
Class documentWriterClass,
HashMap documentWriterConfigAttributes,
FileIndexingPlugin plugin,
int indexingPriority)
Adds a directory of files to be monitored for changes, or replaces the current one if one exists with the same absolute path. |
void |
changeUpdateFrequency(long updateFrequency)
Changes the frequency of reindexing to the new value. |
boolean |
deleteDirectory(File srcDir)
Deletes the files in the given directory from the index and removes it from the configuration. |
boolean |
deleteDirectory(String sourceFileDirectory)
Deletes the files in the given directory from the index and removes it from the configuration. |
Object |
getAttribute(String key)
Gets an attribute Object from this FileIndexingService. |
HashMap |
getConfiguredDirectories()
Gets a HashMap of all directories that are configured in this FileIndexingService, keyed by absolute path. |
static String |
getDateStamp()
Return a string for the current time and date, sutiable for display in log files and output to standout: |
ArrayList |
getIndexingMessages()
Gets the last 10 indexing status messages. |
long |
getLastSyncTime()
Gets the lastSyncTime attribute of the FileIndexingService object |
int |
getNumRecordsToAdd()
Gets the numRecordsToAdd attribute of the FileIndexingService object |
int |
getNumRecordsToDelete()
Gets the numRecordsToDelete attribute of the FileIndexingService object |
int |
getNumRecordsToReplace()
Gets the numRecordsToReplace attribute of the FileIndexingService object |
static String |
getSimpleDateStamp()
Return a string for the current time and date, sutiable for display in log files and output to standout: |
long |
getUpdateFrequency()
Gets the updateFrequency attribute of the FileIndexingService object |
void |
indexFile(File fileToIndex,
FileIndexingPlugin plugin)
Indexes a single file. |
void |
indexFiles(boolean reindexAll,
File directory,
FileIndexingObserver observer)
Updates the index to reflect the files in the directory indicated, which must have been previously added to this FileIndexingService using addDirectory(java.lang.String, java.lang.Class, java.util.HashMap, org.dlese.dpc.index.writer.FileIndexingPlugin, int) . |
void |
indexFiles(boolean reindexAll,
FileIndexingObserver observer)
Updates the index to reflect the files in the directories this service is monitoring, with the option to run the update in the background. |
boolean |
isDirectoryConfigured(File srcDir)
Determines whether the given directory is configured for indexing. |
boolean |
isIndexing()
Determins whether indexing is in progress. |
void |
reindexDocs(org.apache.lucene.document.Document[] docs,
boolean reindexAll)
Reindexes the given Documents. |
void |
reindexDocs(ResultDocList docs,
boolean reindexAll)
Reindexes the Documents in the given ResultDocs. |
int |
reindexDocs(String query,
boolean reindexAll)
Reindexes Documents managed by this FileIndexingService that match the given Lucene query. |
int |
reindexDocs(String field,
String[] terms,
boolean reindexAll)
Re-indexes all documents that match the given terms within the given field. |
int |
reindexDocs(String field,
String term,
boolean reindexAll)
Re-indexes all documents that match the given term within the given field. |
void |
removeDocs(String field,
String[] terms,
FileIndexingServiceWriter docWriter)
Removes all documents that match the given terms within the given field. |
void |
removeDocs(String field,
String[] terms,
FileIndexingServiceWriter docWriter,
boolean saveDeletes)
Removes all documents that match the given terms within the given field. |
void |
removeDocs(String field,
String term,
FileIndexingServiceWriter docWriter)
Removes all documents that match the given term within the given field. |
void |
removeDocs(String field,
String term,
FileIndexingServiceWriter docWriter,
boolean saveDeletedRecords)
Removes all documents that match the given term within the given field. |
void |
setAttribute(String key,
Object attribute)
Sets an attribute Object that will be available for access here and from the FileIndexingServiceWriters. |
static void |
setDebug(boolean db)
Sets the debug attribute object |
void |
setValidationEnabled(boolean validateFiles)
Sets whether or not to validate the files being indexed and create a validation report, which is indexed. |
void |
startTester(String docRoot,
String sourceFileDirectory)
Starts a FileMoveTester iff one is not already initialized. |
void |
startTimerThread(long updateFrequency)
Start or restarts the timer thread with the given update frequency. |
void |
stopIndexing()
Stops the indexing process if it is currently taking place. |
void |
stopTester()
Stops the FileMoveTester |
void |
stopTimerThread()
Stops the indexing timer thread. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int INDEXING_SUCCESS
public static final int INDEXING_ABORTED
public static final int INDEXING_ERROR
public static final int INDEXING_ITEM_ERROR
public static final int INDEXING_DIR_DOES_NOT_EXIST
public static final int INDEXING_DIR_READ_ERROR
Constructor Detail |
---|
public FileIndexingService(SimpleLuceneIndex index, long updateFrequency, String fileIndexingServiceDataDir, int maxNumFilesToIndex)
SimpleLuceneIndex
, checking for changes in the
files and reindexing them at the given update frequency. Validation of files is enabled by default.
index
- The SimpleLuceneIndex
that will be
populated and updated with Documents created from filesupdateFrequency
- The frequency by which files are checked for updates, in seconds. Zero
or less indicates no updates should be performed.fileIndexingServiceDataDir
- The directory where serialized data will be storedmaxNumFilesToIndex
- Max number of files to index per iterationsetValidationEnabled(boolean validateFiles)
public FileIndexingService(SimpleLuceneIndex index, long updateFrequency, boolean saveDeletes, String idFieldToRemove, String fileIndexingServiceDataDir, int maxNumFilesToIndex)
SimpleLuceneIndex
, checking for changes in the
files and reindexing them at the given update frequency. Validation of files is enabled by default.
index
- The SimpleLuceneIndex
that will be
populated and updated with Documents created from filesupdateFrequency
- The frequency by which files are checked for updates, in seconds. Zero
or less indicates no updates should be performed.saveDeletes
- True to save removed documents in the index and mark them deleted,
else they will be removed from the index.idFieldToRemove
- An ID field whoes docs should be removed if found in duplicate.fileIndexingServiceDataDir
- Dir where persistent data files will be storedmaxNumFilesToIndex
- The number of files to index per iterationsetValidationEnabled(boolean validateFiles)
Method Detail |
---|
public void setAttribute(String key, Object attribute)
key
- The key used to reference the attribute.attribute
- Any Java Object.FileIndexingServiceWriter
public void stopIndexing()
public Object getAttribute(String key)
key
- The key used to reference the attribute.
FileIndexingServiceWriter
public void changeUpdateFrequency(long updateFrequency)
startTimerThread(long
updateFrequency)
.
updateFrequency
- The frequency by which files are checked for changes and reindexed.public void startTimerThread(long updateFrequency)
changeUpdateFrequency(long updateFrequency)
.
updateFrequency
- The number of seconds between index updates.public void stopTimerThread()
public void setValidationEnabled(boolean validateFiles)
validateFiles
- True to validate, else false.FileIndexingServiceWriter.getValidationReport()
public boolean addDirectory(String sourceFileDirectory, Class documentWriterClass, HashMap documentWriterConfigAttributes, FileIndexingPlugin plugin, int indexingPriority)
sourceFileDirectory
- The file direcory that will be monitored for updates.indexingPriority
- The feature to be added to the Directory attributedocumentWriterClass
- The feature to be added to the Directory attributedocumentWriterConfigAttributes
- The feature to be added to the Directory attributeplugin
- The feature to be added to the Directory attribute
public boolean addDirectory(File srcDir, Class documentWriterClass, HashMap documentWriterConfigAttributes, FileIndexingPlugin plugin, int indexingPriority)
srcDir
- The file direcory that will be monitored for updates.indexingPriority
- The feature to be added to the Directory attributedocumentWriterClass
- The feature to be added to the Directory attributedocumentWriterConfigAttributes
- The feature to be added to the Directory attributeplugin
- The feature to be added to the Directory attribute
public boolean isIndexing()
public boolean isDirectoryConfigured(File srcDir)
srcDir
- A directory of indexable files.
public HashMap getConfiguredDirectories()
public boolean deleteDirectory(String sourceFileDirectory)
addDirectory(java.lang.String, java.lang.Class, java.util.HashMap, org.dlese.dpc.index.writer.FileIndexingPlugin, int)
method.
sourceFileDirectory
- The directory of files needing to be removed from the index.
public boolean deleteDirectory(File srcDir)
addDirectory(java.lang.String, java.lang.Class, java.util.HashMap, org.dlese.dpc.index.writer.FileIndexingPlugin, int)
method.
srcDir
- The directory of files needing to be removed from the index.
public long getUpdateFrequency()
public long getLastSyncTime()
public int getNumRecordsToDelete()
public int getNumRecordsToAdd()
public int getNumRecordsToReplace()
public void indexFiles(boolean reindexAll, FileIndexingObserver observer)
reindexAll
- True to reindex all files regardless of file mod date, False to reindex only those
files that have changed since the last indexing.observer
- The FileIndexingObserver that will be notified when indexing is complete, or null to
use nonepublic void indexFiles(boolean reindexAll, File directory, FileIndexingObserver observer)
addDirectory(java.lang.String, java.lang.Class, java.util.HashMap, org.dlese.dpc.index.writer.FileIndexingPlugin, int)
. Any new, deleted or modified files that appear
in the directory will be reflected in the index.
reindexAll
- True to reindex all files regardless of file mod date, False to reindex only those
files that have changed since the last indexing.directory
- The directory to index.observer
- The FileIndexingObserver that will be notified when indexing is complete, or null to
use nonepublic void indexFile(File fileToIndex, FileIndexingPlugin plugin) throws FileIndexingServiceException
fileToIndex
- The file to index.plugin
- A FileIndexingPlugin or null.
FileIndexingServiceException
- If unable to indexpublic final void removeDocs(String field, String term, FileIndexingServiceWriter docWriter)
SimpleLuceneIndex.removeDocs(String,String)
but is synchronized with other operations occuring in this
FileIndexinService and handles deletes accordingly.
field
- The field that is searched.term
- The term that is matched for removal.docWriter
- The FileIndexingServiceWriter to usepublic final void removeDocs(String field, String[] terms, FileIndexingServiceWriter docWriter)
SimpleLuceneIndex.removeDocs(String,String[])
but is synchronized with other operations occuring in this
FileIndexinService and handles deletes accordingly.
field
- The field that is searched.terms
- The terms that are matched for removal.docWriter
- The FileIndexingServiceWriter to usepublic final void removeDocs(String field, String term, FileIndexingServiceWriter docWriter, boolean saveDeletedRecords)
SimpleLuceneIndex.removeDocs(String,String)
but is synchronized with other operations occuring in this
FileIndexinService and handles deletes accordingly.
field
- The field that is searched.term
- The term that is matched for removal.saveDeletedRecords
- True to save the removed documents in the index and mark them deleted, else
they will be removed from the index.docWriter
- The FileIndexingServiceWriter to usepublic final void removeDocs(String field, String[] terms, FileIndexingServiceWriter docWriter, boolean saveDeletes)
SimpleLuceneIndex.removeDocs(String,String[])
but is synchronized with other operations occuring in this
FileIndexinService and handles deletes accordingly.
field
- The field that is searched.terms
- The terms that are matched for removal.saveDeletes
- True to save the removed documents in the index and mark them deleted, else they will
be removed from the index.docWriter
- Writer used to perform the delete.public int reindexDocs(String field, String term, boolean reindexAll)
field
- The field that is searched.term
- The term that is matched for updates.reindexAll
- True to reindex all matching results, false to reindex only those matches whoes files
have been modified since the last update.
public int reindexDocs(String field, String[] terms, boolean reindexAll)
field
- The field that is searched.terms
- The terms that are matched for updates.reindexAll
- True to reindex all matching results, false to reindex only those matches whoes files
have been modified since the last update.
public int reindexDocs(String query, boolean reindexAll)
query
- A Lucene search query.reindexAll
- True to reindex all matching results, false to reindex only those matches whoes files
have been modified since the last update.
public void reindexDocs(org.apache.lucene.document.Document[] docs, boolean reindexAll)
docs
- Lucene Documents from the same index that is managed by this FileIndexingService.reindexAll
- True to reindex all matching results, false to reindex only those matches whoes files
have been modified since the last update.public void reindexDocs(ResultDocList docs, boolean reindexAll)
docs
- Lucene ResultDocs from the same index that is managed by this FileIndexingService.reindexAll
- True to reindex all matching results, false to reindex only those matches whoes files
have been modified since the last update.public ArrayList getIndexingMessages()
public void startTester(String docRoot, String sourceFileDirectory)
docRoot
- The context document root as obtainied by calling
getServletContext().getRealPath("/");sourceFileDirectory
- DESCRIPTIONpublic void stopTester()
public static String getSimpleDateStamp()
public static String getDateStamp()
public static void setDebug(boolean db)
db
- The new debug value
|
DLESE Tools v1.6.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |