From 08f9243b55eb5f0f8030eebe976a0d85ffbd44c2 Mon Sep 17 00:00:00 2001
From: ludovicp <ludovicp@localhost>
Date: Fri, 30 Jul 2010 15:11:25 +0000
Subject: [PATCH] Implements a configurable limit in the number of persistent searches a server can handle.
---
opends/src/server/org/opends/server/core/DirectoryServer.java | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 52 insertions(+), 0 deletions(-)
diff --git a/opends/src/server/org/opends/server/core/DirectoryServer.java b/opends/src/server/org/opends/server/core/DirectoryServer.java
index fc9c4ce..a6317bf 100644
--- a/opends/src/server/org/opends/server/core/DirectoryServer.java
+++ b/opends/src/server/org/opends/server/core/DirectoryServer.java
@@ -60,6 +60,7 @@
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CopyOnWriteArraySet;
import java.lang.management.ManagementFactory;
+import java.util.concurrent.atomic.AtomicInteger;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
@@ -612,6 +613,9 @@
// a search.
private int lookthroughLimit;
+ // The current active persistent searches.
+ private AtomicInteger activePSearches = new AtomicInteger(0);
+
// Whether to use collect operation processing times in nanosecond resolution
private boolean useNanoTime;
@@ -8868,6 +8872,54 @@
/**
+ * Registers a new persistent search by increasing the count
+ * of active persistent searches. After receiving a persistent
+ * search request, a Local or Remote WFE must call this method to
+ * let the core server manage the count of concurrent persistent
+ * searches.
+ */
+ public static void registerPersistentSearch()
+ {
+ directoryServer.activePSearches.incrementAndGet();
+ }
+
+
+
+ /**
+ * Deregisters a canceled persistent search. After a persistent
+ * search is canceled, the handler must call this method to let
+ * the core server manage the count of concurrent persistent
+ * searches.
+ */
+ public static void deregisterPersistentSearch()
+ {
+ directoryServer.activePSearches.decrementAndGet();
+ }
+
+
+
+ /**
+ * Indicates whether a new persistent search is allowed.
+ *
+ * @return <CODE>true</CODE>if a new persistent search is allowed
+ * or <CODE>false</CODE>f if not.
+ */
+ public static boolean allowNewPersistentSearch()
+ {
+ //0 indicates that there is no limit.
+ int maxAllowedPSearch = getWorkQueue().getMaxPersistentSearchLimit();
+ if(maxAllowedPSearch ==0 ||
+ directoryServer.activePSearches.get() <
+ maxAllowedPSearch)
+ {
+ return true;
+ }
+ return false;
+ }
+
+
+
+ /**
* Retrieves the default maximum length of time in seconds that should be
* allowed when processing a search.
*
--
Gitblit v1.10.0