From a9b73c46ed8c7eb9106027beb4fcbf8f192a7118 Mon Sep 17 00:00:00 2001
From: abobrov <abobrov@localhost>
Date: Tue, 04 Sep 2007 16:01:28 +0000
Subject: [PATCH] entry cache cleanup: - remove obsolete methods, fields and messages. - aggregate filters evaluation for config phases. - simplify filters evaluation and error reporting. - use a single set of filter messages.
---
opendj-sdk/opends/src/server/org/opends/server/extensions/FIFOEntryCache.java | 133 +-------------------------------------------
1 files changed, 4 insertions(+), 129 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/extensions/FIFOEntryCache.java b/opendj-sdk/opends/src/server/org/opends/server/extensions/FIFOEntryCache.java
index dd9cd90..aff52ec 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/extensions/FIFOEntryCache.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/extensions/FIFOEntryCache.java
@@ -36,7 +36,6 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@@ -55,7 +54,6 @@
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.InitializationException;
-import org.opends.server.types.ResultCode;
import org.opends.server.types.SearchFilter;
import org.opends.server.util.ServerConstants;
import org.opends.messages.MessageBuilder;
@@ -100,34 +98,15 @@
*/
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 reference to the Java runtime used to determine the amount of memory
* currently in use.
*/
private static final Runtime runtime = Runtime.getRuntime();
-
-
- // The DN of the configuration entry for this entry cache.
- private DN configEntryDN;
-
// The mapping between entry backends/IDs and entries.
private HashMap<Backend,HashMap<Long,CacheEntry>> idMap;
- // The maximum percentage of JVM memory that should be used by the cache.
- private int maxMemoryPercent;
-
// The mapping between DNs and entries.
private LinkedHashMap<DN,CacheEntry> dnMap;
@@ -147,16 +126,6 @@
- static
- {
- timeUnits.put(TIME_UNIT_MILLISECONDS_ABBR, 1D);
- timeUnits.put(TIME_UNIT_MILLISECONDS_FULL, 1D);
- timeUnits.put(TIME_UNIT_SECONDS_ABBR, 1000D);
- timeUnits.put(TIME_UNIT_SECONDS_FULL, 1000D);
- }
-
-
-
/**
* Creates a new instance of this FIFO entry cache.
*/
@@ -180,7 +149,6 @@
{
registeredConfiguration = configuration;
configuration.addFIFOChangeListener (this);
- configEntryDN = configuration.dn();
// Initialize the cache structures.
idMap = new HashMap<Backend,HashMap<Long,CacheEntry>>();
@@ -949,80 +917,6 @@
/**
- * Makes a best-effort attempt to apply the configuration contained in the
- * provided entry. Information about the result of this processing should be
- * added to the provided message list. Information should always be added to
- * this list if a configuration change could not be applied. If detailed
- * results are requested, then information about the changes applied
- * successfully (and optionally about parameters that were not changed) should
- * also be included.
- *
- * @param configuration The entry containing the new configuration to
- * apply for this component.
- * @param detailedResults Indicates whether detailed information about the
- * processing should be added to the list.
- *
- * @return Information about the result of the configuration update.
- */
- public ConfigChangeResult applyNewConfiguration(
- FIFOEntryCacheCfg configuration,
- boolean detailedResults
- )
- {
- // Store the current value to detect changes.
- long prevLockTimeout = getLockTimeout();
- long prevMaxEntries = maxEntries;
- int prevMaxMemoryPercent = maxMemoryPercent;
- Set<SearchFilter> prevIncludeFilters = getIncludeFilters();
- Set<SearchFilter> prevExcludeFilters = getExcludeFilters();
-
- // Activate the new configuration.
- ConfigChangeResult changeResult = applyConfigurationChange(configuration);
-
- // Add detailed messages if needed.
- ResultCode resultCode = changeResult.getResultCode();
- boolean configIsAcceptable = (resultCode == ResultCode.SUCCESS);
- if (detailedResults && configIsAcceptable)
- {
- if (maxMemoryPercent != prevMaxMemoryPercent)
- {
- changeResult.addMessage(
- INFO_FIFOCACHE_UPDATED_MAX_MEMORY_PCT.get(maxMemoryPercent,
- maxAllowedMemory));
- }
-
-
- if (maxEntries != prevMaxEntries)
- {
- changeResult.addMessage(
- INFO_FIFOCACHE_UPDATED_MAX_ENTRIES.get(maxEntries));
- }
-
- if (getLockTimeout() != prevLockTimeout)
- {
- changeResult.addMessage(
- INFO_FIFOCACHE_UPDATED_LOCK_TIMEOUT.get(getLockTimeout()));
- }
-
- if (!getIncludeFilters().equals(prevIncludeFilters))
- {
- changeResult.addMessage(
- INFO_FIFOCACHE_UPDATED_INCLUDE_FILTERS.get());
- }
-
- if (!getExcludeFilters().equals(prevExcludeFilters))
- {
- changeResult.addMessage(
- INFO_FIFOCACHE_UPDATED_EXCLUDE_FILTERS.get());
- }
- }
-
- return changeResult;
- }
-
-
-
- /**
* Parses the provided configuration and configure the entry cache.
*
* @param configuration The new configuration containing the changes.
@@ -1061,34 +955,17 @@
switch (errorHandler.getConfigPhase())
{
case PHASE_INIT:
+ case PHASE_ACCEPTABLE:
+ case PHASE_APPLY:
newIncludeFilters = EntryCacheCommon.getFilters (
configuration.getIncludeFilter(),
- ERR_FIFOCACHE_INVALID_INCLUDE_FILTER,
- WARN_FIFOCACHE_CANNOT_DECODE_ANY_INCLUDE_FILTERS,
+ ERR_CACHE_INVALID_INCLUDE_FILTER,
errorHandler,
newConfigEntryDN
);
newExcludeFilters = EntryCacheCommon.getFilters (
configuration.getExcludeFilter(),
- WARN_FIFOCACHE_CANNOT_DECODE_EXCLUDE_FILTER,
- WARN_FIFOCACHE_CANNOT_DECODE_ANY_EXCLUDE_FILTERS,
- errorHandler,
- newConfigEntryDN
- );
- break;
- case PHASE_ACCEPTABLE: // acceptable and apply are using the same
- case PHASE_APPLY: // error ID codes
- newIncludeFilters = EntryCacheCommon.getFilters (
- configuration.getIncludeFilter(),
- ERR_FIFOCACHE_INVALID_INCLUDE_FILTER,
- null,
- errorHandler,
- newConfigEntryDN
- );
- newExcludeFilters = EntryCacheCommon.getFilters (
- configuration.getExcludeFilter(),
- ERR_FIFOCACHE_INVALID_EXCLUDE_FILTER,
- null,
+ ERR_CACHE_INVALID_EXCLUDE_FILTER,
errorHandler,
newConfigEntryDN
);
@@ -1097,9 +974,7 @@
if (applyChanges && errorHandler.getIsAcceptable())
{
- configEntryDN = newConfigEntryDN;
maxEntries = newMaxEntries;
- maxMemoryPercent = newMaxMemoryPercent;
maxAllowedMemory = newMaxAllowedMemory;
setLockTimeout(newLockTimeout);
--
Gitblit v1.10.0