From 0d818965b1f323bbada0b837d387c243b98373d6 Mon Sep 17 00:00:00 2001
From: dugan <dugan@localhost>
Date: Thu, 19 Oct 2006 16:17:53 +0000
Subject: [PATCH] Add support for collecting verifyBackend statistics such as error-count and key-count in an Entry class, so calling methods can access to that information.

---
 opendj-sdk/opends/src/server/org/opends/server/backends/jeb/VerifyJob.java |   33 +++++++++++++++++++++++++++++++--
 1 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/VerifyJob.java b/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/VerifyJob.java
index f9bbe75..05e72a2 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/VerifyJob.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/VerifyJob.java
@@ -201,10 +201,11 @@
    * Verify the backend.
    *
    * @param rootContainer The root container that holds the entries to verify.
+   * @param statEntry Optional statistics entry.
    * @throws DatabaseException If an error occurs in the JE database.
    * @throws JebException If an error occurs in the JE backend.
    */
-  public void verifyBackend(RootContainer rootContainer) throws
+  public void verifyBackend(RootContainer rootContainer, Entry statEntry) throws
       DatabaseException, JebException
   {
 
@@ -325,6 +326,10 @@
       rate = 1000f*keyCount / totalTime;
     }
 
+    addStatEntry(statEntry, "verify-error-count",
+              String.valueOf(errorCount));
+    addStatEntry(statEntry, "verify-key-count",
+              String.valueOf(keyCount));
     if (cleanMode)
     {
       int msgID = MSGID_JEB_VERIFY_CLEAN_FINAL_STATUS;
@@ -345,21 +350,29 @@
         message = getMessage(msgID, multiReferenceCount);
         logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.NOTICE,
                  message, msgID);
+        addStatEntry(statEntry, "verify-multiple-reference-count",
+                String.valueOf(multiReferenceCount));
 
         msgID = MSGID_JEB_VERIFY_ENTRY_LIMIT_EXCEEDED_COUNT;
         message = getMessage(msgID, entryLimitExceededCount);
         logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.NOTICE,
                  message, msgID);
+        addStatEntry(statEntry, "verify-entry-limit-exceeded-count",
+                String.valueOf(entryLimitExceededCount));
 
         msgID = MSGID_JEB_VERIFY_AVERAGE_REFERENCE_COUNT;
         message = getMessage(msgID, averageEntryReferences);
         logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.NOTICE,
                  message, msgID);
+        addStatEntry(statEntry, "verify-average-reference-count",
+                String.valueOf(averageEntryReferences));
 
         msgID = MSGID_JEB_VERIFY_MAX_REFERENCE_COUNT;
         message = getMessage(msgID, maxEntryPerValue);
         logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.NOTICE,
                  message, msgID);
+        addStatEntry(statEntry, "verify-max-reference-count",
+                   String.valueOf(maxEntryPerValue));
       }
     }
     else
@@ -369,7 +382,7 @@
                                   totalTime/1000, rate);
       logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.NOTICE,
                message, msgID);
-
+      //TODO add entry-limit-stats to the statEntry
       if (entryLimitMap.size() > 0)
       {
         msgID = MSGID_JEB_VERIFY_ENTRY_LIMIT_STATS_HEADER;
@@ -1601,4 +1614,20 @@
       previousTime = latestTime;
     }
   }
+
+    /**
+     * Adds an attribute of type t and value v to the statEntry, only if the
+     * statEntry is not null.
+     * @param statEntry passed in from backentryImpl.verifyBackend.
+     * @param t String to be used as the attribute type.
+     * @param v String to be used as the attribute value.
+     */
+    private void addStatEntry(Entry statEntry, String t, String v)
+    {
+        if (statEntry != null)
+        {
+            Attribute a = new Attribute(t, v);
+            statEntry.addAttribute(a, null);
+        }
+    }
 }

--
Gitblit v1.10.0