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/FileSystemEntryCache.java | 61 ++++++++++++++++++++++++++++++
1 files changed, 60 insertions(+), 1 deletions(-)
diff --git a/opends/src/server/org/opends/server/extensions/FileSystemEntryCache.java b/opends/src/server/org/opends/server/extensions/FileSystemEntryCache.java
index 75f38a8..816a658 100644
--- a/opends/src/server/org/opends/server/extensions/FileSystemEntryCache.java
+++ b/opends/src/server/org/opends/server/extensions/FileSystemEntryCache.java
@@ -662,7 +662,8 @@
Entry entry = null;
cacheReadLock.lock();
try {
- if (dnMap.containsKey(entryDN)) {
+ // Use get to generate entry access.
+ if (dnMap.get(entryDN) != null) {
entry = getEntryFromDB(entryDN);
}
} finally {
@@ -1017,6 +1018,64 @@
/**
* {@inheritDoc}
*/
+ public String toVerboseString()
+ {
+ String verboseString = new String();
+
+ Map<DN,Long> dnMapCopy;
+ Map<Backend,Map<Long,DN>> backendMapCopy;
+
+ // Grab write lock to prevent any modifications
+ // to the cache maps until a snapshot is taken.
+ cacheWriteLock.lock();
+ try {
+ // Examining the real maps will hold the lock
+ // and can cause map modifications in case of
+ // any access order maps, make copies instead.
+ dnMapCopy = new LinkedHashMap<DN,Long>(dnMap);
+ backendMapCopy =
+ new LinkedHashMap<Backend,Map<Long,DN>>
+ (backendMap);
+ } finally {
+ cacheWriteLock.unlock();
+ }
+
+ // Check dnMap first.
+ for (DN dn : dnMapCopy.keySet()) {
+ Backend backend = null;
+ Iterator<Backend> backendIterator = backendMapCopy.keySet().iterator();
+ while (backendIterator.hasNext()) {
+ backend = backendIterator.next();
+ Map<Long, DN> map = backendMapCopy.get(backend);
+ if ((map.get(dnMapCopy.get(dn)) != null) &&
+ (map.get(dnMapCopy.get(dn)).equals(dn))) {
+ break;
+ }
+ }
+ }
+
+ // See if there is anything on backendMap that isnt reflected on dnMap
+ // in case maps went out of sync.
+ Backend backend = null;
+ Iterator<Backend> backendIterator = backendMapCopy.keySet().iterator();
+ while (backendIterator.hasNext()) {
+ backend = backendIterator.next();
+ Map<Long, DN> map = backendMapCopy.get(backend);
+ for (Long id : map.keySet()) {
+ if (!dnMapCopy.containsKey(map.get(id)) || map.get(id) == null) {
+ verboseString = verboseString + (map.get(id) != null ?
+ map.get(id) : null) + ":" + id.toString() + ":" +
+ backend.getBackendID() + "\n";
+ }
+ }
+ }
+
+ return (verboseString.length() > 0 ? verboseString : null);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
@Override()
public boolean isConfigurationAcceptable(EntryCacheCfg configuration,
List<Message> unacceptableReasons)
--
Gitblit v1.10.0