Package org.codelibs.fess.ds.callback
Class FileListIndexUpdateCallbackImpl
java.lang.Object
org.codelibs.fess.ds.callback.FileListIndexUpdateCallbackImpl
- All Implemented Interfaces:
IndexUpdateCallback
Implementation of IndexUpdateCallback that handles file list index updates with concurrent processing.
This callback processes file events (create, modify, delete) and manages document indexing and deletion
operations in the search engine. It supports recursive crawling with configurable depth and access count limits.
The implementation uses an executor service for concurrent processing of file operations and maintains a cache of URLs to be deleted for batch processing. It handles redirect following and child URL discovery during the crawling process.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.codelibs.fess.crawler.client.CrawlerClientFactoryFactory for creating crawler clients to handle different URL schemes.List of URLs to be deleted, cached for batch processing.protected IndexUpdateCallbackThe underlying index update callback to delegate operations to.protected intMaximum size of the delete URL cache before batch deletion is triggered.protected intMaximum number of redirects to follow when processing URLs.protected static final StringThe key used to specify the pattern for excluding URLs. -
Constructor Summary
ConstructorsConstructorDescriptionFileListIndexUpdateCallbackImpl(IndexUpdateCallback indexUpdateCallback, org.codelibs.fess.crawler.client.CrawlerClientFactory crawlerClientFactory, int nThreads) Constructs a new FileListIndexUpdateCallbackImpl with the specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddDocument(DataStoreParams paramMap, Map<String, Object> dataMap) Adds a document to the search index by crawling the specified URL and processing the content.voidcommit()Commits all pending index update operations to ensure data persistence.protected booleandeleteDocument(DataStoreParams paramMap, Map<String, Object> dataMap) Deletes a document from the search index based on the URL in the data map.protected voidPerforms batch deletion of all URLs in the delete cache.longReturns the total number of documents processed by this callback.longReturns the total execution time for index update operations.protected longgetMaxAccessCount(DataStoreParams paramMap, Map<String, Object> dataMap) Determines the maximum number of URLs to access during crawling.protected intgetMaxDepth(DataStoreParams paramMap, Map<String, Object> dataMap) Determines the maximum crawling depth from the configuration parameters.protected StringgetParamValue(DataStoreParams paramMap, String key, String defaultValue) Retrieves a parameter value from the data store parameters map.protected booleanisUrlCrawlable(DataStoreParams paramMap, String url) Determines whether the specified URL is crawlable based on the exclusion pattern provided in theparamMap.protected voidMerges response data from the crawler into the original data map.protected ExecutorServicenewFixedThreadPool(int nThreads) Creates a new fixed thread pool executor with the specified number of threads.protected StringprocessRequest(DataStoreParams paramMap, Map<String, Object> dataMap, String url, org.codelibs.fess.crawler.client.CrawlerClient client) Processes a single crawl request by executing the HTTP request, handling redirects, transforming the response data, and indexing the document.voidsetExecutorTerminationTimeout(int executorTerminationTimeout) Sets the timeout for executor service termination during shutdown.voidsetMaxDeleteDocumentCacheSize(int maxDeleteDocumentCacheSize) Sets the maximum size of the delete document cache.voidsetMaxRedirectCount(int maxRedirectCount) Sets the maximum number of redirects to follow when processing URLs.voidstore(DataStoreParams paramMap, Map<String, Object> dataMap) Stores a document in the search index with the specified parameters and data.
-
Field Details
-
URL_EXCLUDE_PATTERN
The key used to specify the pattern for excluding URLs. This constant can be used to retrieve or set the URL exclusion pattern in configuration or processing logic.- See Also:
-
indexUpdateCallback
The underlying index update callback to delegate operations to. -
crawlerClientFactory
protected org.codelibs.fess.crawler.client.CrawlerClientFactory crawlerClientFactoryFactory for creating crawler clients to handle different URL schemes. -
deleteUrlList
List of URLs to be deleted, cached for batch processing. All access is synchronized via indexUpdateCallback lock. -
maxDeleteDocumentCacheSize
protected int maxDeleteDocumentCacheSizeMaximum size of the delete URL cache before batch deletion is triggered. -
maxRedirectCount
protected int maxRedirectCountMaximum number of redirects to follow when processing URLs.
-
-
Constructor Details
-
FileListIndexUpdateCallbackImpl
public FileListIndexUpdateCallbackImpl(IndexUpdateCallback indexUpdateCallback, org.codelibs.fess.crawler.client.CrawlerClientFactory crawlerClientFactory, int nThreads) Constructs a new FileListIndexUpdateCallbackImpl with the specified parameters.- Parameters:
indexUpdateCallback- the underlying index update callback to delegate tocrawlerClientFactory- the factory for creating crawler clientsnThreads- the number of threads for the executor service (minimum 1)
-
-
Method Details
-
newFixedThreadPool
Creates a new fixed thread pool executor with the specified number of threads.- Parameters:
nThreads- the number of threads in the pool- Returns:
- a new ThreadPoolExecutor configured for this callback
-
store
Description copied from interface:IndexUpdateCallbackStores a document in the search index with the specified parameters and data.- Specified by:
storein interfaceIndexUpdateCallback- Parameters:
paramMap- the data store parameters containing configuration and metadatadataMap- the document data to be indexed as key-value pairs
-
getParamValue
Retrieves a parameter value from the data store parameters map.- Parameters:
paramMap- the parameter map to searchkey- the parameter key to look updefaultValue- the default value to return if key is not found- Returns:
- the parameter value as a string, or the default value if not found
-
addDocument
Adds a document to the search index by crawling the specified URL and processing the content. This method handles recursive crawling with depth and access count limits, follows redirects, and processes child URLs discovered during crawling.- Parameters:
paramMap- the data store parameters containing crawling configurationdataMap- the data map containing the document information including the URL
-
isUrlCrawlable
Determines whether the specified URL is crawlable based on the exclusion pattern provided in theparamMap. If theURL_EXCLUDE_PATTERNkey exists in the parameter map, its value is used as a regular expression pattern to match against the given URL. If the URL matches the exclusion pattern, the method returnsfalse, indicating that the URL should not be crawled. Otherwise, it returnstrue.- Parameters:
paramMap- the parameter map containing potential exclusion patternsurl- the URL to be checked for crawlability- Returns:
trueif the URL is crawlable;falseif it matches the exclusion pattern
-
getMaxAccessCount
Determines the maximum number of URLs to access during crawling. This method checks for explicit max_access_count parameter or recursive flag.- Parameters:
paramMap- the data store parametersdataMap- the data map containing crawling configuration- Returns:
- the maximum access count (-1 for unlimited, 1 for single access, or specified count)
-
getMaxDepth
Determines the maximum crawling depth from the configuration parameters.- Parameters:
paramMap- the data store parametersdataMap- the data map containing crawling configuration- Returns:
- the maximum crawling depth (-1 for unlimited depth)
-
processRequest
protected String processRequest(DataStoreParams paramMap, Map<String, Object> dataMap, String url, org.codelibs.fess.crawler.client.CrawlerClient client) Processes a single crawl request by executing the HTTP request, handling redirects, transforming the response data, and indexing the document.- Parameters:
paramMap- the data store parametersdataMap- the data map to be updated with response dataurl- the URL to processclient- the crawler client to use for the request- Returns:
- the redirect URL if a redirect occurred, null otherwise
- Throws:
org.codelibs.fess.crawler.exception.ChildUrlsException- if child URLs are discovered during processingDataStoreCrawlingException- if an error occurs during crawling
-
mergeResponseData
Merges response data from the crawler into the original data map. Handles special ".overwrite" suffix fields by removing the suffix and overwriting the base field.- Parameters:
dataMap- the original data map to merge intoresponseDataMap- the response data map from the crawler
-
deleteDocument
Deletes a document from the search index based on the URL in the data map. For recursive operations, performs immediate deletion. For single documents, adds to the delete cache for batch processing.- Parameters:
paramMap- the data store parametersdataMap- the data map containing the URL to delete- Returns:
- true if the deletion was processed successfully, false otherwise
-
commit
public void commit()Description copied from interface:IndexUpdateCallbackCommits all pending index update operations to ensure data persistence. This method should be called after all documents have been stored.- Specified by:
commitin interfaceIndexUpdateCallback
-
deleteDocuments
protected void deleteDocuments()Performs batch deletion of all URLs in the delete cache. Clears the delete URL list after processing. -
getDocumentSize
public long getDocumentSize()Description copied from interface:IndexUpdateCallbackReturns the total number of documents processed by this callback.- Specified by:
getDocumentSizein interfaceIndexUpdateCallback- Returns:
- the document count
-
getExecuteTime
public long getExecuteTime()Description copied from interface:IndexUpdateCallbackReturns the total execution time for index update operations.- Specified by:
getExecuteTimein interfaceIndexUpdateCallback- Returns:
- the execution time in milliseconds
-
setMaxDeleteDocumentCacheSize
public void setMaxDeleteDocumentCacheSize(int maxDeleteDocumentCacheSize) Sets the maximum size of the delete document cache.- Parameters:
maxDeleteDocumentCacheSize- the maximum cache size before batch deletion is triggered
-
setMaxRedirectCount
public void setMaxRedirectCount(int maxRedirectCount) Sets the maximum number of redirects to follow when processing URLs.- Parameters:
maxRedirectCount- the maximum redirect count
-
setExecutorTerminationTimeout
public void setExecutorTerminationTimeout(int executorTerminationTimeout) Sets the timeout for executor service termination during shutdown.- Parameters:
executorTerminationTimeout- the timeout in seconds
-