From 4a58a441a5b81031a86bc01b630b9e19894f4d80 Mon Sep 17 00:00:00 2001
From: abobrov <abobrov@localhost>
Date: Sun, 02 Dec 2007 17:54:15 +0000
Subject: [PATCH] - [Issue 2007]  generic mechanism for using mulitple caches. - [Issue 2049]  dsconfig is unable to configure the entry cache.

---
 opendj-sdk/opends/src/server/org/opends/server/extensions/FIFOEntryCache.java |   34 ++++++++++++++++++++--------------
 1 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/extensions/FIFOEntryCache.java b/opendj-sdk/opends/src/server/org/opends/server/extensions/FIFOEntryCache.java
index 63fb87e..2508aba 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/extensions/FIFOEntryCache.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/extensions/FIFOEntryCache.java
@@ -213,6 +213,10 @@
    */
   public boolean containsEntry(DN entryDN)
   {
+    if (entryDN == null) {
+      return false;
+    }
+
     // Indicate whether the DN map contains the specified DN.
     return dnMap.containsKey(entryDN);
   }
@@ -229,13 +233,13 @@
     if (e == null)
     {
       // Indicate cache miss.
-      cacheMisses.set(cacheMisses.incrementAndGet());
+      cacheMisses.getAndIncrement();
       return null;
     }
     else
     {
       // Indicate cache hit.
-      cacheHits.set(cacheHits.incrementAndGet());
+      cacheHits.getAndIncrement();
       return e.getEntry();
     }
   }
@@ -264,7 +268,7 @@
   /**
    * {@inheritDoc}
    */
-  protected DN getEntryDN(Backend backend, long entryID)
+  public DN getEntryDN(Backend backend, long entryID)
   {
     // Locate specific backend map and return the entry DN by ID.
     HashMap<Long,CacheEntry> backendMap = idMap.get(backend);
@@ -284,11 +288,6 @@
    */
   public void putEntry(Entry entry, Backend backend, long entryID)
   {
-    // Check exclude and include filters first.
-    if (!filtersAllowCaching(entry)) {
-      return;
-    }
-
     // Create the cache entry based on the provided information.
     CacheEntry cacheEntry = new CacheEntry(entry, backend, entryID);
 
@@ -400,11 +399,6 @@
    */
   public boolean putEntryIfAbsent(Entry entry, Backend backend, long entryID)
   {
-    // Check exclude and include filters first.
-    if (!filtersAllowCaching(entry)) {
-      return true;
-    }
-
     // Create the cache entry based on the provided information.
     CacheEntry cacheEntry = new CacheEntry(entry, backend, entryID);
 
@@ -1004,7 +998,9 @@
     try {
       attrs = EntryCacheCommon.getGenericMonitorData(
         new Long(cacheHits.longValue()),
-        new Long(cacheMisses.longValue()),
+        // If cache misses is maintained by default cache
+        // get it from there and if not point to itself.
+        DirectoryServer.getEntryCache().getCacheMisses(),
         null,
         new Long(maxAllowedMemory),
         new Long(dnMap.size()),
@@ -1024,6 +1020,16 @@
 
 
   /**
+   * {@inheritDoc}
+   */
+  public Long getCacheCount()
+  {
+    return new Long(dnMap.size());
+  }
+
+
+
+  /**
    * 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