From 9f0904fda87bfcf921deeccdbaeafe834fbad696 Mon Sep 17 00:00:00 2001
From: Yannick Lecaillez <yannick.lecaillez@forgerock.com>
Date: Fri, 24 Apr 2015 14:30:47 +0000
Subject: [PATCH] OPENDJ-1725: Persistit: very long recovery and many discarded txns after addrate test

---
 opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ID2Entry.java |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ID2Entry.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ID2Entry.java
index 912c64e..9a23d94 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ID2Entry.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ID2Entry.java
@@ -26,6 +26,7 @@
  */
 package org.opends.server.backends.pluggable;
 
+import static org.forgerock.util.Reject.*;
 import static org.forgerock.util.Utils.*;
 import static org.opends.messages.JebMessages.*;
 import static org.opends.server.core.DirectoryServer.*;
@@ -44,6 +45,7 @@
 import org.forgerock.opendj.ldap.ByteStringBuilder;
 import org.forgerock.opendj.ldap.DecodeException;
 import org.opends.server.api.CompressedSchema;
+import org.opends.server.backends.pluggable.spi.Cursor;
 import org.opends.server.backends.pluggable.spi.ReadableTransaction;
 import org.opends.server.backends.pluggable.spi.StorageRuntimeException;
 import org.opends.server.backends.pluggable.spi.TreeName;
@@ -362,6 +364,24 @@
     return get0(id, txn.read(getName(), id.toByteString()));
   }
 
+  /**
+   * Check that a record entry exists in the entry database.
+   *
+   * @param txn a non null database transaction
+   * @param id The entry ID which forms the key.
+   * @return True if an entry with entryID exists
+   * @throws DirectoryException If a problem occurs while getting the entry.
+   * @throws StorageRuntimeException If an error occurs in the database.
+   */
+  public boolean containsEntryID(ReadableTransaction txn, EntryID id)
+ {
+    checkNotNull(txn, "txn must not be null");
+    checkNotNull(id, "id must not be null");
+    try(final Cursor<ByteString, ByteString> cursor = txn.openCursor(getName())) {
+      return cursor.positionToKey(id.toByteString());
+    }
+ }
+
   private Entry get0(EntryID id, ByteString value) throws DirectoryException
   {
     if (value == null)

--
Gitblit v1.10.0