提交更新
This commit is contained in:
@@ -14,8 +14,8 @@ public class AppearancePatentProperties {
|
||||
private int cozeBatchSize = 10;
|
||||
private int cozeConnectTimeoutMillis = 10000;
|
||||
private int cozeReadTimeoutMillis = 60000;
|
||||
private int cozePollIntervalMillis = 2000;
|
||||
private int cozePollTimeoutMillis = 120000;
|
||||
private int cozePollIntervalMillis = 5000;
|
||||
private int cozePollTimeoutMillis = 600000;
|
||||
private int staleTimeoutMinutes = 20;
|
||||
private String staleFinalizeCron = "0 */2 * * * *";
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ public class SimilarAsinProperties {
|
||||
private int cozeBatchSize = 10;
|
||||
private int cozeConnectTimeoutMillis = 10000;
|
||||
private int cozeReadTimeoutMillis = 60000;
|
||||
private int cozePollIntervalMillis = 2000;
|
||||
private int cozePollTimeoutMillis = 120000;
|
||||
private int cozePollIntervalMillis = 5000;
|
||||
private int cozePollTimeoutMillis = 600000;
|
||||
private int staleTimeoutMinutes = 20;
|
||||
private String staleFinalizeCron = "0 */2 * * * *";
|
||||
}
|
||||
|
||||
@@ -32,7 +32,9 @@ public class TaskOperationLockConfig implements WebMvcConfigurer {
|
||||
private static final class TaskOperationLockInterceptor implements HandlerInterceptor {
|
||||
|
||||
private static final Pattern TASK_PATH = Pattern.compile(".*/api/([^/]+)/tasks/(\\d+)(?:/.*)?$");
|
||||
private static final Pattern TASK_RESULT_PATH = Pattern.compile(".*/api/([^/]+)/tasks/(\\d+)/result/?$");
|
||||
private static final Set<String> MUTATING_METHODS = Set.of("POST", "PUT", "PATCH", "DELETE");
|
||||
private static final long RESULT_SUBMIT_WAIT_MILLIS = 10 * 60 * 1000L;
|
||||
private static final String LOCK_ATTRIBUTE = TaskOperationLockInterceptor.class.getName() + ".LOCK";
|
||||
|
||||
private final TaskDistributedLockService taskDistributedLockService;
|
||||
@@ -53,17 +55,25 @@ public class TaskOperationLockConfig implements WebMvcConfigurer {
|
||||
}
|
||||
String moduleType = matcher.group(1).trim().toUpperCase(Locale.ROOT).replace('-', '_');
|
||||
Long taskId = Long.valueOf(matcher.group(2));
|
||||
long waitMillis = resolveWaitMillis(request.getMethod(), uri);
|
||||
TaskDistributedLockService.LockHandle lockHandle =
|
||||
taskDistributedLockService.acquire(moduleType, taskId, TaskDistributedLockService.DEFAULT_WAIT_MILLIS);
|
||||
taskDistributedLockService.acquire(moduleType, taskId, waitMillis);
|
||||
if (lockHandle == null) {
|
||||
log.info("[task-operation-lock] rejected busy task operation method={} uri={} moduleType={} taskId={}",
|
||||
request.getMethod(), uri, moduleType, taskId);
|
||||
log.info("[task-operation-lock] rejected busy task operation method={} uri={} moduleType={} taskId={} waitMillis={}",
|
||||
request.getMethod(), uri, moduleType, taskId, waitMillis);
|
||||
throw new BusinessException(40902, "TASK_LOCK_BUSY");
|
||||
}
|
||||
request.setAttribute(LOCK_ATTRIBUTE, lockHandle);
|
||||
return true;
|
||||
}
|
||||
|
||||
private long resolveWaitMillis(String method, String uri) {
|
||||
if ("POST".equals(method) && TASK_RESULT_PATH.matcher(uri == null ? "" : uri).matches()) {
|
||||
return RESULT_SUBMIT_WAIT_MILLIS;
|
||||
}
|
||||
return TaskDistributedLockService.DEFAULT_WAIT_MILLIS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
|
||||
Reference in New Issue
Block a user