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/FIFOEntryCache.java |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/opends/src/server/org/opends/server/extensions/FIFOEntryCache.java b/opends/src/server/org/opends/server/extensions/FIFOEntryCache.java
index aff52ec..0a78dcf 100644
--- a/opends/src/server/org/opends/server/extensions/FIFOEntryCache.java
+++ b/opends/src/server/org/opends/server/extensions/FIFOEntryCache.java
@@ -55,6 +55,7 @@
 import org.opends.server.types.Entry;
 import org.opends.server.types.InitializationException;
 import org.opends.server.types.SearchFilter;
+import org.opends.server.types.Attribute;
 import org.opends.server.util.ServerConstants;
 import org.opends.messages.MessageBuilder;
 
@@ -231,10 +232,14 @@
     CacheEntry e = dnMap.get(entryDN);
     if (e == null)
     {
+      // Indicate cache miss.
+      cacheMisses.set(cacheMisses.incrementAndGet());
       return null;
     }
     else
     {
+      // Indicate cache hit.
+      cacheHits.set(cacheHits.incrementAndGet());
       return e.getEntry();
     }
   }
@@ -990,6 +995,35 @@
 
 
   /**
+   * {@inheritDoc}
+   */
+  public ArrayList<Attribute> getMonitorData()
+  {
+    ArrayList<Attribute> attrs = new ArrayList<Attribute>();
+
+    try {
+      attrs = EntryCacheCommon.getGenericMonitorData(
+        new Long(cacheHits.longValue()),
+        new Long(cacheMisses.longValue()),
+        null,
+        new Long(maxAllowedMemory),
+        new Long(dnMap.size()),
+        (((maxEntries != Integer.MAX_VALUE) &&
+          (maxEntries != Long.MAX_VALUE)) ?
+           new Long(maxEntries) : new Long(0))
+        );
+    } 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