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/BackupBackend.java |   32 ++++++++++++++++++--------------
 1 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/BackupBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/BackupBackend.java
index 1a1369f..3151938 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/BackupBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/BackupBackend.java
@@ -26,6 +26,7 @@
  */
 package org.opends.server.backends;
 
+import static org.forgerock.util.Reject.*;
 import static org.opends.messages.BackendMessages.*;
 import static org.opends.server.config.ConfigConstants.*;
 import static org.opends.server.schema.BooleanSyntax.*;
@@ -328,7 +329,7 @@
   @Override
   public ConditionResult hasSubordinates(DN entryDN) throws DirectoryException
   {
-    long ret = numSubordinates(entryDN, false);
+    long ret = getNumberOfSubordinates(entryDN, false);
     if(ret < 0)
     {
       return ConditionResult.UNDEFINED;
@@ -336,19 +337,22 @@
     return ConditionResult.valueOf(ret != 0);
   }
 
-
+  /** {@inheritDoc} */
+  @Override
+  public long getNumberOfEntriesInBaseDN(DN baseDN) throws DirectoryException {
+    checkNotNull(baseDN, "baseDN must not be null");
+    return getNumberOfSubordinates(baseDN, true) + 1;
+  }
 
   /** {@inheritDoc} */
   @Override
-  public long numSubordinates(DN entryDN, boolean subtree)
-      throws DirectoryException
-  {
-    // If the requested entry was null, then return undefined.
-    if (entryDN == null)
-    {
-      return -1;
-    }
+  public long getNumberOfChildren(DN parentDN) throws DirectoryException {
+    checkNotNull(parentDN, "parentDN must not be null");
+    return getNumberOfSubordinates(parentDN, false);
+  }
 
+  private long getNumberOfSubordinates(DN entryDN, boolean includeSubtree) throws DirectoryException
+  {
     // If the requested entry was the backend base entry, then return
     // the number of backup directories.
     if (backupBaseDN.equals(entryDN))
@@ -366,8 +370,9 @@
 
         // If subtree is included, count the number of entries for each
         // backup directory.
-        if (subtree)
+        if (includeSubtree)
         {
+          count++;
           try
           {
             BackupDirectory backupDirectory = backupDirectories.get(dir).getBackupDirectory();
@@ -375,7 +380,8 @@
           }
           catch (Exception e)
           {
-            return -1;
+            throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, ERR_BACKUP_INVALID_BACKUP_DIRECTORY.get(
+                entryDN, e.getMessage()));
           }
         }
 
@@ -429,8 +435,6 @@
     }
   }
 
-
-
   /** {@inheritDoc} */
   @Override
   public Entry getEntry(DN entryDN)

--
Gitblit v1.10.0