From 0ce8111bcd7c23226fa1fe7469baae9b1840eae4 Mon Sep 17 00:00:00 2001
From: abobrov <abobrov@localhost>
Date: Sun, 19 Aug 2007 23:28:49 +0000
Subject: [PATCH] - implement new toVerboseString() method. - fix bugs found by entry cache unit tests. - sanitize backend map maintenance.
---
opends/src/server/org/opends/server/extensions/SoftReferenceEntryCache.java | 37 ++++++++++++++++++++++++++++++++++++-
1 files changed, 36 insertions(+), 1 deletions(-)
diff --git a/opends/src/server/org/opends/server/extensions/SoftReferenceEntryCache.java b/opends/src/server/org/opends/server/extensions/SoftReferenceEntryCache.java
index 85f9f34..1cf9825 100644
--- a/opends/src/server/org/opends/server/extensions/SoftReferenceEntryCache.java
+++ b/opends/src/server/org/opends/server/extensions/SoftReferenceEntryCache.java
@@ -282,6 +282,7 @@
{
map = new ConcurrentHashMap<Long,SoftReference<CacheEntry>>();
map.put(entryID, ref);
+ idMap.put(backend, map);
}
else
{
@@ -361,6 +362,12 @@
{
ref.clear();
}
+ // If this backend becomes empty now remove
+ // it from the idMap map.
+ if (map.isEmpty())
+ {
+ idMap.remove(backend);
+ }
}
}
}
@@ -441,6 +448,28 @@
/**
* {@inheritDoc}
*/
+ public String toVerboseString()
+ {
+ String verboseString = new String();
+
+ // There're no locks in this cache to keep dnMap and idMap in
+ // sync. Examine dnMap only since its more likely to be up to
+ // date than idMap. Dont bother with copies either since this
+ // is SoftReference based implementation.
+ for(SoftReference<CacheEntry> ce : dnMap.values()) {
+ verboseString = verboseString + ce.get().getDN().toString() +
+ ":" + Long.toString(ce.get().getEntryID()) + ":" +
+ ce.get().getBackend().getBackendID() + "\n";
+ }
+
+ return (verboseString.length() > 0 ? verboseString : null);
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
@Override()
public boolean isConfigurationAcceptable(EntryCacheCfg configuration,
List<Message> unacceptableReasons)
@@ -611,8 +640,9 @@
{
ref.clear();
+ Backend backend = freedEntry.getBackend();
ConcurrentHashMap<Long,SoftReference<CacheEntry>> map =
- idMap.get(freedEntry.getBackend());
+ idMap.get(backend);
if (map != null)
{
ref = map.remove(freedEntry.getEntryID());
@@ -620,6 +650,11 @@
{
ref.clear();
}
+ // If this backend becomes empty now remove
+ // it from the idMap map.
+ if (map.isEmpty()) {
+ idMap.remove(backend);
+ }
}
}
}
--
Gitblit v1.10.0