From 4166c20ed1817f2792c6c4a6d12b810c7c256b72 Mon Sep 17 00:00:00 2001
From: abobrov <abobrov@localhost>
Date: Sun, 09 Sep 2007 14:48:37 +0000
Subject: [PATCH] - [Issue 1594] entry caches should have monitor information: implement generic entry cache monitor provider which allows any entry cache implementation current or future to provide a common or custom set of entry cache state data. update all existing entry cache implementations so that they provide their common state data to the entry cache monitor provider.
---
opends/src/server/org/opends/server/extensions/SoftReferenceEntryCache.java | 34 ++++++++++++++++++++++++++++++++++
1 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/opends/src/server/org/opends/server/extensions/SoftReferenceEntryCache.java b/opends/src/server/org/opends/server/extensions/SoftReferenceEntryCache.java
index ae8e5ba..5ed0888 100644
--- a/opends/src/server/org/opends/server/extensions/SoftReferenceEntryCache.java
+++ b/opends/src/server/org/opends/server/extensions/SoftReferenceEntryCache.java
@@ -46,6 +46,7 @@
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.loggers.debug.DebugTracer;
+import org.opends.server.types.Attribute;
import org.opends.server.types.CacheEntry;
import org.opends.server.types.ConfigChangeResult;
import org.opends.server.types.DebugLogLevel;
@@ -209,6 +210,8 @@
SoftReference<CacheEntry> ref = dnMap.get(entryDN);
if (ref == null)
{
+ // Indicate cache miss.
+ cacheMisses.set(cacheMisses.incrementAndGet());
return null;
}
else
@@ -216,10 +219,14 @@
CacheEntry cacheEntry = ref.get();
if (cacheEntry == null)
{
+ // Indicate cache miss.
+ cacheMisses.set(cacheMisses.incrementAndGet());
return null;
}
else
{
+ // Indicate cache hit.
+ cacheHits.set(cacheHits.incrementAndGet());
return cacheEntry.getEntry();
}
}
@@ -652,6 +659,33 @@
/**
+ * {@inheritDoc}
+ */
+ public ArrayList<Attribute> getMonitorData()
+ {
+ ArrayList<Attribute> attrs = new ArrayList<Attribute>();
+
+ try {
+ attrs = EntryCacheCommon.getGenericMonitorData(
+ new Long(cacheHits.longValue()),
+ new Long(cacheMisses.longValue()),
+ null,
+ null,
+ new Long(dnMap.size()),
+ null
+ );
+ } catch (Exception e) {
+ if (debugEnabled()) {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
+ }
+
+ return attrs;
+ }
+
+
+
+ /**
* Return a verbose string representation of the current cache maps.
* This is useful primary for debugging and diagnostic purposes such
* as in the entry cache unit tests.
--
Gitblit v1.10.0