feat(1.5.0-beta1): 重试任务支持防止任务重复拉取配置
This commit is contained in:
parent
34e826cd97
commit
4de55b5fd3
@ -14,11 +14,8 @@ import java.util.Set;
|
||||
@Data
|
||||
public class ScanTask {
|
||||
|
||||
// private String namespaceId;
|
||||
//
|
||||
// private String groupName;
|
||||
|
||||
private Set<Integer> buckets;
|
||||
|
||||
// private Integer groupPartition;
|
||||
private String bucketStr;
|
||||
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -53,6 +54,7 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class ScanRetryActor extends AbstractActor {
|
||||
public static final ConcurrentSkipListSet<String> REPEATED_PULL= new ConcurrentSkipListSet<>(new ArrayList<>());
|
||||
private final SystemProperties systemProperties;
|
||||
private final AccessTemplate accessTemplate;
|
||||
private final RetryMapper retryMapper;
|
||||
@ -67,6 +69,8 @@ public class ScanRetryActor extends AbstractActor {
|
||||
doScan(config);
|
||||
} catch (Exception e) {
|
||||
SnailJobLog.LOCAL.error("Data scanner processing exception. [{}]", config, e);
|
||||
} finally {
|
||||
REPEATED_PULL.remove(config.getBucketStr());
|
||||
}
|
||||
|
||||
}).build();
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.aizuda.snailjob.server.starter.dispatch;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.aizuda.snailjob.server.retry.task.support.dispatch.ScanRetryActor;
|
||||
import org.apache.pekko.actor.AbstractActor;
|
||||
import org.apache.pekko.actor.ActorRef;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
@ -71,10 +73,17 @@ public class ConsumerBucketActor extends AbstractActor {
|
||||
List<List<Integer>> partitions = Lists.partition(new ArrayList<>(totalBuckets),
|
||||
(totalBuckets.size() + retryMaxPullParallel - 1) / retryMaxPullParallel);
|
||||
for (List<Integer> buckets : partitions) {
|
||||
String key = StrUtil.join(StrUtil.COMMA, new TreeSet<>(buckets));
|
||||
if (ScanRetryActor.REPEATED_PULL.contains(key)) {
|
||||
SnailJobLog.LOCAL.warn("Discard the current scanning task because there are ongoing tasks in the current batch.[{}]", key);
|
||||
continue;
|
||||
}
|
||||
ScanTask scanTask = new ScanTask();
|
||||
scanTask.setBucketStr(key);
|
||||
scanTask.setBuckets(new HashSet<>(buckets));
|
||||
ActorRef scanRetryActorRef = ActorGenerator.scanRetryActor();
|
||||
scanRetryActorRef.tell(scanTask, scanRetryActorRef);
|
||||
ScanRetryActor.REPEATED_PULL.add(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user