From 025d8fe096c5f981059c8c3cab6efb279ffdfe5f Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Tue, 18 Jul 2006 22:29:12 +0000
Subject: [PATCH] Update the FIFO and soft reference entry cache implementations to convert the lock timeout attribute to use an integer with unit syntax rather than just an integer.
---
opends/src/server/org/opends/server/extensions/SoftReferenceEntryCache.java | 69 ++++++++++++++++++++++------------
1 files changed, 44 insertions(+), 25 deletions(-)
diff --git a/opends/src/server/org/opends/server/extensions/SoftReferenceEntryCache.java b/opends/src/server/org/opends/server/extensions/SoftReferenceEntryCache.java
index 21047dc..ffcd4bb 100644
--- a/opends/src/server/org/opends/server/extensions/SoftReferenceEntryCache.java
+++ b/opends/src/server/org/opends/server/extensions/SoftReferenceEntryCache.java
@@ -32,6 +32,7 @@
import java.lang.ref.SoftReference;
import java.util.ArrayList;
import java.util.HashSet;
+import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
@@ -43,7 +44,7 @@
import org.opends.server.config.ConfigAttribute;
import org.opends.server.config.ConfigEntry;
import org.opends.server.config.ConfigException;
-import org.opends.server.config.IntegerConfigAttribute;
+import org.opends.server.config.IntegerWithUnitConfigAttribute;
import org.opends.server.config.StringConfigAttribute;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.InitializationException;
@@ -84,6 +85,15 @@
+ /**
+ * The set of time units that will be used for expressing the task retention
+ * time.
+ */
+ private static final LinkedHashMap<String,Double> timeUnits =
+ new LinkedHashMap<String,Double>();
+
+
+
// The mapping between entry DNs and their corresponding entries.
private ConcurrentHashMap<DN,SoftReference<CacheEntry>> dnMap;
@@ -112,6 +122,14 @@
+ static
+ {
+ timeUnits.put("ms", 1.0);
+ timeUnits.put("s", 1000.0);
+ }
+
+
+
/**
* Creates a new instance of this soft reference entry cache. All
* initialization should be performed in the <CODE>initializeEntryCache</CODE>
@@ -170,14 +188,14 @@
// Determine the lock timeout to use when interacting with the lock manager.
int msgID = MSGID_SOFTREFCACHE_DESCRIPTION_LOCK_TIMEOUT;
- IntegerConfigAttribute lockTimeoutStub =
- new IntegerConfigAttribute(ATTR_SOFTREFCACHE_LOCK_TIMEOUT,
- getMessage(msgID), true, false, false,
- true, 0, false, 0);
+ IntegerWithUnitConfigAttribute lockTimeoutStub =
+ new IntegerWithUnitConfigAttribute(ATTR_SOFTREFCACHE_LOCK_TIMEOUT,
+ getMessage(msgID), false, timeUnits,
+ true, 0, false, 0);
try
{
- IntegerConfigAttribute lockTimeoutAttr =
- (IntegerConfigAttribute)
+ IntegerWithUnitConfigAttribute lockTimeoutAttr =
+ (IntegerWithUnitConfigAttribute)
configEntry.getConfigAttribute(lockTimeoutStub);
if (lockTimeoutAttr == null)
{
@@ -185,7 +203,7 @@
}
else
{
- lockTimeout = lockTimeoutAttr.activeValue();
+ lockTimeout = lockTimeoutAttr.activeCalculatedValue();
}
}
catch (Exception e)
@@ -1054,10 +1072,11 @@
int msgID = MSGID_SOFTREFCACHE_DESCRIPTION_LOCK_TIMEOUT;
- IntegerConfigAttribute lockTimeoutAttr =
- new IntegerConfigAttribute(ATTR_SOFTREFCACHE_LOCK_TIMEOUT,
- getMessage(msgID), true, false, false,
- true, 0, false, 0, lockTimeout);
+ IntegerWithUnitConfigAttribute lockTimeoutAttr =
+ new IntegerWithUnitConfigAttribute(ATTR_SOFTREFCACHE_LOCK_TIMEOUT,
+ getMessage(msgID), false, timeUnits,
+ true, 0, false, 0, lockTimeout,
+ "ms");
attrList.add(lockTimeoutAttr);
@@ -1121,14 +1140,14 @@
// Determine the lock timeout to use when interacting with the lock manager.
int msgID = MSGID_SOFTREFCACHE_DESCRIPTION_LOCK_TIMEOUT;
- IntegerConfigAttribute lockTimeoutStub =
- new IntegerConfigAttribute(ATTR_SOFTREFCACHE_LOCK_TIMEOUT,
- getMessage(msgID), true, false, false,
- true, 0, false, 0);
+ IntegerWithUnitConfigAttribute lockTimeoutStub =
+ new IntegerWithUnitConfigAttribute(ATTR_SOFTREFCACHE_LOCK_TIMEOUT,
+ getMessage(msgID), false, timeUnits,
+ true, 0, false, 0);
try
{
- IntegerConfigAttribute lockTimeoutAttr =
- (IntegerConfigAttribute)
+ IntegerWithUnitConfigAttribute lockTimeoutAttr =
+ (IntegerWithUnitConfigAttribute)
configEntry.getConfigAttribute(lockTimeoutStub);
}
catch (Exception e)
@@ -1296,18 +1315,18 @@
// Determine the lock timeout to use when interacting with the lock manager.
long newLockTimeout = LockManager.DEFAULT_TIMEOUT;
int msgID = MSGID_SOFTREFCACHE_DESCRIPTION_LOCK_TIMEOUT;
- IntegerConfigAttribute lockTimeoutStub =
- new IntegerConfigAttribute(ATTR_SOFTREFCACHE_LOCK_TIMEOUT,
- getMessage(msgID), true, false, false,
- true, 0, false, 0);
+ IntegerWithUnitConfigAttribute lockTimeoutStub =
+ new IntegerWithUnitConfigAttribute(ATTR_SOFTREFCACHE_LOCK_TIMEOUT,
+ getMessage(msgID), false, timeUnits,
+ true, 0, false, 0);
try
{
- IntegerConfigAttribute lockTimeoutAttr =
- (IntegerConfigAttribute)
+ IntegerWithUnitConfigAttribute lockTimeoutAttr =
+ (IntegerWithUnitConfigAttribute)
configEntry.getConfigAttribute(lockTimeoutStub);
if (lockTimeoutAttr != null)
{
- newLockTimeout = lockTimeoutAttr.pendingValue();
+ newLockTimeout = lockTimeoutAttr.pendingCalculatedValue();
}
}
catch (Exception e)
--
Gitblit v1.10.0