From 52cf2d05f87a2a9fd142a7e5354a0c0b3f254be5 Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Thu, 05 Jul 2007 14:45:35 +0000
Subject: [PATCH] A variation of issue 1876 :

---
 opendj-sdk/opends/src/server/org/opends/server/replication/server/DbHandler.java |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/server/DbHandler.java b/opendj-sdk/opends/src/server/org/opends/server/replication/server/DbHandler.java
index e749af2..a30dc7c 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/server/DbHandler.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/server/DbHandler.java
@@ -83,6 +83,14 @@
   private boolean done = false;
   private DirectoryThread thread = null;
   private Object flushLock = new Object();
+
+  // The High and low water mark for the max size of the msgQueue.
+  // the threads calling add() method will be blocked if the size of
+  // msgQueue becomes larger than the  MSG_QUEUE_HIMARK and will resume
+  // only when the size of the msgQueue goes below MSG_QUEUE_LOWMARK.
+  final static int MSG_QUEUE_HIMARK = 5000;
+  final static int MSG_QUEUE_LOWMARK = 4000;
+
   /**
    * the trim age in milliseconds.
    */
@@ -130,7 +138,7 @@
     synchronized (msgQueue)
     {
       int size = msgQueue.size();
-      while (size > 5000)     /* TODO : max size should be configurable */
+      while (size > MSG_QUEUE_HIMARK)
       {
         try
         {
@@ -265,7 +273,7 @@
         msgQueue.remove();
         current++;
       }
-      if (msgQueue.size() < 5000)
+      if (msgQueue.size() < MSG_QUEUE_LOWMARK)
         msgQueue.notify();
     }
   }

--
Gitblit v1.10.0