From 16decf0b35cb59c97f4d6c1c3b5d5b3ee5f74a27 Mon Sep 17 00:00:00 2001
From: abobrov <abobrov@localhost>
Date: Wed, 04 Jul 2007 13:50:07 +0000
Subject: [PATCH] - replace private JE API with newly provided [since JE 3.2.28] public API to determine approx env size. - remove fields that are no longer used.  

---
 opendj-sdk/opends/src/server/org/opends/server/extensions/FileSystemEntryCache.java |   46 +++++++++++++---------------------------------
 1 files changed, 13 insertions(+), 33 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/extensions/FileSystemEntryCache.java b/opendj-sdk/opends/src/server/org/opends/server/extensions/FileSystemEntryCache.java
index abc6f8e..c01b473 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/extensions/FileSystemEntryCache.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/extensions/FileSystemEntryCache.java
@@ -28,19 +28,17 @@
 
 import java.util.ArrayList;
 import java.util.HashSet;
-import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
-import java.util.concurrent.locks.Lock;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.util.SortedMap;
+import java.util.concurrent.atomic.AtomicLong;
 import java.util.Timer;
 import java.util.TimerTask;
-import java.util.concurrent.atomic.AtomicLong;
 import java.io.File;
 import com.sleepycat.bind.EntryBinding;
 import com.sleepycat.bind.serial.SerialBinding;
@@ -52,11 +50,9 @@
 import com.sleepycat.je.DatabaseConfig;
 import com.sleepycat.je.DatabaseEntry;
 import com.sleepycat.je.DatabaseNotFoundException;
-import com.sleepycat.je.DbInternal;
 import com.sleepycat.je.LockMode;
 import com.sleepycat.je.OperationStatus;
-import com.sleepycat.je.cleaner.UtilizationProfile;
-import com.sleepycat.je.dbi.EnvironmentImpl;
+import com.sleepycat.je.StatsConfig;
 import org.opends.server.api.Backend;
 import org.opends.server.api.EntryCache;
 import org.opends.server.admin.std.server.FileSystemEntryCacheCfg;
@@ -122,20 +118,6 @@
    */
   private static final DebugTracer TRACER = getTracer();
 
-  /**
-   * The set of time units that will be used for expressing the task retention
-   * time.
-   */
-  private static final LinkedHashMap<String, Double> timeUnits =
-          new LinkedHashMap<String, Double>();
-
-  /**
-    * The set of units and their multipliers for configuration attributes
-    * representing a number of bytes.
-    */
-  private static HashMap<String, Double> memoryUnits =
-      new HashMap<String, Double>();
-
   // Permissions for cache db environment.
   private static final FilePermission CACHE_HOME_PERMISSIONS =
       new FilePermission(0700);
@@ -205,6 +187,9 @@
   private EnvironmentMutableConfig entryCacheEnvMutableConfig;
   private DatabaseConfig entryCacheDBConfig;
 
+  // Statistics retrieval operation config for this JE environment.
+  private StatsConfig entryCacheEnvStatsConfig = new StatsConfig();
+
   // The main entry cache database.
   private Database entryCacheDB;
 
@@ -381,6 +366,10 @@
       entryCacheDBConfig = new DatabaseConfig();
       entryCacheDBConfig.setAllowCreate(true);
 
+      // Configure the JE environment statistics to return only
+      // the values which do not incur some performance penalty.
+      entryCacheEnvStatsConfig.setFast(true);
+
       // Remove old cache databases if this cache is not persistent.
       if ( !persistentCache ) {
         try {
@@ -1715,18 +1704,9 @@
 
       // Zero means unlimited here.
       if (maxAllowedMemory != 0) {
-        // TODO: This should be done using JE public API
-        // EnvironmentStats.getTotalLogSize() when JE 3.2.28 is available.
-        EnvironmentImpl envImpl =
-              DbInternal.envGetEnvironmentImpl(entryCacheEnv);
-        UtilizationProfile utilProfile = envImpl.getUtilizationProfile();
-        SortedMap map = utilProfile.getFileSummaryMap(false);
-
-        // This calculation is not exactly precise as the last JE logfile
-        // will always be less than JELOGFILEMAX however in the interest
-        // of performance and the fact that JE environment is always a
-        // moving target we will allow for that margin of error here.
-        usedMemory = map.size() * JELOGFILEMAX.longValue();
+        // Get approximate current total log size of JE environment in bytes.
+        usedMemory =
+            entryCacheEnv.getStats(entryCacheEnvStatsConfig).getTotalLogSize();
 
         // TODO: Check and log a warning if usedMemory hits default or
         // configurable watermark, see Issue 1735.

--
Gitblit v1.10.0