Skip to content

Commit

Permalink
使用 fixedRate
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghost-chu committed Nov 11, 2024
1 parent 8eb8b06 commit 843a037
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class AnalyseService {
@Transactional
@Modifying
@Lock(LockModeType.READ)
@Scheduled(fixedDelayString = "${analyse.untrustip.interval}")
@Scheduled(fixedRateString = "${analyse.untrustip.interval}")
public void cronUntrustedIPAddresses() {
var list = ipMerger.merge(banHistoryRepository
.generateUntrustedIPAddresses(
Expand Down Expand Up @@ -101,7 +101,7 @@ public List<AnalysedRule> getOverDownloadIPAddresses() {
@Transactional
@Modifying
@Lock(LockModeType.READ)
@Scheduled(fixedDelayString = "${analyse.highriskips.interval}")
@Scheduled(fixedRateString = "${analyse.highriskips.interval}")
public void cronHighRiskIps() {
Set<IPAddress> list =
new HashSet<>(banHistoryRepository
Expand Down Expand Up @@ -145,7 +145,7 @@ public List<AnalysedRule> getHighRiskIps() {
@Transactional
@Modifying
@Lock(LockModeType.READ)
@Scheduled(fixedDelayString = "${analyse.highriskipv6identity.interval}")
@Scheduled(fixedRateString = "${analyse.highriskipv6identity.interval}")
public void cronHighRiskIPV6Identity() {
Set<IPAddress> list = new HashSet<>();
banHistoryRepository.findByPeerIp(
Expand Down Expand Up @@ -183,7 +183,7 @@ public List<AnalysedRule> getHighRiskIPV6Identity() {
@Transactional
@Modifying
@Lock(LockModeType.READ)
@Scheduled(fixedDelayString = "${analyse.overdownload.interval}")
@Scheduled(fixedRateString = "${analyse.overdownload.interval}")
public void cronUpdateOverDownload() {
var query = entityManager.createNativeQuery("""
WITH LatestSnapshots AS (
Expand Down Expand Up @@ -248,7 +248,7 @@ AggregatedUploads AS (
// @Transactional
// @Modifying
// @Lock(LockModeType.READ)
// @Scheduled(fixedDelayString = "${analyse.untrustip.interval}")
// @Scheduled(fixedRateString = "${analyse.untrustip.interval}")
// public void cronUpdateOverDownload() {
// var query = entityManager.createNativeQuery("""
// WITH LatestSnapshots AS (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void log(HttpServletRequest req, String action, boolean success, Map<Stri
auditQueue.add(new Audit(null, OffsetDateTime.now(), IPUtil.toInet(ServletUtil.getIP(req)), action, success, getHeaders(req), node));
}

@Scheduled(fixedDelay = 10, timeUnit = TimeUnit.SECONDS)
@Scheduled(fixedRate = 10, timeUnit = TimeUnit.SECONDS)
@Transactional
@Modifying
public void updateTrackerMetrics() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public GithubUpdateService(BanHistoryRepository banHistoryRepository, AnalyseSer
}


@Scheduled(fixedDelayString = "${service.githubruleupdate.interval}")
@Scheduled(fixedRateString = "${service.githubruleupdate.interval}")
@Transactional
public void githubRuleUpdate() throws IOException {
log.info("开始更新 GitHub 同步规则存储库...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public TrackerService(TrackedPeerRepository trackedPeerRepository,
this.semaphore = new Semaphore(maxParallelAnnounce);
}

@Scheduled(fixedDelayString = "${service.tracker.metrics-interval}")
@Scheduled(fixedRateString = "${service.tracker.metrics-interval}")
@Transactional
public void updateTrackerMetrics() {
var totalPeers = meterRegistry.gauge("sparkle_tracker_tracking_total_peers", trackedPeerRepository.count());
Expand All @@ -81,7 +81,7 @@ public void updateTrackerMetrics() {
log.info("[Tracker 实时] 总Peer: {}, 唯一Peer: {}, 唯一IP: {}, 活动种子: {}", totalPeers, uniquePeers, uniqueIps, activeTasks);
}

@Scheduled(fixedDelayString = "${service.tracker.cleanup-interval}")
@Scheduled(fixedRateString = "${service.tracker.cleanup-interval}")
@Transactional
public void cleanup() {
var count = trackedPeerRepository.deleteByLastTimeSeenLessThanEqual(TimeUtil.toUTC(System.currentTimeMillis() - inactiveInterval));
Expand All @@ -94,7 +94,7 @@ public void scheduleAnnounce(PeerAnnounce announce) {

@Modifying
@Transactional
@Scheduled(fixedDelayString = "${service.tracker.announce-flush-interval}")
@Scheduled(fixedRateString = "${service.tracker.announce-flush-interval}")
public void flushAnnounces() {
boolean locked = announceFlushLock.tryLock();
if (!locked) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public UserService(UserRepository userRepository) {
// return (UserDto) StpUtil.getLoginId();
// }

@Scheduled(fixedDelayString = "${service.user.metrics-interval}")
@Scheduled(fixedRateString = "${service.user.metrics-interval}")
@Transactional
public void updateUserMetrics() {
meterRegistry.gauge("sparkle_user_total", userRepository.count());
Expand Down

0 comments on commit 843a037

Please sign in to comment.