Skip to content

Commit

Permalink
perf: file-gateway调度逻辑优化 TencentBlueKing#2977
Browse files Browse the repository at this point in the history
增加耗时日志打印
  • Loading branch information
jsonwan committed May 14, 2024
1 parent 568ae8f commit 81fe601
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.StopWatch;

import java.util.List;

Expand Down Expand Up @@ -97,6 +98,8 @@ public void run() {
}

private void reDispatchFileSourceTasks() {
StopWatch watch = new StopWatch("reDispatchFileSourceTasks");
watch.start("listTimeoutFileSourceTaskIds");
// 找出未结束且长时间无响应的任务,无响应且未结束的任务就应当被重调度了
long fileSourceTaskStatusExpireTimeMills = reDispatchTaskTimeoutSeconds * 1000L;
List<String> timeoutFileSourceTaskIdList = fileTaskDAO.listTimeoutFileSourceTaskIds(
Expand All @@ -110,6 +113,8 @@ private void reDispatchFileSourceTasks() {
timeoutFileSourceTaskIdList.size(),
timeoutFileSourceTaskIdList
);
watch.stop();
watch.start("reDispatch Tasks");
// 进行超时重调度
for (String fileSourceTaskId : timeoutFileSourceTaskIdList) {
boolean result = reDispatchService.reDispatchByGateway(fileSourceTaskId, 0L, 5000L);
Expand All @@ -120,5 +125,19 @@ private void reDispatchFileSourceTasks() {
result
);
}
watch.stop();
if (watch.getTotalTimeSeconds() > 10) {
log.warn(
"SLOW: reDispatched {} fileSourceTask, timeConsuming:{}",
timeoutFileSourceTaskIdList.size(),
watch.prettyPrint()
);
} else {
log.info(
"reDispatched {} fileSourceTask, timeConsuming: {}s",
timeoutFileSourceTaskIdList.size(),
watch.getTotalTimeSeconds()
);
}
}
}

0 comments on commit 81fe601

Please sign in to comment.