From 4166c20ed1817f2792c6c4a6d12b810c7c256b72 Mon Sep 17 00:00:00 2001
From: abobrov <abobrov@localhost>
Date: Sun, 09 Sep 2007 14:48:37 +0000
Subject: [PATCH] - [Issue 1594] entry caches should have monitor information: implement generic entry cache monitor provider which allows any entry cache implementation current or future to provide a common or custom set of entry cache state data. update all existing entry cache implementations so that they provide their common state data to the entry cache monitor provider.
---
opends/src/server/org/opends/server/api/EntryCache.java | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/opends/src/server/org/opends/server/api/EntryCache.java b/opends/src/server/org/opends/server/api/EntryCache.java
index 09c7d0c..75dae36 100644
--- a/opends/src/server/org/opends/server/api/EntryCache.java
+++ b/opends/src/server/org/opends/server/api/EntryCache.java
@@ -33,6 +33,8 @@
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.locks.Lock;
+import java.util.ArrayList;
+import java.util.concurrent.atomic.AtomicLong;
import org.opends.server.core.DirectoryServer;
import org.opends.server.config.ConfigException;
@@ -43,6 +45,7 @@
import org.opends.server.types.LockManager;
import org.opends.server.types.SearchFilter;
import org.opends.server.types.DebugLogLevel;
+import org.opends.server.types.Attribute;
import org.opends.server.admin.std.server.EntryCacheCfg;
import org.opends.server.loggers.debug.DebugTracer;
import static org.opends.server.loggers.debug.DebugLogger.*;
@@ -105,6 +108,16 @@
// up.
private long lockTimeout = LockManager.DEFAULT_TIMEOUT;
+ /**
+ * Arbitrary number of cache hits for monitoring.
+ */
+ protected AtomicLong cacheHits = new AtomicLong(0);
+
+ /**
+ * Arbitrary number of cache misses for monitoring.
+ */
+ protected AtomicLong cacheMisses = new AtomicLong(0);
+
/**
@@ -239,6 +252,9 @@
List<Lock> lockList) {
if (!containsEntry(entryDN)) {
+ // Indicate cache miss.
+ cacheMisses.set(cacheMisses.incrementAndGet());
+
return null;
}
@@ -391,6 +407,9 @@
// Translate given backend/entryID pair to entryDN.
DN entryDN = getEntryDN(backend, entryID);
if (entryDN == null) {
+ // Indicate cache miss.
+ cacheMisses.set(cacheMisses.incrementAndGet());
+
return null;
}
@@ -526,6 +545,19 @@
/**
+ * Retrieves a set of attributes containing monitor data that should
+ * be returned to the client if the corresponding monitor entry is
+ * requested.
+ *
+ * @return A set of attributes containing monitor data that should
+ * be returned to the client if the corresponding monitor
+ * entry is requested.
+ */
+ public abstract ArrayList<Attribute> getMonitorData();
+
+
+
+ /**
* Retrieves the maximum length of time in milliseconds to wait for
* a lock before giving up.
*
--
Gitblit v1.10.0