Class CrawlerMetricsImpl

java.lang.Object
com.norconex.crawler.core.metrics.CrawlerMetricsImpl
All Implemented Interfaces:
CrawlerMetrics, CrawlerMetricsMXBean, Closeable, AutoCloseable

public class CrawlerMetricsImpl extends Object implements CrawlerMetrics
  • Constructor Details

    • CrawlerMetricsImpl

      public CrawlerMetricsImpl()
  • Method Details

    • clearPersistedEventCounts

      public static void clearPersistedEventCounts(CacheManager cacheManager)
      Discards event counts left in the crawl store by a previous crawl session.

      Counts are meant to span the runs of one session — a crawl that was stopped and resumed did the work once, and the execution summary reports them as "incl. resumed" — but not to span sessions. Left alone, every recrawl of a source reported its own numbers plus those of every crawl before it, since the store outlives any one session and init(CrawlerSession) only ever cleared the in-memory copy.

      Called from CrawlerRunInfoResolver rather than from init, which runs on every node: the resolver elects a single node to perform one-time setup for a run, so the counts cannot be wiped out from under a node that has already started counting.

      Parameters:
      cacheManager - the crawl store to clear the counts in
    • init

      public void init(CrawlerSession crawlSession)
      Specified by:
      init in interface CrawlerMetrics
    • incrementCounter

      public void incrementCounter(String eventName, long incrementBy)
    • getEventCounts

      public Map<String,Long> getEventCounts()
      Specified by:
      getEventCounts in interface CrawlerMetricsMXBean
    • getProcessingCount

      public long getProcessingCount()
      Specified by:
      getProcessingCount in interface CrawlerMetricsMXBean
    • getProcessedCount

      public long getProcessedCount()
      Specified by:
      getProcessedCount in interface CrawlerMetricsMXBean
    • getQueuedCount

      public long getQueuedCount()
      Specified by:
      getQueuedCount in interface CrawlerMetricsMXBean
    • getBaselineCount

      public long getBaselineCount()
      Specified by:
      getBaselineCount in interface CrawlerMetricsMXBean
    • isClosed

      public boolean isClosed()
    • flush

      public void flush()
      Description copied from interface: CrawlerMetrics
      Flushes the metrics. Implementation specific, but normally forces a commit of any buffered event to storage and/or the synchronization of metrics across nodes.
      Specified by:
      flush in interface CrawlerMetrics
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface CrawlerMetrics