feat(unreachable-cooldown): 连接层不可达客户端级冷却,四家判定下沉共用
BACKLOG B24(窗长 300s 已拍板):连续 2 次连接未建立即对该 host 进 冷却窗,窗内调用零探针快速失败(归因文案与调用内短路逐字一致);到期 后下一条真实调用兼作探针,失败重进、成功恢复。isConnectFailure 四处 副本(BrandCheckClient/AppearancePatentLlmClient/SimilarAsinLlmClient/ TaskOwnerForwardService)下沉 common/retry 共用。三家客户端接入同一 冷却表(两个 LLM 客户端共用 ai.t8star.org 一格,16890 独立一格), 窗长可配(0=关闭退回调用内短路)。另修 CollectDataBrandBatchFilter 首批预算竞态(1ms 预算下 GC 停顿误切首批,照 BrandCheckClient 首轮 不掐契约补 start>0 守卫)。变异验证:冷却禁用 6 例判红;定向 47/47 绿。
This commit is contained in:
+3
-2
@@ -1,6 +1,7 @@
|
||||
package com.nanri.aiimage.modules.appearancepatent.client;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.nanri.aiimage.common.retry.UnreachableCooldown;
|
||||
import com.nanri.aiimage.config.AppearancePatentProperties;
|
||||
import com.nanri.aiimage.modules.appearancepatent.model.dto.AppearancePatentResultRowDto;
|
||||
import com.nanri.aiimage.modules.brand.client.BrandCheckClient;
|
||||
@@ -46,7 +47,7 @@ class AppearancePatentBrandBatchTest {
|
||||
null,
|
||||
brandCheckClient,
|
||||
mock(UserSecretUsageService.class)
|
||||
);
|
||||
, new UnreachableCooldown());
|
||||
|
||||
@Test
|
||||
void mergedBatchAsksBrandCheckOnceAndAttributesPerRow() throws Exception {
|
||||
@@ -115,7 +116,7 @@ class AppearancePatentBrandBatchTest {
|
||||
properties.setLlmRetryTimes(1);
|
||||
properties.setLlmReadTimeoutMillis(5_000);
|
||||
AppearancePatentLlmClient inspectClient = new AppearancePatentLlmClient(
|
||||
properties, new ObjectMapper(), null, brandCheckClient, mock(UserSecretUsageService.class));
|
||||
properties, new ObjectMapper(), null, brandCheckClient, mock(UserSecretUsageService.class), new UnreachableCooldown());
|
||||
|
||||
List<AppearancePatentResultRowDto> rows = inspectClient.inspectRows(
|
||||
List.of(
|
||||
|
||||
+4
-3
@@ -1,6 +1,7 @@
|
||||
package com.nanri.aiimage.modules.appearancepatent.client;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.nanri.aiimage.common.retry.UnreachableCooldown;
|
||||
import com.nanri.aiimage.config.AppearancePatentProperties;
|
||||
import com.nanri.aiimage.config.BrandCheckProperties;
|
||||
import com.nanri.aiimage.modules.appearancepatent.model.dto.AppearancePatentResultRowDto;
|
||||
@@ -72,7 +73,7 @@ class AppearancePatentLlmClientHttpTest {
|
||||
null,
|
||||
localBrandCheckClient(),
|
||||
mock(UserSecretUsageService.class)
|
||||
);
|
||||
, new UnreachableCooldown());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,7 +86,7 @@ class AppearancePatentLlmClientHttpTest {
|
||||
brand.setRetryTimes(1);
|
||||
brand.setRetryIntervalMillis(0);
|
||||
brand.setTotalTimeoutMillis(5000);
|
||||
return new BrandCheckClient(brand, null, null);
|
||||
return new BrandCheckClient(brand, null, null, new UnreachableCooldown());
|
||||
}
|
||||
|
||||
private void handleBrandCheck(HttpExchange exchange) throws IOException {
|
||||
@@ -290,7 +291,7 @@ class AppearancePatentLlmClientHttpTest {
|
||||
properties.setLlmHost("http://127.0.0.1:" + server.getAddress().getPort());
|
||||
customizer.accept(properties);
|
||||
return new AppearancePatentLlmClient(properties, objectMapper, null,
|
||||
localBrandCheckClient(), mock(UserSecretUsageService.class));
|
||||
localBrandCheckClient(), mock(UserSecretUsageService.class), new UnreachableCooldown());
|
||||
}
|
||||
|
||||
/** 连接层故障短路:网关根本连不上时,重试阶梯必须在证据数处停下,行级拿到可读的真因。 */
|
||||
|
||||
+3
-2
@@ -1,6 +1,7 @@
|
||||
package com.nanri.aiimage.modules.appearancepatent.client;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.nanri.aiimage.common.retry.UnreachableCooldown;
|
||||
import com.nanri.aiimage.config.AppearancePatentProperties;
|
||||
import com.nanri.aiimage.config.BrandCheckProperties;
|
||||
import com.nanri.aiimage.modules.appearancepatent.model.dto.AppearancePatentResultRowDto;
|
||||
@@ -68,7 +69,7 @@ class AppearancePatentLlmClientImageDedupeTest {
|
||||
properties.setLlmHost("http://127.0.0.1:" + server.getAddress().getPort());
|
||||
properties.setLlmRetryTimes(1);
|
||||
client = new AppearancePatentLlmClient(properties, objectMapper, null, localBrandCheckClient(),
|
||||
mock(UserSecretUsageService.class));
|
||||
mock(UserSecretUsageService.class), new UnreachableCooldown());
|
||||
}
|
||||
|
||||
private BrandCheckClient localBrandCheckClient() {
|
||||
@@ -77,7 +78,7 @@ class AppearancePatentLlmClientImageDedupeTest {
|
||||
brand.setRetryTimes(1);
|
||||
brand.setRetryIntervalMillis(0);
|
||||
brand.setTotalTimeoutMillis(5000);
|
||||
return new BrandCheckClient(brand, null, null);
|
||||
return new BrandCheckClient(brand, null, null, new UnreachableCooldown());
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
|
||||
+8
-7
@@ -1,6 +1,7 @@
|
||||
package com.nanri.aiimage.modules.appearancepatent.client;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.nanri.aiimage.common.retry.UnreachableCooldown;
|
||||
import com.nanri.aiimage.config.AppearancePatentProperties;
|
||||
import com.nanri.aiimage.config.BrandCheckProperties;
|
||||
import com.nanri.aiimage.modules.brand.client.BrandCheckClient;
|
||||
@@ -26,9 +27,9 @@ class AppearancePatentLlmClientTest {
|
||||
new AppearancePatentProperties(),
|
||||
new ObjectMapper(),
|
||||
null,
|
||||
new BrandCheckClient(new BrandCheckProperties(), null, null),
|
||||
new BrandCheckClient(new BrandCheckProperties(), null, null, new UnreachableCooldown()),
|
||||
mock(UserSecretUsageService.class)
|
||||
);
|
||||
, new UnreachableCooldown());
|
||||
|
||||
@Test
|
||||
void markRowsFailedLeavesUserFacingResultFilledWithReviewMessage() {
|
||||
@@ -123,7 +124,7 @@ class AppearancePatentLlmClientTest {
|
||||
null,
|
||||
brandCheckClient,
|
||||
mock(UserSecretUsageService.class)
|
||||
);
|
||||
, new UnreachableCooldown());
|
||||
AppearancePatentResultRowDto row = new AppearancePatentResultRowDto();
|
||||
row.setId("1");
|
||||
String dataText = """
|
||||
@@ -140,7 +141,7 @@ class AppearancePatentLlmClientTest {
|
||||
|
||||
private static AppearancePatentLlmClient clientWith(BrandCheckClient brandCheckClient) {
|
||||
return new AppearancePatentLlmClient(new AppearancePatentProperties(), new ObjectMapper(),
|
||||
null, brandCheckClient, mock(UserSecretUsageService.class));
|
||||
null, brandCheckClient, mock(UserSecretUsageService.class), new UnreachableCooldown());
|
||||
}
|
||||
|
||||
private static AppearancePatentResultRowDto newRow(String id) {
|
||||
@@ -204,7 +205,7 @@ class AppearancePatentLlmClientTest {
|
||||
null,
|
||||
brandCheckClient,
|
||||
mock(UserSecretUsageService.class)
|
||||
);
|
||||
, new UnreachableCooldown());
|
||||
AppearancePatentResultRowDto row = new AppearancePatentResultRowDto();
|
||||
row.setId("1");
|
||||
String dataText = """
|
||||
@@ -228,7 +229,7 @@ class AppearancePatentLlmClientTest {
|
||||
null,
|
||||
brandCheckClient,
|
||||
mock(UserSecretUsageService.class)
|
||||
);
|
||||
, new UnreachableCooldown());
|
||||
AppearancePatentResultRowDto row = new AppearancePatentResultRowDto();
|
||||
row.setId("1");
|
||||
String dataText = """
|
||||
@@ -251,7 +252,7 @@ class AppearancePatentLlmClientTest {
|
||||
null,
|
||||
brandCheckClient,
|
||||
mock(UserSecretUsageService.class)
|
||||
);
|
||||
, new UnreachableCooldown());
|
||||
AppearancePatentResultRowDto row = new AppearancePatentResultRowDto();
|
||||
row.setId("1");
|
||||
String dataText = """
|
||||
|
||||
+3
-2
@@ -1,6 +1,7 @@
|
||||
package com.nanri.aiimage.modules.appearancepatent.client;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.nanri.aiimage.common.retry.UnreachableCooldown;
|
||||
import com.nanri.aiimage.config.AppearancePatentProperties;
|
||||
import com.nanri.aiimage.config.BrandCheckProperties;
|
||||
import com.nanri.aiimage.modules.appearancepatent.model.dto.AppearancePatentResultRowDto;
|
||||
@@ -59,7 +60,7 @@ class AppearancePatentLlmClientTokenUsageTest {
|
||||
AppearancePatentProperties properties = new AppearancePatentProperties();
|
||||
properties.setLlmHost("http://127.0.0.1:" + server.getAddress().getPort());
|
||||
properties.setLlmRetryTimes(1);
|
||||
client = new AppearancePatentLlmClient(properties, objectMapper, null, localBrandCheckClient(), usageService);
|
||||
client = new AppearancePatentLlmClient(properties, objectMapper, null, localBrandCheckClient(), usageService, new UnreachableCooldown());
|
||||
}
|
||||
|
||||
private BrandCheckClient localBrandCheckClient() {
|
||||
@@ -68,7 +69,7 @@ class AppearancePatentLlmClientTokenUsageTest {
|
||||
brand.setRetryTimes(1);
|
||||
brand.setRetryIntervalMillis(0);
|
||||
brand.setTotalTimeoutMillis(5000);
|
||||
return new BrandCheckClient(brand, null, null);
|
||||
return new BrandCheckClient(brand, null, null, new UnreachableCooldown());
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
|
||||
Reference in New Issue
Block a user