@Test public void testSimpleCaseXML() throws InterruptedException { CacheManager manager = new CacheManager(getClass().getResourceAsStream("/ehcache-scheduled-refresh.xml")); try { Cache cache = manager.getCache("sr-test"); for (int i = 0; i < 10; i++) { cache.put(new Element(i, i + "")); } waitOnExtensionState(ScheduledRefreshCacheExtension.findExtensionsFromCache(cache).iterator().next(), TIMED_WAIT_IN_SECS,2); for (Object key : cache.getKeys()) { Element val = cache.get(key); int iVal = ((Number) key).intValue(); if ((iVal & 0x01) == 0) { Assert.assertEquals(iVal + 20000, Long.parseLong((String) val.getObjectValue())); } else { Assert.assertEquals(iVal + 10000, Long.parseLong((String) val.getObjectValue())); } } } finally { manager.shutdown(); } }
static Collection<ScheduledRefreshCacheExtension> findExtensionsFromCache(Ehcache cache) { LinkedList<ScheduledRefreshCacheExtension> exts=new LinkedList<ScheduledRefreshCacheExtension>(); for (CacheExtension ce : cache.getRegisteredCacheExtensions()) { if (ce instanceof ScheduledRefreshCacheExtension) { exts.add((ScheduledRefreshCacheExtension)ce); } } return exts; }
ScheduledRefreshCacheExtension implements CacheExtension { static Collection<ScheduledRefreshCacheExtension> findExtensionsFromCache(Ehcache cache) { LinkedList<ScheduledRefreshCacheExtension> exts=new LinkedList<ScheduledRefreshCacheExtension>(); for (CacheExtension ce : cache.getRegisteredCacheExtensions()) { if (ce instanceof ScheduledRefreshCacheExtension) { exts.add((ScheduledRefreshCacheExtension)ce); } } return exts; } }
ScheduledRefreshCacheExtension implements CacheExtension { static Collection<ScheduledRefreshCacheExtension> findExtensionsFromCache(Ehcache cache) { LinkedList<ScheduledRefreshCacheExtension> exts=new LinkedList<ScheduledRefreshCacheExtension>(); for (CacheExtension ce : cache.getRegisteredCacheExtensions()) { if (ce instanceof ScheduledRefreshCacheExtension) { exts.add((ScheduledRefreshCacheExtension)ce); } } return exts; } ScheduledRefreshCacheExtension(ScheduledRefreshConfiguration config, Ehcache cache); }
ScheduledRefreshCacheExtension implements CacheExtension { static Collection<ScheduledRefreshCacheExtension> findExtensionsFromCache(Ehcache cache) { LinkedList<ScheduledRefreshCacheExtension> exts=new LinkedList<ScheduledRefreshCacheExtension>(); for (CacheExtension ce : cache.getRegisteredCacheExtensions()) { if (ce instanceof ScheduledRefreshCacheExtension) { exts.add((ScheduledRefreshCacheExtension)ce); } } return exts; } ScheduledRefreshCacheExtension(ScheduledRefreshConfiguration config, Ehcache cache); @Override void init(); @Override void dispose(); @Override CacheExtension clone(Ehcache cache); @Override Status getStatus(); @org.terracotta.statistics.Statistic(name = "refresh", tags = "scheduledrefresh") long getRefreshCount(); @org.terracotta.statistics.Statistic(name = "job", tags = "scheduledrefresh") long getJobCount(); @org.terracotta.statistics.Statistic(name = "keysprocessed", tags = "scheduledrefresh") long getKeysProcessedCount(); static Set<ExtendedStatistics.Statistic<Number>> findRefreshStatistics(Ehcache cache); static Set<ExtendedStatistics.Statistic<Number>> findJobStatistics(Ehcache cache); static Set<ExtendedStatistics.Statistic<Number>> findKeysProcessedStatistics(Ehcache cache); static ExtendedStatistics.Statistic<Number> findRefreshStatistic(Ehcache cache); static ExtendedStatistics.Statistic<Number> findJobStatistic(Ehcache cache); static ExtendedStatistics.Statistic<Number> findKeysProcessedStatistic(Ehcache cache); }
ScheduledRefreshCacheExtension implements CacheExtension { static Collection<ScheduledRefreshCacheExtension> findExtensionsFromCache(Ehcache cache) { LinkedList<ScheduledRefreshCacheExtension> exts=new LinkedList<ScheduledRefreshCacheExtension>(); for (CacheExtension ce : cache.getRegisteredCacheExtensions()) { if (ce instanceof ScheduledRefreshCacheExtension) { exts.add((ScheduledRefreshCacheExtension)ce); } } return exts; } ScheduledRefreshCacheExtension(ScheduledRefreshConfiguration config, Ehcache cache); @Override void init(); @Override void dispose(); @Override CacheExtension clone(Ehcache cache); @Override Status getStatus(); @org.terracotta.statistics.Statistic(name = "refresh", tags = "scheduledrefresh") long getRefreshCount(); @org.terracotta.statistics.Statistic(name = "job", tags = "scheduledrefresh") long getJobCount(); @org.terracotta.statistics.Statistic(name = "keysprocessed", tags = "scheduledrefresh") long getKeysProcessedCount(); static Set<ExtendedStatistics.Statistic<Number>> findRefreshStatistics(Ehcache cache); static Set<ExtendedStatistics.Statistic<Number>> findJobStatistics(Ehcache cache); static Set<ExtendedStatistics.Statistic<Number>> findKeysProcessedStatistics(Ehcache cache); static ExtendedStatistics.Statistic<Number> findRefreshStatistic(Ehcache cache); static ExtendedStatistics.Statistic<Number> findJobStatistic(Ehcache cache); static ExtendedStatistics.Statistic<Number> findKeysProcessedStatistic(Ehcache cache);  }