feat(采集数据): 品牌检测失败自动补测队列,限流窗口后自动重查并补结果(V140)

WIPO 限流窗口内 queryFailed 的品牌按任务排队(biz_collectdata_brand_recheck,同任务同品牌幂等),Scheduler 按指数退避自动补测:补出无侵权→行补进结果文件,判出侵权→落无效品牌表,连续耗尽→EXHAUSTED 并通知。只存品牌不存行,注入按 payload_hash 幂等。
This commit is contained in:
2026-10-03 00:22:07 +08:00
parent 68b19f22b3
commit 005cda9379
21 changed files with 1642 additions and 11 deletions
@@ -0,0 +1,50 @@
package com.nanri.aiimage.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* 采集数据品牌检测失败补测(requeue)配置:
* 上游 WIPO 限流窗口过去后,把任务里品牌检测「查询失败」的品牌自动重查并补进结果。
*
* <p>节奏设计对标 2026-10-02 的真实限流事件(持续 11 小时):首轮延后 {@link #firstDelayMinutes}
* 分钟避开任务收尾,失败后按 {@link #intervalBaseMinutes} 起指数退避(30m→1h→2h→4h→8h→16h→32h
* 封顶),共 {@link #maxAttempts} 轮实测,合计覆盖约 31 小时的上游抖动窗口。
*/
@Data
@ConfigurationProperties(prefix = "aiimage.collect-data.brand-recheck")
public class CollectDataBrandRecheckProperties {
/** 补测总开关:关闭后不再入队、调度器跳过所有轮次(应急降噪)。 */
private boolean enabled = true;
/** 调度轮询间隔(毫秒),默认 5 分钟;与通知扫描同节拍,双实例由分布式锁互斥。 */
private long scanIntervalMs = 5 * 60 * 1000L;
/** 调度首次执行延迟(毫秒),默认 2 分钟,避开启动阶段。 */
private long scanInitialDelayMs = 2 * 60 * 1000L;
/** 入队后到首次补测的延后分钟数:避开任务收尾与短时限流窗口(客户端同步重试已覆盖)。 */
private int firstDelayMinutes = 30;
/** 退避基准分钟数:第 n 次失败后等待 intervalBaseMinutes × 2^(n-1),封顶 16 小时。 */
private int intervalBaseMinutes = 30;
/**
* 单个品牌最大实测轮次(含首次)。默认 7:失败后等待 30m/1h/2h/4h/8h/16h,
* 首测 + 6 次重测合计覆盖约 31 小时;用尽后条目 EXHAUSTED,不再自动重试。
*/
private int maxAttempts = 7;
/** 单轮最多取出的到期条目数(跨任务合计),防止限流恢复瞬间的补流洪峰。 */
private int roundBatchSize = 200;
/**
* 轮内熔断阈值:本轮已实测品牌中「仍查询失败」占比超过该值(且实测数 ≥
* {@link #failRateMinProbe})时,中止本轮剩余条目——上游仍在限流时不必逐批捶它。
*/
private double failRateThreshold = 0.5;
/** 熔断判定的最小实测品牌数:样本太小不判熔断,避免单品牌偶发失败触发整轮中止。 */
private int failRateMinProbe = 3;
}
@@ -4,6 +4,6 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.annotation.Configuration;
@Configuration
@EnableConfigurationProperties({OssProperties.class, TransientStorageProperties.class, StorageProperties.class, BrandProgressProperties.class, DeleteBrandProgressProperties.class, BrandCheckProperties.class, ZiniaoProperties.class, ModuleCleanupProperties.class, TaskPressureProperties.class, TaskImageCacheCleanupProperties.class, AppearancePatentProperties.class, SimilarAsinProperties.class, ImageVideoProperties.class, InstanceRoutingProperties.class, CapacityPlanProperties.class, UserSecretProperties.class, NotificationProperties.class, DeviceLogOssProperties.class})
@EnableConfigurationProperties({OssProperties.class, TransientStorageProperties.class, StorageProperties.class, BrandProgressProperties.class, DeleteBrandProgressProperties.class, BrandCheckProperties.class, ZiniaoProperties.class, ModuleCleanupProperties.class, TaskPressureProperties.class, TaskImageCacheCleanupProperties.class, AppearancePatentProperties.class, SimilarAsinProperties.class, ImageVideoProperties.class, InstanceRoutingProperties.class, CapacityPlanProperties.class, UserSecretProperties.class, NotificationProperties.class, DeviceLogOssProperties.class, CollectDataBrandRecheckProperties.class})
public class PropertiesConfig {
}