Exemplo n.º 1
0
 /** {@inheritDoc} */
 public void notifyRemoveAll(Ehcache cache) {
   if (!statisticsEnabled.get()) {
     return;
   }
   for (CacheUsageListener l : listeners) {
     l.notifyRemoveAll();
   }
 }
Exemplo n.º 2
0
 /** {@inheritDoc} */
 public void setStatisticsEnabled(boolean enableStatistics) {
   if (enableStatistics) {
     clearStatistics();
   }
   statisticsEnabled.set(enableStatistics);
   for (CacheUsageListener l : listeners) {
     l.notifyStatisticsEnabledChanged(enableStatistics);
   }
 }
Exemplo n.º 3
0
 /** {@inheritDoc} */
 public void notifyElementExpired(Ehcache cache, Element element) {
   if (!statisticsEnabled.get()) {
     return;
   }
   cacheElementExpired.incrementAndGet();
   for (CacheUsageListener l : listeners) {
     l.notifyCacheElementExpired();
   }
 }
Exemplo n.º 4
0
 /** {@inheritDoc} */
 public void notifyElementUpdated(Ehcache cache, Element element) throws CacheException {
   if (!statisticsEnabled.get()) {
     return;
   }
   cacheElementUpdated.incrementAndGet();
   for (CacheUsageListener l : listeners) {
     l.notifyCacheElementUpdated();
   }
 }
Exemplo n.º 5
0
 /** {@inheritDoc} */
 public void cacheMissNotFound() {
   if (!statisticsEnabled.get()) {
     return;
   }
   cacheMissNotFound.incrementAndGet();
   for (CacheUsageListener l : listeners) {
     l.notifyCacheMissedWithNotFound();
   }
 }
Exemplo n.º 6
0
 /** {@inheritDoc} */
 public void cacheHitOnDisk() {
   if (!statisticsEnabled.get()) {
     return;
   }
   cacheHitOnDiskCount.incrementAndGet();
   for (CacheUsageListener l : listeners) {
     l.notifyCacheHitOnDisk();
   }
 }
Exemplo n.º 7
0
 /** {@inheritDoc} */
 public void setStatisticsAccuracy(int statisticsAccuracy) {
   if (!Statistics.isValidStatisticsAccuracy(statisticsAccuracy)) {
     throw new IllegalArgumentException(
         "Invalid statistics accuracy value: " + statisticsAccuracy);
   }
   this.statisticsAccuracy.set(statisticsAccuracy);
   for (CacheUsageListener l : listeners) {
     l.notifyStatisticsAccuracyChanged(statisticsAccuracy);
   }
 }
Exemplo n.º 8
0
 /** {@inheritDoc} */
 public void clearStatistics() {
   cacheHitInMemoryCount.set(0);
   cacheHitOnDiskCount.set(0);
   cacheMissExpired.set(0);
   cacheMissNotFound.set(0);
   cacheElementEvictedCount.set(0);
   totalGetTimeTakenMillis.set(0);
   cacheElementRemoved.set(0);
   cacheElementExpired.set(0);
   cacheElementPut.set(0);
   cacheElementUpdated.set(0);
   minGetTimeMillis.set(MIN_MAX_DEFAULT_VALUE);
   maxGetTimeMillis.set(MIN_MAX_DEFAULT_VALUE);
   for (CacheUsageListener l : listeners) {
     l.notifyStatisticsCleared();
   }
 }
Exemplo n.º 9
0
 /** {@inheritDoc} */
 public void addGetTimeMillis(long millis) {
   if (!statisticsEnabled.get()) {
     return;
   }
   totalGetTimeTakenMillis.addAndGet(millis);
   for (CacheUsageListener l : listeners) {
     l.notifyTimeTakenForGet(millis);
   }
   if (minGetTimeMillis.get() == MIN_MAX_DEFAULT_VALUE
       || (millis < minGetTimeMillis.get() && millis > 0)) {
     minGetTimeMillis.set(millis);
   }
   if (maxGetTimeMillis.get() == MIN_MAX_DEFAULT_VALUE
       || (millis > maxGetTimeMillis.get() && millis > 0)) {
     maxGetTimeMillis.set(millis);
   }
 }
Exemplo n.º 10
0
 /** {@inheritDoc} */
 public void dispose() {
   for (CacheUsageListener l : listeners) {
     l.dispose();
   }
 }