mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

abobrov
03.29.2007 25d7ae2bbef02d6ebb5ca9e88f016147ebfc34bf
- make default entry cache BackendInitializationListener so it can handle backend init/fini processing relevant to entry cache for all
active entry cache implementations instead of letting each entry cache implementation to be BackendInitializationListener on its
own which can lead to unexpected results such as listener activity on already finilized entry cache implementation.
2 files modified
83 ■■■■ changed files
opendj-sdk/opends/src/server/org/opends/server/api/EntryCache.java 40 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/server/org/opends/server/extensions/DefaultEntryCache.java 43 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/server/org/opends/server/api/EntryCache.java
@@ -36,7 +36,6 @@
import java.util.concurrent.locks.Lock;
import java.util.concurrent.atomic.AtomicLong;
import org.opends.server.core.DirectoryServer;
import org.opends.server.config.ConfigException;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
@@ -86,7 +85,6 @@
     notes="Entry cache methods may only be invoked by backends")
public abstract class EntryCache
       <T extends EntryCacheCfg>
       implements BackendInitializationListener
{
  /**
   * The tracer object for the debug logger.
@@ -127,9 +125,7 @@
   */
  public EntryCache()
  {
    // Register with backend initialization listener to clear cache
    // entries belonging to given backend that about to go offline.
    DirectoryServer.registerBackendInitializationListener(this);
    // No implementation required.
  }
@@ -793,38 +789,4 @@
    return true;
  }
  /**
   * Performs any processing that may be required whenever a backend
   * is initialized for use in the Directory Server.  This method will
   * be invoked after the backend has been initialized but before it
   * has been put into service.
   *
   * @param  backend  The backend that has been initialized and is
   *                  about to be put into service.
   */
  public void performBackendInitializationProcessing(Backend backend)
  {
    // Do nothing.
  }
  /**
   * Performs any processing that may be required whenever a backend
   * is finalized.  This method will be invoked after the backend has
   * been taken out of service but before it has been finalized.
   *
   * @param  backend  The backend that has been taken out of service
   *                  and is about to be finalized.
   */
  public void performBackendFinalizationProcessing(Backend backend)
  {
    // Do not clear any backends if the server is shutting down.
    if ( !(DirectoryServer.getInstance().isShuttingDown()) ) {
      clearBackend(backend);
    }
  }
}
opendj-sdk/opends/src/server/org/opends/server/extensions/DefaultEntryCache.java
@@ -38,8 +38,10 @@
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.EntryCacheCfg;
import org.opends.server.api.Backend;
import org.opends.server.api.BackendInitializationListener;
import org.opends.server.api.EntryCache;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.types.Attribute;
import org.opends.server.types.ConfigChangeResult;
@@ -62,7 +64,8 @@
 */
public class DefaultEntryCache
       extends EntryCache<EntryCacheCfg>
       implements ConfigurationChangeListener<EntryCacheCfg>
       implements ConfigurationChangeListener<EntryCacheCfg>,
       BackendInitializationListener
{
  /**
   * The tracer object for the debug logger.
@@ -82,6 +85,10 @@
  public DefaultEntryCache()
  {
    super();
    // Register with backend initialization listener to clear cache
    // entries belonging to given backend that about to go offline.
    DirectoryServer.registerBackendInitializationListener(this);
  }
@@ -491,5 +498,39 @@
    this.cacheOrder =
      cacheOrderMap.values().toArray(new EntryCache<?>[0]);
  }
  /**
   * Performs any processing that may be required whenever a backend
   * is initialized for use in the Directory Server.  This method will
   * be invoked after the backend has been initialized but before it
   * has been put into service.
   *
   * @param  backend  The backend that has been initialized and is
   *                  about to be put into service.
   */
  public void performBackendInitializationProcessing(Backend backend)
  {
    // Do nothing.
  }
  /**
   * Performs any processing that may be required whenever a backend
   * is finalized.  This method will be invoked after the backend has
   * been taken out of service but before it has been finalized.
   *
   * @param  backend  The backend that has been taken out of service
   *                  and is about to be finalized.
   */
  public void performBackendFinalizationProcessing(Backend backend)
  {
    // Do not clear any backends if the server is shutting down.
    if ( !(DirectoryServer.getInstance().isShuttingDown()) ) {
      clearBackend(backend);
    }
  }
}