Package org.codelibs.fess.thumbnail
Class ThumbnailManager
java.lang.Object
org.codelibs.fess.thumbnail.ThumbnailManager
Manager class for handling thumbnail generation and management.
Provides functionality to generate, cache, and serve thumbnail images for documents.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classFile visitor for purging old thumbnail files. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected FileBase directory for storing thumbnail files.protected booleanFlag indicating whether thumbnail generation is currently in progress.protected final List<ThumbnailGenerator> List of available thumbnail generators.protected StringFile extension for generated thumbnail images.protected static final org.apache.logging.log4j.LoggerLogger instance for this class.protected longExpiration time in milliseconds for no-image placeholder files.protected intHash size for splitting thumbnail storage directories.protected intNumber of subdirectories for organizing thumbnails.protected intSize of the thumbnail path cache.protected static final StringDefault directory name for thumbnails.protected intNumber of tasks to process in bulk operations.protected BlockingQueue<org.codelibs.core.misc.Tuple3<String, String, String>> Queue for thumbnail generation tasks containing URL, content, and path tuples.protected intMaximum size of the thumbnail generation task queue.protected longTimeout in milliseconds for thumbnail task queue operations. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(ThumbnailGenerator generator) Adds a thumbnail generator to the manager.voiddestroy()Cleans up resources when the thumbnail manager is destroyed.intgenerate(ExecutorService executorService, boolean cleanup) Generates thumbnails using the provided executor service.protected StringgetImageFilename(String docid) Gets the image filename for a document based on its document ID.protected StringgetImageFilename(Map<String, Object> docMap) Gets the image filename for a document based on its document map.getThumbnailFile(Map<String, Object> docMap) Gets the thumbnail file for a document if it exists.Gets the system property option string for thumbnail path configuration.voidinit()Initializes the thumbnail manager after construction.voidmigrate()Migrates existing thumbnail files to the new directory structure.booleanOffers a document for thumbnail generation.protected voidprocess(org.codelibs.fess.mylasta.direction.FessConfig fessConfig, org.codelibs.fess.opensearch.config.exentity.ThumbnailQueue entity) Processes a single thumbnail generation task.longpurge(long expiry) Purges old thumbnail files based on the expiry time.voidsetImageExtention(String imageExtention) Sets the image file extension for thumbnails.voidsetNoImageExpired(long noImageExpired) Sets the expiration time for no-image placeholder files.voidsetSplitHashSize(int splitHashSize) Sets the hash size for splitting thumbnail storage directories.voidsetSplitSize(int splitSize) Sets the split size for directory organization.voidsetThumbnailPathCacheSize(int thumbnailPathCacheSize) Sets the thumbnail path cache size.voidsetThumbnailTaskQueueSize(int thumbnailTaskQueueSize) Sets the maximum size of the thumbnail task queue.protected voidstoreQueue(List<org.codelibs.core.misc.Tuple3<String, String, String>> taskList) Stores thumbnail generation tasks to the queue for processing.
-
Field Details
-
THUMBNAILS_DIR_NAME
Default directory name for thumbnails.- See Also:
-
logger
protected static final org.apache.logging.log4j.Logger loggerLogger instance for this class. -
baseDir
Base directory for storing thumbnail files. -
generatorList
List of available thumbnail generators. -
thumbnailTaskQueue
Queue for thumbnail generation tasks containing URL, content, and path tuples. -
generating
protected volatile boolean generatingFlag indicating whether thumbnail generation is currently in progress. -
thumbnailPathCacheSize
protected int thumbnailPathCacheSizeSize of the thumbnail path cache. -
imageExtention
File extension for generated thumbnail images. -
splitSize
protected int splitSizeNumber of subdirectories for organizing thumbnails. -
thumbnailTaskQueueSize
protected int thumbnailTaskQueueSizeMaximum size of the thumbnail generation task queue. -
thumbnailTaskBulkSize
protected int thumbnailTaskBulkSizeNumber of tasks to process in bulk operations. -
thumbnailTaskQueueTimeout
protected long thumbnailTaskQueueTimeoutTimeout in milliseconds for thumbnail task queue operations. -
noImageExpired
protected long noImageExpiredExpiration time in milliseconds for no-image placeholder files. -
splitHashSize
protected int splitHashSizeHash size for splitting thumbnail storage directories.
-
-
Constructor Details
-
ThumbnailManager
public ThumbnailManager()Default constructor for ThumbnailManager.
-
-
Method Details
-
init
@PostConstruct public void init()Initializes the thumbnail manager after construction. Sets up base directory and starts background processing. -
destroy
@PreDestroy public void destroy()Cleans up resources when the thumbnail manager is destroyed. Stops background processing and waits for threads to complete. -
getThumbnailPathOption
Gets the system property option string for thumbnail path configuration.- Returns:
- the property option string for JVM arguments
-
storeQueue
Stores thumbnail generation tasks to the queue for processing.- Parameters:
taskList- list of thumbnail tasks to store
-
generate
Generates thumbnails using the provided executor service.- Parameters:
executorService- the executor service for parallel processingcleanup- whether to run in cleanup mode- Returns:
- the number of tasks processed
-
process
protected void process(org.codelibs.fess.mylasta.direction.FessConfig fessConfig, org.codelibs.fess.opensearch.config.exentity.ThumbnailQueue entity) Processes a single thumbnail generation task.- Parameters:
fessConfig- the Fess configurationentity- the thumbnail queue entity to process
-
offer
Offers a document for thumbnail generation.- Parameters:
docMap- the document data map- Returns:
- true if the task was successfully added to the queue
-
getImageFilename
Gets the image filename for a document based on its document map.- Parameters:
docMap- the document data map- Returns:
- the generated image filename
-
getImageFilename
Gets the image filename for a document based on its document ID.- Parameters:
docid- the document ID- Returns:
- the generated image filename
-
getThumbnailFile
Gets the thumbnail file for a document if it exists.- Parameters:
docMap- the document data map- Returns:
- the thumbnail file or null if not found
-
add
Adds a thumbnail generator to the manager.- Parameters:
generator- the thumbnail generator to add
-
purge
public long purge(long expiry) Purges old thumbnail files based on the expiry time.- Parameters:
expiry- the expiry time threshold- Returns:
- the number of files purged
-
migrate
public void migrate()Migrates existing thumbnail files to the new directory structure. -
setThumbnailPathCacheSize
public void setThumbnailPathCacheSize(int thumbnailPathCacheSize) Sets the thumbnail path cache size.- Parameters:
thumbnailPathCacheSize- the cache size to set
-
setImageExtention
Sets the image file extension for thumbnails.- Parameters:
imageExtention- the file extension to set
-
setSplitSize
public void setSplitSize(int splitSize) Sets the split size for directory organization.- Parameters:
splitSize- the split size to set
-
setThumbnailTaskQueueSize
public void setThumbnailTaskQueueSize(int thumbnailTaskQueueSize) Sets the maximum size of the thumbnail task queue.- Parameters:
thumbnailTaskQueueSize- the queue size to set
-
setNoImageExpired
public void setNoImageExpired(long noImageExpired) Sets the expiration time for no-image placeholder files.- Parameters:
noImageExpired- the expiration time in milliseconds
-
setSplitHashSize
public void setSplitHashSize(int splitHashSize) Sets the hash size for splitting thumbnail storage directories.- Parameters:
splitHashSize- the hash size to set
-