All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pl.allegro.tech.hermes.management.infrastructure.detection.InactiveTopicsDetectionScheduler Maven / Gradle / Ivy

There is a newer version: 2.10.4
Show newest version
package pl.allegro.tech.hermes.management.infrastructure.detection;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import pl.allegro.tech.hermes.management.domain.detection.InactiveTopicsDetectionJob;
import pl.allegro.tech.hermes.management.infrastructure.leader.ManagementLeadership;

public class InactiveTopicsDetectionScheduler {
  private final InactiveTopicsDetectionJob job;
  private final ManagementLeadership leader;

  private static final Logger logger =
      LoggerFactory.getLogger(InactiveTopicsDetectionScheduler.class);

  public InactiveTopicsDetectionScheduler(
      InactiveTopicsDetectionJob job, ManagementLeadership leader) {
    this.leader = leader;
    this.job = job;
  }

  @Scheduled(cron = "${detection.inactive-topics.cron}")
  public void run() {
    if (leader.isLeader()) {
      logger.info("Inactive topics detection started");
      job.detectAndNotify();
    } else {
      logger.info("Inactive topics detection not started - not a leader");
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy