From a79aa3ddbd25b8c7c0abc6c8d5a00c7ed27dd81d 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.

---
 opends/src/server/org/opends/server/extensions/FileSystemEntryCache.java |   38 +++++++++++++++++++++-----------------
 1 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/opends/src/server/org/opends/server/extensions/FileSystemEntryCache.java b/opends/src/server/org/opends/server/extensions/FileSystemEntryCache.java
index 991f644..4928f94 100644
--- a/opends/src/server/org/opends/server/extensions/FileSystemEntryCache.java
+++ b/opends/src/server/org/opends/server/extensions/FileSystemEntryCache.java
@@ -78,8 +78,8 @@
 import org.opends.server.types.FilePermission;
 import org.opends.server.types.DebugLogLevel;
 import org.opends.server.types.OpenDsException;
-import org.opends.server.types.Attribute;
 import org.opends.server.loggers.debug.DebugTracer;
+import org.opends.server.types.Attribute;
 import org.opends.server.util.ServerConstants;
 
 import static org.opends.server.loggers.debug.DebugLogger.*;
@@ -607,6 +607,10 @@
    */
   public boolean containsEntry(DN entryDN)
   {
+    if (entryDN == null) {
+      return false;
+    }
+
     // Indicate whether the DN map contains the specified DN.
     boolean containsEntry = false;
     cacheReadLock.lock();
@@ -631,10 +635,10 @@
       if (dnMap.get(entryDN) != null) {
         entry = getEntryFromDB(entryDN);
         // Indicate cache hit.
-        cacheHits.set(cacheHits.incrementAndGet());
+        cacheHits.getAndIncrement();
       } else {
         // Indicate cache miss.
-        cacheMisses.set(cacheMisses.incrementAndGet());
+        cacheMisses.getAndIncrement();
       }
     } finally {
       cacheReadLock.unlock();
@@ -662,7 +666,7 @@
   /**
    * {@inheritDoc}
    */
-  protected DN getEntryDN(Backend backend, long entryID) {
+  public DN getEntryDN(Backend backend, long entryID) {
 
     DN entryDN = null;
     cacheReadLock.lock();
@@ -684,13 +688,8 @@
   /**
    * {@inheritDoc}
    */
-  public void putEntry(Entry entry, Backend backend, long entryID) {
-
-    // Check exclude and include filters first.
-    if (!filtersAllowCaching(entry)) {
-      return;
-    }
-
+  public void putEntry(Entry entry, Backend backend, long entryID)
+  {
     // Obtain a lock on the cache.  If this fails, then don't do anything.
     try {
       if (!cacheWriteLock.tryLock(getLockTimeout(), TimeUnit.MILLISECONDS)) {
@@ -714,11 +713,6 @@
    */
   public boolean putEntryIfAbsent(Entry entry, Backend backend, long entryID)
   {
-    // Check exclude and include filters first.
-    if (!filtersAllowCaching(entry)) {
-      return true;
-    }
-
     try {
       // Obtain a lock on the cache.  If this fails, then don't do anything.
       if (! cacheWriteLock.tryLock(getLockTimeout(), TimeUnit.MILLISECONDS)) {
@@ -1350,7 +1344,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(),
         new Long(entryCacheEnv.getStats(
           entryCacheEnvStatsConfig).getTotalLogSize()),
         new Long(maxAllowedMemory),
@@ -1369,6 +1365,14 @@
   }
 
   /**
+   * {@inheritDoc}
+   */
+  public Long getCacheCount()
+  {
+    return new Long(dnMap.size());
+  }
+
+  /**
    * Retrieves and decodes the entry with the specified DN from JE backend db.
    *
    * @param  entryDN   The DN of the entry to retrieve.

--
Gitblit v1.10.0