From bf7b61bf7e22fc0c1c0bf69255f44d0139c86937 Mon Sep 17 00:00:00 2001
From: boli <boli@localhost>
Date: Thu, 24 Aug 2006 15:50:33 +0000
Subject: [PATCH] Add a configuration option to limit the number of entries that will be checked for matches during a search operation. A value of -1 or 0 will remove the limit, like the behavior of DS 5 and 6. Changed the "unlimited" values of size and time limits to be consistent with the lookthrough limit (-1 or 0). 

---
 opends/src/server/org/opends/server/core/CoreConfigManager.java |   85 +++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 82 insertions(+), 3 deletions(-)

diff --git a/opends/src/server/org/opends/server/core/CoreConfigManager.java b/opends/src/server/org/opends/server/core/CoreConfigManager.java
index 45c5f55..a19ffef 100644
--- a/opends/src/server/org/opends/server/core/CoreConfigManager.java
+++ b/opends/src/server/org/opends/server/core/CoreConfigManager.java
@@ -532,8 +532,8 @@
     // Determine the default server size limit.
     msgID = MSGID_CONFIG_CORE_DESCRIPTION_SIZE_LIMIT;
     IntegerConfigAttribute sizeLimitStub =
-         new IntegerConfigAttribute(ATTR_SIZE_LIMIT, getMessage(msgID), true,
-                                    false, false, true, 0, true,
+         new IntegerConfigAttribute(ATTR_SIZE_LIMIT, getMessage(msgID), false,
+                                    false, false, true, -1, true,
                                     Integer.MAX_VALUE);
     try
     {
@@ -567,7 +567,7 @@
     msgID = MSGID_CONFIG_CORE_DESCRIPTION_TIME_LIMIT;
     IntegerWithUnitConfigAttribute timeLimitStub =
          new IntegerWithUnitConfigAttribute(ATTR_TIME_LIMIT, getMessage(msgID),
-                                            false, timeUnits, true, 0, true,
+                                            false, timeUnits, true, -1, true,
                                             Integer.MAX_VALUE);
     try
     {
@@ -598,6 +598,41 @@
     }
 
 
+    // Determine the default server lookthrough limit.
+    msgID = MSGID_CONFIG_CORE_DESCRIPTION_LOOKTHROUGH_LIMIT;
+    IntegerConfigAttribute lookthroughLimitStub =
+         new IntegerConfigAttribute(ATTR_LOOKTHROUGH_LIMIT, getMessage(msgID),
+                                    false, false, false, true, -1, true,
+                                    Integer.MAX_VALUE);
+    try
+    {
+      IntegerConfigAttribute lookthroughLimitAttr =
+           (IntegerConfigAttribute)
+           configRoot.getConfigAttribute(lookthroughLimitStub);
+      if (lookthroughLimitAttr == null)
+      {
+        DirectoryServer.setLookthroughLimit(DEFAULT_LOOKTHROUGH_LIMIT);
+      }
+      else
+      {
+        DirectoryServer.setLookthroughLimit(
+            lookthroughLimitAttr.activeIntValue());
+      }
+    }
+    catch (Exception e)
+    {
+      // An error occurred, but this should not be considered fatal.  Log an
+      // error message and use the default.
+      assert debugException(CLASS_NAME, "initializeCoreConfig", e);
+
+      logError(ErrorLogCategory.CONFIGURATION, ErrorLogSeverity.SEVERE_ERROR,
+               MSGID_CONFIG_CORE_INVALID_LOOKTHROUGH_LIMIT, configRoot.getDN(),
+               String.valueOf(e));
+
+      DirectoryServer.setLookthroughLimit(DEFAULT_LOOKTHROUGH_LIMIT);
+    }
+
+
     // Determine the writability mode for the Directory Server.  By default, it
     // will be writable.
     WritabilityMode writabilityMode = WritabilityMode.ENABLED;
@@ -2135,6 +2170,40 @@
     }
 
 
+    // Get the server lookthrough limit.
+    int lookthroughLimit = DEFAULT_LOOKTHROUGH_LIMIT;
+    msgID = MSGID_CONFIG_CORE_DESCRIPTION_LOOKTHROUGH_LIMIT;
+    IntegerConfigAttribute lookthroughLimitStub =
+         new IntegerConfigAttribute(ATTR_LOOKTHROUGH_LIMIT,
+             getMessage(msgID), false, false, false, true, -1, true,
+             Integer.MAX_VALUE);
+    try
+    {
+      IntegerConfigAttribute lookthroughLimitAttr =
+           (IntegerConfigAttribute)
+           configEntry.getConfigAttribute(lookthroughLimitStub);
+      if (lookthroughLimitAttr != null)
+      {
+        lookthroughLimit = lookthroughLimitAttr.pendingIntValue();
+      }
+    }
+    catch (Exception e)
+    {
+      assert debugException(CLASS_NAME, "applyNewConfiguration", e);
+
+      // An error occurred, so we will not allow this configuration change to
+      // take place.
+      if (resultCode == ResultCode.SUCCESS)
+      {
+        resultCode = ResultCode.INVALID_ATTRIBUTE_SYNTAX;
+      }
+
+      msgID = MSGID_CONFIG_CORE_INVALID_LOOKTHROUGH_LIMIT;
+      resultMessages.add(getMessage(msgID, configEntry.getDN().toString(),
+                                    String.valueOf(e)));
+    }
+
+
     // Get the server writability mode.
     HashSet<String> writabilityModes = new HashSet<String>(3);
     writabilityModes.add(WritabilityMode.ENABLED.toString());
@@ -2377,6 +2446,16 @@
       }
 
 
+      DirectoryServer.setLookthroughLimit(lookthroughLimit);
+      if (detailedResults)
+      {
+        resultMessages.add(getMessage(MSGID_CONFIG_SET_ATTRIBUTE,
+                                      ATTR_LOOKTHROUGH_LIMIT,
+                                      String.valueOf(lookthroughLimit),
+                                      configEntryDN.toString()));
+      }
+
+
       DirectoryServer.setWritabilityMode(writabilityMode);
       if (detailedResults)
       {

--
Gitblit v1.10.0