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

Fabio Pistolesi
20.44.2015 54fbe518d8e0f66c95a8825209d6a176dcb323a1
Preparatory commit for OPENDJ-1727, propagating a serverContext to all backends and storages to access
informations about the current running environment.
Changes in API only.
24 files modified
111 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ReadOnlyConfigFileHandler.java 3 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/api/Backend.java 17 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/BackupBackend.java 3 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/ChangelogBackend.java 3 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/LDIFBackend.java 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/MemoryBackend.java 3 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/MonitorBackend.java 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/NullBackend.java 3 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java 6 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java 6 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/TrustStoreBackend.java 6 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/BackendImpl.java 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/persistit/PersistItStorage.java 8 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/persistit/PitBackend.java 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendImpl.java 16 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Importer.java 3 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskBackend.java 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/core/BackendConfigManager.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/extensions/ConfigFileHandler.java 6 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/BackendToolUtils.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/EncodePassword.java 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/persistit/PersistitTestCase.java 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ReadOnlyConfigFileHandler.java
@@ -46,6 +46,7 @@
import org.opends.server.core.ModifyDNOperation;
import org.opends.server.core.ModifyOperation;
import org.opends.server.core.SearchOperation;
import org.opends.server.core.ServerContext;
import org.opends.server.types.AttributeType;
import org.opends.server.types.BackupConfig;
import org.opends.server.types.BackupDirectory;
@@ -267,7 +268,7 @@
  /** {@inheritDoc} */
  @Override
  public void configureBackend(BackendCfg cfg) throws ConfigException
  public void configureBackend(BackendCfg cfg, ServerContext serverContext) throws ConfigException
  {
  }
opendj-server-legacy/src/main/java/org/opends/server/api/Backend.java
@@ -52,6 +52,7 @@
import org.opends.server.core.PersistentSearch;
import org.opends.server.core.PersistentSearch.CancellationCallback;
import org.opends.server.core.SearchOperation;
import org.opends.server.core.ServerContext;
import org.opends.server.monitors.BackendMonitor;
import org.opends.server.types.AttributeType;
import org.opends.server.types.BackupConfig;
@@ -112,15 +113,26 @@
      new ConcurrentLinkedQueue<PersistentSearch>();
  /**
   * Temporarily sets up the server context for the first phase of add of a new configuration entry.
   * Will be needed for checking storage parameters before committing the change in configuration.
   *
   * @param context the server context for this instance
   */
  public void setServerContext(ServerContext context)
  {
  }
  /**
   * Configure this backend based on the information in the provided
   * configuration.
   *
   * @param  cfg          The configuration of this backend.
   * @param  serverContext The server context for this instance
   *
   * @throws  ConfigException
   *                      If there is an error in the configuration.
   */
  public abstract void configureBackend(C cfg) throws ConfigException;
  public abstract void configureBackend(C cfg, ServerContext serverContext) throws ConfigException;
  /**
   * Indicates whether the provided configuration is acceptable for
@@ -166,8 +178,7 @@
   *                                   related to the server
   *                                   configuration.
   */
  public abstract void initializeBackend()
         throws ConfigException, InitializationException;
  public abstract void initializeBackend() throws ConfigException, InitializationException;
  /**
   * Performs any necessary work to finalize this backend, including
opendj-server-legacy/src/main/java/org/opends/server/backends/BackupBackend.java
@@ -53,6 +53,7 @@
import org.opends.server.core.ModifyDNOperation;
import org.opends.server.core.ModifyOperation;
import org.opends.server.core.SearchOperation;
import org.opends.server.core.ServerContext;
import org.opends.server.schema.GeneralizedTimeSyntax;
import org.opends.server.types.*;
@@ -157,7 +158,7 @@
  /** {@inheritDoc} */
  @Override
  public void configureBackend(BackupBackendCfg config) throws ConfigException
  public void configureBackend(BackupBackendCfg config, ServerContext serverContext) throws ConfigException
  {
    // Make sure that a configuration entry was provided.  If not, then we will
    // not be able to complete initialization.
opendj-server-legacy/src/main/java/org/opends/server/backends/ChangelogBackend.java
@@ -69,6 +69,7 @@
import org.opends.server.core.ModifyOperation;
import org.opends.server.core.PersistentSearch;
import org.opends.server.core.SearchOperation;
import org.opends.server.core.ServerContext;
import org.opends.server.replication.common.CSN;
import org.opends.server.replication.common.MultiDomainServerState;
import org.opends.server.replication.common.ServerState;
@@ -279,7 +280,7 @@
  /** {@inheritDoc} */
  @Override
  public void configureBackend(final Configuration config) throws ConfigException
  public void configureBackend(final Configuration config, ServerContext serverContext) throws ConfigException
  {
    throw new UnsupportedOperationException("The changelog backend is not configurable");
  }
opendj-server-legacy/src/main/java/org/opends/server/backends/LDIFBackend.java
@@ -1231,7 +1231,7 @@
  /** {@inheritDoc} */
  @Override
  public void configureBackend(LDIFBackendCfg config) throws ConfigException
  public void configureBackend(LDIFBackendCfg config, ServerContext serverContext) throws ConfigException
  {
    if (config != null)
    {
opendj-server-legacy/src/main/java/org/opends/server/backends/MemoryBackend.java
@@ -52,6 +52,7 @@
import org.opends.server.core.ModifyDNOperation;
import org.opends.server.core.ModifyOperation;
import org.opends.server.core.SearchOperation;
import org.opends.server.core.ServerContext;
import org.opends.server.types.AttributeType;
import org.opends.server.types.BackupConfig;
import org.opends.server.types.BackupDirectory;
@@ -148,7 +149,7 @@
  /** {@inheritDoc} */
  @Override
  public void configureBackend(MemoryBackendCfg config) throws ConfigException
  public void configureBackend(MemoryBackendCfg config, ServerContext serverContext) throws ConfigException
  {
    if (config != null)
    {
opendj-server-legacy/src/main/java/org/opends/server/backends/MonitorBackend.java
@@ -160,7 +160,7 @@
  /** {@inheritDoc} */
  @Override
  public void configureBackend(final MonitorBackendCfg config)
  public void configureBackend(final MonitorBackendCfg config, ServerContext serverContext)
      throws ConfigException
  {
    Reject.ifNull(config);
opendj-server-legacy/src/main/java/org/opends/server/backends/NullBackend.java
@@ -51,6 +51,7 @@
import org.opends.server.core.ModifyDNOperation;
import org.opends.server.core.ModifyOperation;
import org.opends.server.core.SearchOperation;
import org.opends.server.core.ServerContext;
import org.opends.server.types.AttributeType;
import org.opends.server.types.BackupConfig;
import org.opends.server.types.BackupDirectory;
@@ -146,7 +147,7 @@
  /** {@inheritDoc} */
  @Override
  public void configureBackend(BackendCfg config) throws ConfigException
  public void configureBackend(BackendCfg config, ServerContext serverContext) throws ConfigException
  {
    if (config != null)
    {
opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java
@@ -65,6 +65,7 @@
import org.opends.server.core.ModifyDNOperation;
import org.opends.server.core.ModifyOperation;
import org.opends.server.core.SearchOperation;
import org.opends.server.core.ServerContext;
import org.opends.server.types.*;
import org.opends.server.util.BuildVersion;
import org.opends.server.util.LDIFWriter;
@@ -142,7 +143,7 @@
  /** {@inheritDoc} */
  @Override
  public void configureBackend(RootDSEBackendCfg config) throws ConfigException
  public void configureBackend(RootDSEBackendCfg config, ServerContext serverContext) throws ConfigException
  {
    Reject.ifNull(config);
    currentConfig = config;
@@ -151,8 +152,7 @@
  /** {@inheritDoc} */
  @Override
  public void initializeBackend()
         throws ConfigException, InitializationException
  public void initializeBackend() throws ConfigException, InitializationException
  {
    ConfigEntry configEntry =
         DirectoryServer.getConfigEntry(configEntryDN);
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
@@ -88,6 +88,7 @@
import org.opends.server.core.ModifyOperation;
import org.opends.server.core.SchemaConfigManager;
import org.opends.server.core.SearchOperation;
import org.opends.server.core.ServerContext;
import org.opends.server.schema.AttributeTypeSyntax;
import org.opends.server.schema.DITContentRuleSyntax;
import org.opends.server.schema.DITStructureRuleSyntax;
@@ -252,7 +253,7 @@
  /** {@inheritDoc} */
  @Override
  public void configureBackend(SchemaBackendCfg cfg) throws ConfigException
  public void configureBackend(SchemaBackendCfg cfg, ServerContext serverContext) throws ConfigException
  {
    // Make sure that a configuration entry was provided.  If not, then we will
    // not be able to complete initialization.
@@ -353,8 +354,7 @@
  /** {@inheritDoc} */
  @Override
  public void initializeBackend()
         throws ConfigException, InitializationException
  public void initializeBackend() throws ConfigException, InitializationException
  {
    // Register each of the suffixes with the Directory Server.  Also, register
    // the first one as the schema base.
opendj-server-legacy/src/main/java/org/opends/server/backends/TrustStoreBackend.java
@@ -77,6 +77,7 @@
import org.opends.server.core.ModifyDNOperation;
import org.opends.server.core.ModifyOperation;
import org.opends.server.core.SearchOperation;
import org.opends.server.core.ServerContext;
import org.opends.server.types.*;
import org.opends.server.util.CertificateManager;
import org.opends.server.util.SetupUtils;
@@ -132,7 +133,7 @@
  /** {@inheritDoc} */
  @Override
  public void configureBackend(TrustStoreBackendCfg config) throws ConfigException
  public void configureBackend(TrustStoreBackendCfg config, ServerContext serverContext) throws ConfigException
  {
    Reject.ifNull(config);
    configuration = config;
@@ -140,8 +141,7 @@
  /** {@inheritDoc} */
  @Override
  public void initializeBackend()
         throws ConfigException, InitializationException
  public void initializeBackend() throws ConfigException, InitializationException
  {
    DN configEntryDN = configuration.dn();
opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/BackendImpl.java
@@ -153,7 +153,7 @@
  /** {@inheritDoc} */
  @Override
  public void configureBackend(LocalDBBackendCfg cfg) throws ConfigException
  public void configureBackend(LocalDBBackendCfg cfg, ServerContext serverContext) throws ConfigException
  {
    Reject.ifNull(cfg);
opendj-server-legacy/src/main/java/org/opends/server/backends/persistit/PersistItStorage.java
@@ -44,6 +44,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.admin.server.ConfigurationChangeListener;
@@ -60,8 +61,8 @@
import org.opends.server.backends.pluggable.spi.UpdateFunction;
import org.opends.server.backends.pluggable.spi.WriteOperation;
import org.opends.server.backends.pluggable.spi.WriteableStorage;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ServerContext;
import org.opends.server.extensions.DiskSpaceMonitor;
import org.opends.server.types.DN;
import org.opends.server.types.FilePermission;
@@ -524,9 +525,12 @@
   *
   * @param cfg
   *          The configuration.
   * @param serverContext
   *          This server instance context
   * @throws ConfigException if memory cannot be reserved
   */
  // FIXME: should be package private once importer is decoupled.
  public PersistItStorage(final PersistitBackendCfg cfg)
  public PersistItStorage(final PersistitBackendCfg cfg, ServerContext serverContext) throws ConfigException
  {
    backendDirectory = new File(getFileForPath(cfg.getDBDirectory()), cfg.getBackendId());
    config = cfg;
opendj-server-legacy/src/main/java/org/opends/server/backends/persistit/PitBackend.java
@@ -39,6 +39,6 @@
  @Override
  protected Storage configureStorage(PersistitBackendCfg cfg) throws ConfigException
  {
    return new PersistItStorage(cfg);
    return new PersistItStorage(cfg, serverContext);
  }
}
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendImpl.java
@@ -95,6 +95,9 @@
      OID_SERVER_SIDE_SORT_REQUEST_CONTROL,
      OID_VLV_REQUEST_CONTROL));
  /** The server context for this directory server. */
  protected ServerContext serverContext;
  /**
   * Begin a Backend API method that accesses the database and returns the <code>EntryContainer</code> for
   * <code>entryDN</code>.
@@ -144,19 +147,19 @@
  /** {@inheritDoc} */
  @Override
  public void configureBackend(C cfg) throws ConfigException
  public void configureBackend(C cfg, ServerContext serverContext) throws ConfigException
  {
    Reject.ifNull(cfg);
    this.cfg = cfg;
    this.serverContext = serverContext;
    baseDNs = this.cfg.getBaseDN().toArray(new DN[0]);
    storage = new TracedStorage(configureStorage(cfg), cfg.getBackendId());
  }
  /** {@inheritDoc} */
  @Override
  public void initializeBackend()
      throws ConfigException, InitializationException
  public void initializeBackend() throws ConfigException, InitializationException
  {
    if (mustOpenRootContainer())
    {
@@ -801,6 +804,13 @@
  /** {@inheritDoc} */
  @Override
  public void setServerContext(ServerContext context)
  {
    this.serverContext = context;
  }
  /** {@inheritDoc} */
  @Override
  public boolean isConfigurationAcceptable(C config, List<LocalizableMessage> unacceptableReasons)
  {
    return isConfigurationChangeAcceptable(config, unacceptableReasons);
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Importer.java
@@ -3979,7 +3979,8 @@
      returnValues.put("isDBTxnNoSync", true);
      try
      {
        storage = new PersistItStorage(newPersistitBackendCfgProxy(returnValues));
        storage = new PersistItStorage(newPersistitBackendCfgProxy(returnValues),
            DirectoryServer.getInstance().getServerContext());
      }
      catch (Exception e)
      {
opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskBackend.java
@@ -137,7 +137,7 @@
  /** {@inheritDoc} */
  @Override
  public void configureBackend(TaskBackendCfg cfg) throws ConfigException
  public void configureBackend(TaskBackendCfg cfg, ServerContext serverContext) throws ConfigException
  {
    Reject.ifNull(cfg);
opendj-server-legacy/src/main/java/org/opends/server/core/BackendConfigManager.java
@@ -1017,10 +1017,10 @@
  }
  @SuppressWarnings({ "unchecked", "rawtypes" })
  private static void initializeBackend(Backend backend, BackendCfg cfg)
  private void initializeBackend(Backend backend, BackendCfg cfg)
       throws ConfigException, InitializationException
  {
    backend.configureBackend(cfg);
    backend.configureBackend(cfg, serverContext);
    backend.initializeBackend();
  }
opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
@@ -2091,7 +2091,7 @@
    }
    rootDSEBackend = new RootDSEBackend();
    rootDSEBackend.configureBackend(rootDSECfg);
    rootDSEBackend.configureBackend(rootDSECfg, serverContext);
    rootDSEBackend.initializeBackend();
  }
@@ -2425,7 +2425,7 @@
    throw new InitializationException(message, e);
  }
  rootDSEBackend = new RootDSEBackend();
  rootDSEBackend.configureBackend(rootDSECfg);
  rootDSEBackend.configureBackend(rootDSECfg, serverContext);
  rootDSEBackend.initializeBackend();
}
opendj-server-legacy/src/main/java/org/opends/server/extensions/ConfigFileHandler.java
@@ -76,6 +76,7 @@
import org.opends.server.core.ModifyDNOperation;
import org.opends.server.core.ModifyOperation;
import org.opends.server.core.SearchOperation;
import org.opends.server.core.ServerContext;
import org.opends.server.schema.GeneralizedTimeSyntax;
import org.opends.server.tools.LDIFModify;
import org.opends.server.types.*;
@@ -794,7 +795,7 @@
  /** {@inheritDoc} */
  @Override
  public void configureBackend(ConfigFileHandlerBackendCfg cfg)
  public void configureBackend(ConfigFileHandlerBackendCfg cfg, ServerContext serverContext)
         throws ConfigException
  {
    // No action is required.
@@ -802,8 +803,7 @@
  /** {@inheritDoc} */
  @Override
  public void initializeBackend()
         throws ConfigException, InitializationException
  public void initializeBackend() throws ConfigException, InitializationException
  {
    // No action is required, since all initialization was performed in the
    // initializeConfigHandler method.
opendj-server-legacy/src/main/java/org/opends/server/tools/BackendToolUtils.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2014 ForgeRock AS
 *      Portions Copyright 2013-2015 ForgeRock AS
 */
package org.opends.server.tools;
@@ -197,7 +197,7 @@
        backend = (Backend) backendClass.newInstance();
        backend.setBackendID(backendID);
        cfg = root.getBackend(backendID);
        backend.configureBackend(cfg);
        backend.configureBackend(cfg, DirectoryServer.getInstance().getServerContext());
      }
      catch (Exception e)
      {
opendj-server-legacy/src/main/java/org/opends/server/tools/EncodePassword.java
@@ -879,7 +879,7 @@
        backend.setBackendID(backendID);
        backend.setWritabilityMode(WritabilityMode.INTERNAL_ONLY);
        try {
          backend.configureBackend(backendCfg);
          backend.configureBackend(backendCfg, directoryServer.getServerContext());
          backend.initializeBackend();
        } catch (Exception e) {
          LocalizableMessage msg = ERR_CONFIG_BACKEND_CANNOT_INITIALIZE.get(className, backendCfg.dn(),
opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java
@@ -89,7 +89,7 @@
         throws Exception
  {
    SchemaBackend schemaBackend = new SchemaBackend();
    schemaBackend.configureBackend(null);
    schemaBackend.configureBackend(null, null);
  }
opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/persistit/PersistitTestCase.java
@@ -65,7 +65,7 @@
  
    PitBackend b = new PitBackend();
    b.setBackendID(backendCfg.getBackendId());
    b.configureBackend((PersistitBackendCfg)backendCfg);
    b.configureBackend((PersistitBackendCfg)backendCfg, DirectoryServer.getInstance().getServerContext());
    return b;
  }