Skip to content

Commit

Permalink
Merge pull request #195 from jamebal/develop
Browse files Browse the repository at this point in the history
perf: 优化重建索引
  • Loading branch information
jamebal authored Dec 4, 2024
2 parents c1cb541 + 5738441 commit 1186c47
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,8 @@ public void init() {

private void getSyncFileVisitorService() {
int processors = Runtime.getRuntime().availableProcessors() - 4;
if (processors < 1) {
processors = 1;
}
if (syncFileVisitorService == null || syncFileVisitorService.isShutdown()) {
syncFileVisitorService = ThreadUtil.newFixedExecutor(processors, 1, "syncFileVisitor", true);
syncFileVisitorService = ThreadUtil.newFixedExecutor(Math.max(processors, 2), 1, "syncFileVisitor", true);
}
}

Expand Down Expand Up @@ -231,6 +228,8 @@ private void waitTaskCompleted() {
// 等待线程池里所有任务完成
if (!syncFileVisitorService.awaitTermination(10, TimeUnit.MINUTES)) {
log.warn("同步文件超时, 尝试强制停止所有任务");
// 移除删除标记, 以免误删索引
removeDeletedFlag(null);
syncFileVisitorService.shutdownNow();
}
} catch (InterruptedException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public class VideoProcessService {
@PostConstruct
public void init() {
getVideoTranscodingService();
addTranscodingTaskService = ThreadUtil.newFixedExecutor(8, 100, "addTranscodingTask", true);
addTranscodingTaskService = ThreadUtil.newFixedExecutor(8, 40960, "addTranscodingTask", true);
}

private void getVideoTranscodingService() {
Expand Down

0 comments on commit 1186c47

Please sign in to comment.