From b506a6cd184bd8cf477f7d9a7f968c990f153528 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Mon, 23 Mar 2015 23:03:19 +0000
Subject: [PATCH] OPENDJ-1848 CR-6383: Remove Storage getRMW and putIfAbsent methods

---
 opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java |   43 +++++++++++--------------------------------
 1 files changed, 11 insertions(+), 32 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java
index 6fd9fc7..f9d20a8 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java
@@ -1528,30 +1528,9 @@
             }
 
             EntryID entryID = rootContainer.getNextEntryID();
-
-            // Insert into dn2id.
-            if (!dn2id.insert(txn, entry.getName(), entryID))
-            {
-              // Do not ever expect to come through here.
-              throw new DirectoryException(ResultCode.ENTRY_ALREADY_EXISTS, ERR_JEB_ADD_ENTRY_ALREADY_EXISTS.get(entry
-                  .getName()));
-            }
-
-            // Update the referral database for referral entries.
-            if (!dn2uri.addEntry(txn, entry))
-            {
-              // Do not ever expect to come through here.
-              throw new DirectoryException(ResultCode.ENTRY_ALREADY_EXISTS, ERR_JEB_ADD_ENTRY_ALREADY_EXISTS.get(entry
-                  .getName()));
-            }
-
-            // Insert into id2entry.
-            if (!id2entry.insert(txn, entryID, entry))
-            {
-              // Do not ever expect to come through here.
-              throw new DirectoryException(ResultCode.ENTRY_ALREADY_EXISTS, ERR_JEB_ADD_ENTRY_ALREADY_EXISTS.get(entry
-                  .getName()));
-            }
+            dn2id.put(txn, entry.getName(), entryID);
+            dn2uri.addEntry(txn, entry);
+            id2entry.put(txn, entryID, entry);
 
             // Insert into the indexes, in index configuration order.
             final IndexBuffer indexBuffer = new IndexBuffer(EntryContainer.this);
@@ -1811,7 +1790,8 @@
       {
         leafDNKey = dnToDNKey(targetDN, baseDN.size());
       }
-      ByteString value = txn.getRMW(dn2id.getName(), leafDNKey);
+      // FIXME: previously this used a RMW lock - see OPENDJ-1878.
+      ByteString value = txn.read(dn2id.getName(), leafDNKey);
       if (value == null)
       {
         LocalizableMessage message = ERR_JEB_DELETE_NO_SUCH_OBJECT.get(targetDN);
@@ -1831,7 +1811,8 @@
     }
 
     // Check that the entry exists in id2entry and read its contents.
-    Entry entry = id2entry.getRMW(txn, leafID);
+    // FIXME: previously this used a RMW lock - see OPENDJ-1878.
+    Entry entry = id2entry.get(txn, leafID);
     if (entry == null)
     {
       throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
@@ -2023,7 +2004,7 @@
         {
           try
           {
-            EntryID entryID = dn2id.getRMW(txn, newEntry.getName());
+            EntryID entryID = dn2id.get(txn, newEntry.getName());
             if (entryID == null)
             {
               LocalizableMessage message = ERR_JEB_MODIFY_NO_SUCH_OBJECT.get(newEntry.getName());
@@ -2138,6 +2119,7 @@
   void renameEntry(final DN currentDN, final Entry entry, final ModifyDNOperation modifyDNOperation)
       throws StorageRuntimeException, DirectoryException, CanceledOperationException
   {
+    // FIXME: consistency + isolation cannot be maintained lock free - see OPENDJ-1878.
     try
     {
       storage.write(new WriteOperation()
@@ -2374,11 +2356,8 @@
                            ModifyDNOperation modifyDNOperation)
       throws DirectoryException, StorageRuntimeException
   {
-    if (!dn2id.insert(txn, newEntry.getName(), newID))
-    {
-      LocalizableMessage message = ERR_JEB_MODIFYDN_ALREADY_EXISTS.get(newEntry.getName());
-      throw new DirectoryException(ResultCode.ENTRY_ALREADY_EXISTS, message);
-    }
+    // FIXME: the core server should validate that the new subtree location is empty.
+    dn2id.put(txn, newEntry.getName(), newID);
     id2entry.put(txn, newID, newEntry);
     dn2uri.addEntry(txn, newEntry);
 

--
Gitblit v1.10.0