From ac27a41b85595ecd2444a64d822ab37aa8722fed Mon Sep 17 00:00:00 2001
From: Yannick Lecaillez <yannick.lecaillez@forgerock.com>
Date: Thu, 21 May 2015 09:34:32 +0000
Subject: [PATCH] Use backendID for entry cache rather than backend instance.  RootContainer is now directly constructed with the Storage rather than getting it from the Backend.

---
 opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/EntryContainer.java |   27 +++++++++++++--------------
 1 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/EntryContainer.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/EntryContainer.java
index d7fdf3e..9371eb4 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/EntryContainer.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/EntryContainer.java
@@ -46,7 +46,6 @@
 import org.opends.server.admin.std.server.LocalDBBackendCfg;
 import org.opends.server.admin.std.server.LocalDBIndexCfg;
 import org.opends.server.admin.std.server.LocalDBVLVIndexCfg;
-import org.opends.server.api.Backend;
 import org.opends.server.api.ClientConnection;
 import org.opends.server.api.EntryCache;
 import org.opends.server.api.plugin.PluginResult.SubordinateDelete;
@@ -96,8 +95,8 @@
   /** The vlv index configuration manager. */
   private final VLVJEIndexCfgManager vlvJEIndexCfgManager;
 
-  /** The backend to which this entry container belongs. */
-  private final Backend<?> backend;
+  /** ID of the backend to which this entry container belongs. */
+  private final String backendID;
 
   /** The root container in which this entryContainer belongs. */
   private final RootContainer rootContainer;
@@ -366,19 +365,19 @@
    *                storing on disk.
    * @param databasePrefix The prefix to use in the database names used by
    *                       this entry container.
-   * @param backend A reference to the JE backend that is creating this entry
-   *                container. It is needed by the Directory Server entry cache
-   *                methods.
+   * @param backendID ID of the JE backend that is creating this entry
+   *                  container. It is needed by the Directory Server
+   *                  entry cache methods.
    * @param config The configuration of the JE backend.
    * @param env The JE environment to create this entryContainer in.
    * @param rootContainer The root container this entry container is in.
    * @throws ConfigException if a configuration related error occurs.
    */
-  EntryContainer(DN baseDN, String databasePrefix, Backend<?> backend,
+  EntryContainer(DN baseDN, String databasePrefix, String backendID,
       LocalDBBackendCfg config, Environment env, RootContainer rootContainer)
           throws ConfigException
   {
-    this.backend = backend;
+    this.backendID = backendID;
     this.baseDN = baseDN;
     this.config = config;
     this.env = env;
@@ -446,7 +445,7 @@
         }
         id2subtree.open(); // No-op
 
-        logger.info(NOTE_JEB_SUBORDINATE_INDEXES_DISABLED, backend.getBackendID());
+        logger.info(NOTE_JEB_SUBORDINATE_INDEXES_DISABLED, backendID);
       }
 
       dn2uri = new DN2URI(databasePrefix + "_" + REFERRAL_DATABASE_NAME, env, this);
@@ -1214,7 +1213,7 @@
   {
     // Try the entry cache first.
     final EntryCache<?> entryCache = getEntryCache();
-    final Entry cacheEntry = entryCache.getEntry(backend, entryID.longValue());
+    final Entry cacheEntry = entryCache.getEntry(backendID, entryID.longValue());
     if (cacheEntry != null)
     {
       return cacheEntry;
@@ -1225,7 +1224,7 @@
     {
       // Put the entry in the cache making sure not to overwrite a newer copy
       // that may have been inserted since the time we read the cache.
-      entryCache.putEntryIfAbsent(entry, backend, entryID.longValue());
+      entryCache.putEntryIfAbsent(entry, backendID, entryID.longValue());
     }
     return entry;
   }
@@ -1519,7 +1518,7 @@
       EntryCache<?> entryCache = DirectoryServer.getEntryCache();
       if (entryCache != null)
       {
-        entryCache.putEntry(entry, backend, entryID.longValue());
+        entryCache.putEntry(entry, backendID, entryID.longValue());
       }
     }
     catch (DatabaseException | DirectoryException | CanceledOperationException e)
@@ -1886,7 +1885,7 @@
        * Put the entry in the cache making sure not to overwrite a newer copy that may have been
        * inserted since the time we read the cache.
        */
-      entryCache.putEntryIfAbsent(entry, backend, entryID.longValue());
+      entryCache.putEntryIfAbsent(entry, backendID, entryID.longValue());
     }
     return entry;
   }
@@ -1972,7 +1971,7 @@
       EntryCache<?> entryCache = DirectoryServer.getEntryCache();
       if (entryCache != null)
       {
-        entryCache.putEntry(newEntry, backend, entryID.longValue());
+        entryCache.putEntry(newEntry, backendID, entryID.longValue());
       }
     }
     catch (DatabaseException | DirectoryException | CanceledOperationException e)

--
Gitblit v1.10.0