fix #1098 store thumbnail queue at shutdown
This commit is contained in:
parent
e6e32074ff
commit
43cd969c5c
3 changed files with 37 additions and 6 deletions
|
@ -82,7 +82,7 @@ public class ThumbnailManager {
|
|||
|
||||
protected int thumbnailTaskBulkSize = 100;
|
||||
|
||||
protected long thumbnailTaskQueueTimeout = 60 * 1000L;
|
||||
protected long thumbnailTaskQueueTimeout = 30 * 1000L;
|
||||
|
||||
protected long noImageExpired = 24 * 60 * 60 * 1000L; // 24 hours
|
||||
|
||||
|
@ -131,12 +131,18 @@ public class ThumbnailManager {
|
|||
}
|
||||
} catch (final InterruptedException e) {
|
||||
logger.debug("Interupted task.", e);
|
||||
if (!taskList.isEmpty()) {
|
||||
storeQueue(taskList);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
if (generating) {
|
||||
logger.warn("Failed to generage a thumbnail.", e);
|
||||
logger.warn("Failed to generate thumbnail.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!taskList.isEmpty()) {
|
||||
storeQueue(taskList);
|
||||
}
|
||||
}, "ThumbnailGenerator");
|
||||
thumbnailQueueThread.start();
|
||||
}
|
||||
|
@ -182,6 +188,9 @@ public class ThumbnailManager {
|
|||
}
|
||||
});
|
||||
taskList.clear();
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Storing " + list.size() + " thumbnail tasks.");
|
||||
}
|
||||
final ThumbnailQueueBhv thumbnailQueueBhv = ComponentUtil.getComponent(ThumbnailQueueBhv.class);
|
||||
thumbnailQueueBhv.batchInsert(list);
|
||||
}
|
||||
|
@ -199,6 +208,9 @@ public class ThumbnailManager {
|
|||
cb.query().addOrderBy_CreatedTime_Asc();
|
||||
cb.fetchFirst(fessConfig.getPageThumbnailQueueMaxFetchSizeAsInteger());
|
||||
}).forEach(entity -> {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Generating thumbnail: " + entity);
|
||||
}
|
||||
idList.add(entity.getId());
|
||||
final String generatorName = entity.getGenerator();
|
||||
try {
|
||||
|
@ -239,11 +251,19 @@ public class ThumbnailManager {
|
|||
final String path = getImageFilename(docMap);
|
||||
final Tuple4<String, String, String, String> task = generator.createTask(path, docMap);
|
||||
if (task != null) {
|
||||
thumbnailTaskQueue.offer(task);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Add thumbnail task: " + task);
|
||||
}
|
||||
if (!thumbnailTaskQueue.offer(task)) {
|
||||
logger.warn("Failed to add thumbnail task: " + task);
|
||||
}
|
||||
}
|
||||
break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Thumbnail generator is not found: " + (docMap != null ? docMap.get("url") : docMap));
|
||||
}
|
||||
}
|
||||
|
||||
protected String getImageFilename(final Map<String, Object> docMap) {
|
||||
|
|
|
@ -96,7 +96,11 @@ public abstract class BaseThumbnailGenerator implements ThumbnailGenerator {
|
|||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
final String thumbnailId = DocumentUtil.getValue(docMap, fessConfig.getIndexFieldId(), String.class);
|
||||
final String url = DocumentUtil.getValue(docMap, fessConfig.getIndexFieldUrl(), String.class);
|
||||
return new Tuple4<>(getName(), thumbnailId, url, path);
|
||||
final Tuple4<String, String, String, String> task = new Tuple4<>(getName(), thumbnailId, url, path);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Create thumbnail task: " + task);
|
||||
}
|
||||
return task;
|
||||
}
|
||||
|
||||
public void setDirectoryNameLength(final int directoryNameLength) {
|
||||
|
|
|
@ -51,9 +51,16 @@ public class HtmlTagBasedGenerator extends BaseThumbnailGenerator {
|
|||
final String thumbnailId = DocumentUtil.getValue(docMap, fessConfig.getIndexFieldId(), String.class);
|
||||
final String url = DocumentUtil.getValue(docMap, fessConfig.getIndexFieldThumbnail(), String.class);
|
||||
if (StringUtil.isBlank(url)) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Thumbnail task is not found: " + path + ", " + thumbnailId + ", " + url);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return new Tuple4<>(getName(), thumbnailId, url, path);
|
||||
final Tuple4<String, String, String, String> task = new Tuple4<>(getName(), thumbnailId, url, path);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Create thumbnail task: " + task);
|
||||
}
|
||||
return task;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue