fix(backlog): 品牌出口统一、join 截止与进行中任务补回
- BrandLabel 出口守卫扩到全仓 entity.setBrand,撞款/去重/品牌库统一清洗 - FutureDeadline 替换五处无界 join,回传口锁等待降为 1s - 采集/跟价/外观专利 history 补回窗口外进行中与续跑任务 - 工作台客户端版本强制单调;catch 棘轮按新增出口逐处记名
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package com.nanri.aiimage.common.support;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
/**
|
||||
* 带截止的 future 等待。
|
||||
*
|
||||
* <p>{@code join()} 没有时间界:JDK HTTP 客户端的超时只封顶到响应头,响应体读取一旦卡住,
|
||||
* 行线程/任务线程会永久 park。凡是把 worker 线程 join 回主线程的地方都走这里,超时即取消
|
||||
* 该 future 并把超时作为该行/该批的失败收口,不拖住整条任务。</p>
|
||||
*/
|
||||
public final class FutureDeadline {
|
||||
|
||||
private FutureDeadline() {
|
||||
}
|
||||
|
||||
public static <T> T await(CompletableFuture<T> future, long timeoutMillis, String label)
|
||||
throws InterruptedException, ExecutionException, TimeoutException {
|
||||
try {
|
||||
return future.get(Math.max(1L, timeoutMillis), TimeUnit.MILLISECONDS);
|
||||
} catch (TimeoutException ex) {
|
||||
future.cancel(true);
|
||||
throw new TimeoutException(label + " 超过 " + timeoutMillis + "ms 未完成,已取消");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user