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/EntryCacheCommon.java | 48 +++++++++++++++++++++++++-----------------------
1 files changed, 25 insertions(+), 23 deletions(-)
diff --git a/opends/src/server/org/opends/server/extensions/EntryCacheCommon.java b/opends/src/server/org/opends/server/extensions/EntryCacheCommon.java
index eac3bbb..49edcdf 100644
--- a/opends/src/server/org/opends/server/extensions/EntryCacheCommon.java
+++ b/opends/src/server/org/opends/server/extensions/EntryCacheCommon.java
@@ -381,7 +381,7 @@
{
ArrayList<Attribute> attrs = new ArrayList<Attribute>();
- if ((cacheHits != null) && (cacheMisses != null)) {
+ if (cacheHits != null) {
AttributeType hitsAttrType =
DirectoryServer.getDefaultAttributeType("entryCacheHits");
LinkedHashSet<AttributeValue> hitsValues =
@@ -390,29 +390,31 @@
cacheHits.toString()));
attrs.add(new Attribute(hitsAttrType, "entryCacheHits",
hitsValues));
+ // Cache misses is required to get cache tries and hit ratio.
+ if (cacheMisses != null) {
+ AttributeType triesAttrType =
+ DirectoryServer.getDefaultAttributeType("entryCacheTries");
+ LinkedHashSet<AttributeValue> triesValues =
+ new LinkedHashSet<AttributeValue>();
+ Long cacheTries = cacheHits + cacheMisses;
+ triesValues.add(new AttributeValue(triesAttrType,
+ cacheTries.toString()));
+ attrs.add(new Attribute(triesAttrType, "entryCacheTries",
+ triesValues));
- AttributeType triesAttrType =
- DirectoryServer.getDefaultAttributeType("entryCacheTries");
- LinkedHashSet<AttributeValue> triesValues =
- new LinkedHashSet<AttributeValue>();
- Long cacheTries = cacheHits + cacheMisses;
- triesValues.add(new AttributeValue(triesAttrType,
- cacheTries.toString()));
- attrs.add(new Attribute(triesAttrType, "entryCacheTries",
- triesValues));
-
- AttributeType hitRatioAttrType =
- DirectoryServer.getDefaultAttributeType("entryCacheHitRatio");
- LinkedHashSet<AttributeValue> hitRatioValues =
- new LinkedHashSet<AttributeValue>();
- Double hitRatioRaw = cacheTries > 0 ?
- cacheHits.doubleValue() / cacheTries.doubleValue() :
- cacheHits.doubleValue() / 1;
- Double hitRatio = hitRatioRaw * 100D;
- hitRatioValues.add(new AttributeValue(hitRatioAttrType,
- Long.toString(hitRatio.longValue())));
- attrs.add(new Attribute(hitRatioAttrType, "entryCacheHitRatio",
- hitRatioValues));
+ AttributeType hitRatioAttrType =
+ DirectoryServer.getDefaultAttributeType("entryCacheHitRatio");
+ LinkedHashSet<AttributeValue> hitRatioValues =
+ new LinkedHashSet<AttributeValue>();
+ Double hitRatioRaw = cacheTries > 0 ?
+ cacheHits.doubleValue() / cacheTries.doubleValue() :
+ cacheHits.doubleValue() / 1;
+ Double hitRatio = hitRatioRaw * 100D;
+ hitRatioValues.add(new AttributeValue(hitRatioAttrType,
+ Long.toString(hitRatio.longValue())));
+ attrs.add(new Attribute(hitRatioAttrType, "entryCacheHitRatio",
+ hitRatioValues));
+ }
}
if (cacheSize != null) {
--
Gitblit v1.10.0