예제 #1
0
  /**
   * Creates monitored proxy instance for underlying cache with given parameters.
   *
   * @param instance underlying cache.
   * @param statisticsAccuracy Ehcache statistics accuracy.
   * @param category category for related stats producer.
   * @param subsystem subsystem for related stats producer.
   * @param updatePeriod period (in milliseconds) in which stats values will be updated.
   */
  public MonitoredEhcache(
      Ehcache instance,
      int statisticsAccuracy,
      String category,
      String subsystem,
      long updatePeriod) {
    super(instance);
    underlyingCache.setStatisticsAccuracy(statisticsAccuracy);
    underlyingCache.setStatisticsEnabled(true);
    cacheProducer =
        new OnDemandStatsProducer<EhcacheStats>(
            underlyingCache.getName(), category, subsystem, new EhcacheStatsFactory());
    ProducerRegistryFactory.getProducerRegistryInstance().registerProducer(cacheProducer);

    PeriodicStatsUpdater.addTask(
        new TimerTask() {
          @Override
          public void run() {
            if (underlyingCache.isStatisticsEnabled()) {
              updateStats();
            }
          }
        },
        updatePeriod);
  }
예제 #2
0
 static {
   onDemandProducer =
       new OnDemandStatsProducer<SessionCountStats>(
           "SessionCountByTld",
           "web",
           IStatsProducer.SUBSYSTEM_BUILTIN,
           SessionCountFactory.DEFAULT_INSTANCE);
   ProducerRegistryFactory.getProducerRegistryInstance().registerProducer(onDemandProducer);
 }