Commit ebdfa50c authored by Tigran Mkrtchyan's avatar Tigran Mkrtchyan
Browse files

nfs: cache: publish more information through JMX

parent fad7c63e
......@@ -26,6 +26,7 @@ import java.util.MissingResourceException;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level;
......@@ -77,10 +78,10 @@ public class Cache<K, V> extends TimerTask {
expiredEntries.add(cacheElement.getObject());
}
}
_lastClean.set(now);
} finally {
_accessLock.unlock();
}
for (V v : expiredEntries) {
_eventListener.notifyExpired(this, v);
}
......@@ -134,6 +135,11 @@ public class Cache<K, V> extends TimerTask {
*/
private final CacheMXBean<V> _mxBean;
/**
* Last cleanup time
*/
private final AtomicLong _lastClean = new AtomicLong(System.currentTimeMillis());
/**
* Create new cache instance with default {@link CacheEventListener} and
* default cleanup period.
......@@ -361,4 +367,8 @@ public class Cache<K, V> extends TimerTask {
}
return entries;
}
public long lastClean() {
return _lastClean.get();
}
}
......@@ -29,6 +29,7 @@ public interface CacheMXBean<V> {
long getEntryLiveTime();
int getSize();
String[] getEntries();
long getLastClean();
}
......@@ -84,6 +84,11 @@ public class CacheMXBeanImpl<K,V> implements CacheMXBean<V> {
public long getEntryLiveTime() {
return _cache.getEntryLiveTime();
}
@Override
public long getLastClean() {
return System.currentTimeMillis() - _cache.lastClean();
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment