From a79aa3ddbd25b8c7c0abc6c8d5a00c7ed27dd81d Mon Sep 17 00:00:00 2001
From: abobrov <abobrov@localhost>
Date: Sun, 02 Dec 2007 17:54:15 +0000
Subject: [PATCH] - [Issue 2007] generic mechanism for using mulitple caches. - [Issue 2049] dsconfig is unable to configure the entry cache.
---
opends/src/server/org/opends/server/extensions/SoftReferenceEntryCache.java | 36 +++++++++++++++++++++---------------
1 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/opends/src/server/org/opends/server/extensions/SoftReferenceEntryCache.java b/opends/src/server/org/opends/server/extensions/SoftReferenceEntryCache.java
index f35c776..209b180 100644
--- a/opends/src/server/org/opends/server/extensions/SoftReferenceEntryCache.java
+++ b/opends/src/server/org/opends/server/extensions/SoftReferenceEntryCache.java
@@ -195,6 +195,10 @@
*/
public boolean containsEntry(DN entryDN)
{
+ if (entryDN == null) {
+ return false;
+ }
+
// Indicate whether the DN map contains the specified DN.
return dnMap.containsKey(entryDN);
}
@@ -210,7 +214,7 @@
if (ref == null)
{
// Indicate cache miss.
- cacheMisses.set(cacheMisses.incrementAndGet());
+ cacheMisses.getAndIncrement();
return null;
}
else
@@ -219,13 +223,13 @@
if (cacheEntry == null)
{
// Indicate cache miss.
- cacheMisses.set(cacheMisses.incrementAndGet());
+ cacheMisses.getAndIncrement();
return null;
}
else
{
// Indicate cache hit.
- cacheHits.set(cacheHits.incrementAndGet());
+ cacheHits.getAndIncrement();
return cacheEntry.getEntry();
}
}
@@ -262,7 +266,7 @@
/**
* {@inheritDoc}
*/
- protected DN getEntryDN(Backend backend, long entryID)
+ public DN getEntryDN(Backend backend, long entryID)
{
// Locate specific backend map and return the entry DN by ID.
ConcurrentHashMap<Long,SoftReference<CacheEntry>>
@@ -286,11 +290,6 @@
*/
public void putEntry(Entry entry, Backend backend, long entryID)
{
- // Check exclude and include filters first.
- if (!filtersAllowCaching(entry)) {
- return;
- }
-
// Create the cache entry based on the provided information.
CacheEntry cacheEntry = new CacheEntry(entry, backend, entryID);
SoftReference<CacheEntry> ref =
@@ -327,11 +326,6 @@
public boolean putEntryIfAbsent(Entry entry, Backend backend,
long entryID)
{
- // Check exclude and include filters first.
- if (!filtersAllowCaching(entry)) {
- return true;
- }
-
// See if the entry already exists. If so, then return false.
if (dnMap.containsKey(entry.getDN()))
{
@@ -667,7 +661,9 @@
try {
attrs = EntryCacheCommon.getGenericMonitorData(
new Long(cacheHits.longValue()),
- new Long(cacheMisses.longValue()),
+ // If cache misses is maintained by default cache
+ // get it from there and if not point to itself.
+ DirectoryServer.getEntryCache().getCacheMisses(),
null,
null,
new Long(dnMap.size()),
@@ -685,6 +681,16 @@
/**
+ * {@inheritDoc}
+ */
+ public Long getCacheCount()
+ {
+ return new Long(dnMap.size());
+ }
+
+
+
+ /**
* Return a verbose string representation of the current cache maps.
* This is useful primary for debugging and diagnostic purposes such
* as in the entry cache unit tests.
--
Gitblit v1.10.0