Skip to content

Commit

Permalink
[pinpoint-apm#11419] Adjust flush interval for node and link information
Browse files Browse the repository at this point in the history
  • Loading branch information
emeroad committed Aug 27, 2024
1 parent dda79e5 commit 9950871
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@

import com.navercorp.pinpoint.collector.dao.CachedStatisticsDao;
import jakarta.annotation.PostConstruct;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.stereotype.Component;

Expand All @@ -30,20 +33,27 @@

@Component
public class AvgMaxLinkScheduler {
private final Logger logger = LogManager.getLogger(this.getClass());

private final TaskScheduler scheduler;
private final List<CachedStatisticsDao> statisticsDaoList;
private final Duration flushPeriod;


public AvgMaxLinkScheduler(@Qualifier("statisticsLinkScheduler") TaskScheduler scheduler,
@Value("${collector.map-link.avg.flush-period:5000}") Duration flushPeriod,
List<CachedStatisticsDao> statisticsDaoList) {
this.scheduler = Objects.requireNonNull(scheduler, "scheduler");
this.statisticsDaoList = Objects.requireNonNull(statisticsDaoList, "statisticsDaoList");
this.flushPeriod = Objects.requireNonNull(flushPeriod, "flushPeriod");
logger.info("AvgMaxLinkScheduler flushPeriod={}", flushPeriod);
logger.info("AvgMaxLinkScheduler CachedStatisticsDao:{}", statisticsDaoList);
}

@PostConstruct
public void linkScheduling() {
for (CachedStatisticsDao dao : statisticsDaoList) {
this.scheduler.scheduleWithFixedDelay(dao::flushAvgMax, Duration.ofMillis(1000));
this.scheduler.scheduleWithFixedDelay(dao::flushAvgMax, flushPeriod);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@

import com.navercorp.pinpoint.collector.dao.CachedStatisticsDao;
import jakarta.annotation.PostConstruct;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.stereotype.Component;

Expand All @@ -30,20 +33,26 @@

@Component
public class StatisticsLinkScheduler {
private final Logger logger = LogManager.getLogger(this.getClass());

private final TaskScheduler scheduler;
private final List<CachedStatisticsDao> statisticsDaoList;
private final Duration flushPeriod;

public StatisticsLinkScheduler(@Qualifier("avgMaxLinkScheduler") TaskScheduler scheduler,
@Value("${collector.map-link.stat.flush-period:5000}") Duration flushPeriod,
List<CachedStatisticsDao> statisticsDaoList) {
this.scheduler = Objects.requireNonNull(scheduler, "scheduler");
this.statisticsDaoList = Objects.requireNonNull(statisticsDaoList, "statisticsDaoList");
this.flushPeriod = Objects.requireNonNull(flushPeriod, "flushPeriod");
logger.info("StatisticsLinkScheduler flushPeriod={}", flushPeriod);
logger.info("StatisticsLinkScheduler CachedStatisticsDao:{}", statisticsDaoList);
}

@PostConstruct
public void linkScheduling() {
for (CachedStatisticsDao dao : statisticsDaoList) {
this.scheduler.scheduleWithFixedDelay(dao::flushLink, Duration.ofMillis(1000));
this.scheduler.scheduleWithFixedDelay(dao::flushLink, flushPeriod);
}
}
}

0 comments on commit 9950871

Please sign in to comment.