From 1f09540bc620a96d353c892d51ace2a35d07627b Mon Sep 17 00:00:00 2001
From: abobrov <abobrov@localhost>
Date: Fri, 01 Feb 2008 01:13:11 +0000
Subject: [PATCH] - [Issue 2772] Report preload status   Log database cache preload status, progress and completion reports.

---
 opendj-sdk/opends/src/messages/messages/jeb.properties                         |   14 +++++++
 opendj-sdk/opends/src/server/org/opends/server/backends/jeb/RootContainer.java |   47 +++++++++++++++++++++--
 2 files changed, 57 insertions(+), 4 deletions(-)

diff --git a/opendj-sdk/opends/src/messages/messages/jeb.properties b/opendj-sdk/opends/src/messages/messages/jeb.properties
index 3deac18..fd19063 100644
--- a/opendj-sdk/opends/src/messages/messages/jeb.properties
+++ b/opendj-sdk/opends/src/messages/messages/jeb.properties
@@ -130,8 +130,22 @@
  because an entry with that name already exists
 MILD_ERR_JEB_NEW_SUPERIOR_NO_SUCH_OBJECT_54=The entry cannot be moved because \
  the new parent entry '%s' does not exist
+NOTICE_JEB_CACHE_PRELOAD_STARTED_55=The database cache preload for backend %s \
+ has started
+NOTICE_JEB_CACHE_DB_PRELOADED_56=The database cache preload for database %s \
+ is complete
+NOTICE_JEB_CACHE_PRELOAD_INTERRUPTED_BY_TIME_57=The database cache preload for \
+ backend %s has been interrupted while preloading database %s due to time limit
+NOTICE_JEB_CACHE_PRELOAD_INTERRUPTED_BY_SIZE_58=The database cache preload for \
+ backend %s has been interrupted while preloading database %s due to size limit
+NOTICE_JEB_CACHE_PRELOAD_INTERRUPTED_UNKNOWN_59=The database cache preload for \
+ backend %s has been interrupted while preloading database %s
+NOTICE_JEB_CACHE_PRELOAD_DONE_60=The database cache preload for backend %s \
+ is complete
 NOTICE_JEB_CACHE_SIZE_AFTER_PRELOAD_61=The database cache is %d MB after \
  pre-loading
+SEVERE_ERR_JEB_CACHE_PRELOAD_62=An error occurred while preloading the \
+ database cache for backend %s:  %s
 SEVERE_ERR_JEB_BACKUP_CANNOT_GET_MAC_63=An error occurred while attempting to \
  obtain the %s MAC provider to create the signed hash for the backup:  %s
 SEVERE_ERR_JEB_BACKUP_CANNOT_GET_DIGEST_64=An error occurred while attempting \
diff --git a/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/RootContainer.java b/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/RootContainer.java
index c7489f3..bd539f5 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/RootContainer.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/RootContainer.java
@@ -402,12 +402,18 @@
       // is filled.
       try
       {
-        long timeEnd = System.currentTimeMillis() + timeLimit;
-
         // Configure preload of Leaf Nodes (LNs) containing the data values.
         PreloadConfig preloadConfig = new PreloadConfig();
         preloadConfig.setLoadLNs(true);
 
+        Message message =
+            NOTE_JEB_CACHE_PRELOAD_STARTED.get(backend.getBackendID());
+        logError(message);
+
+        boolean isInterrupted = false;
+
+        long timeEnd = System.currentTimeMillis() + timeLimit;
+
         for (DatabaseContainer db : dbList)
         {
           // Calculate the remaining time.
@@ -427,17 +433,44 @@
           }
 
           // Stop if the cache is full or the time limit has been exceeded.
-          if (preloadStats.getStatus() != PreloadStatus.SUCCESS)
+          PreloadStatus preloadStatus = preloadStats.getStatus();
+          if (preloadStatus != PreloadStatus.SUCCESS)
           {
+            if (preloadStatus == PreloadStatus.EXCEEDED_TIME) {
+              message =
+                NOTE_JEB_CACHE_PRELOAD_INTERRUPTED_BY_TIME.get(
+                backend.getBackendID(), db.getName());
+              logError(message);
+            } else if (preloadStatus == PreloadStatus.FILLED_CACHE) {
+              message =
+                NOTE_JEB_CACHE_PRELOAD_INTERRUPTED_BY_SIZE.get(
+                backend.getBackendID(), db.getName());
+              logError(message);
+            } else {
+              message =
+                NOTE_JEB_CACHE_PRELOAD_INTERRUPTED_UNKNOWN.get(
+                backend.getBackendID(), db.getName());
+              logError(message);
+            }
+
+            isInterrupted = true;
             break;
           }
+
+          message = NOTE_JEB_CACHE_DB_PRELOADED.get(db.getName());
+          logError(message);
+        }
+
+        if (!isInterrupted) {
+          message = NOTE_JEB_CACHE_PRELOAD_DONE.get(backend.getBackendID());
+          logError(message);
         }
 
         // Log an informational message about the size of the cache.
         EnvironmentStats stats = env.getStats(new StatsConfig());
         long total = stats.getCacheTotalBytes();
 
-        Message message =
+        message =
             NOTE_JEB_CACHE_SIZE_AFTER_PRELOAD.get(total / (1024 * 1024));
         logError(message);
       }
@@ -447,6 +480,12 @@
         {
           TRACER.debugCaught(DebugLogLevel.ERROR, e);
         }
+
+        Message message =
+          ERR_JEB_CACHE_PRELOAD.get(backend.getBackendID(),
+          (e.getCause() != null ? e.getCause().getMessage() :
+            stackTraceToSingleLineString(e)));
+        logError(message);
       }
     }
   }

--
Gitblit v1.10.0