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

Violette Roche-Montane
07.27.2013 010eb1a3897f43458830cef58270d8196c3a4459
OPENDJ-473 CR-1252 Implement a task which allows the administrator to forcefully clear an index's degraded status.
6 files modified
2994 ■■■■ changed files
opends/resource/schema/02-config.ldif 7 ●●●● patch | view | raw | blame | history
opends/src/messages/messages/tools.properties 8 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/backends/jeb/RebuildConfig.java 94 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java 2856 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/config/ConfigConstants.java 9 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/RebuildIndex.java 20 ●●●●● patch | view | raw | blame | history
opends/resource/schema/02-config.ldif
@@ -3654,6 +3654,11 @@
  SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
  SINGLE-VALUE
  X-ORIGIN 'OpenDJ Directory Server' )
attributeTypes: ( 1.3.6.1.4.1.36733.2.1.1.116
  NAME 'ds-task-rebuild-index-clear-degraded-state'
  EQUALITY caseIgnoreMatch
  SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
  X-ORIGIN 'OpenDS Directory Server' )
objectClasses: ( 1.3.6.1.4.1.26027.1.2.1
  NAME 'ds-cfg-access-control-handler'
  SUP top
@@ -4638,7 +4643,7 @@
  STRUCTURAL
  MUST ( ds-task-rebuild-base-dn $
         ds-task-rebuild-index )
  MAY ds-task-rebuild-tmp-directory
  MAY ( ds-task-rebuild-tmp-directory $ ds-task-rebuild-index-clear-degraded-state )
  X-ORIGIN 'OpenDS Directory Server' )
objectClasses: ( 1.3.6.1.4.1.26027.1.2.98
  NAME 'ds-virtual-static-group'
opends/src/messages/messages/tools.properties
@@ -21,7 +21,7 @@
# CDDL HEADER END
#
#      Copyright 2006-2010 Sun Microsystems, Inc.
#      Portions Copyright 2011-2012 ForgeRock AS
#      Portions Copyright 2011-2013 ForgeRock AS
@@ -2595,3 +2595,9 @@
 cannot be specified with the "--rebuildDegraded" option
SEVERE_ERR_CONFIGDS_CANNOT_UPDATE_DIGEST_MD5_FQDN_1733=An error occurred while \
 attempting to update the FQDN for the DIGEST-MD5 SASL mechanism:  %s
INFO_REBUILDINDEX_DESCRIPTION_CLEAR_DEGRADED_STATE_1734=Indicates that indexes do not need \
rebuilding because they are known to be empty and forcefully marks them as valid. \
This is an advanced option which must only be used in cases where a degraded index \
is known to be empty and does not therefore need rebuilding. \
This situation typically arises when an index is created for an attribute \
which has just been added to the schema
opends/src/server/org/opends/server/backends/jeb/RebuildConfig.java
@@ -23,7 +23,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions copyright 2012 ForgeRock AS.
 *      Portions Copyright 2011-2013 ForgeRock AS
 */
package org.opends.server.backends.jeb;
@@ -39,7 +39,8 @@
  /**
   * Identifies how indexes will be selected for rebuild.
   */
  public static enum RebuildMode {
  public static enum RebuildMode
  {
    /**
     * Rebuild all indexes, including system indexes.
     */
@@ -70,8 +71,10 @@
  private String tmpDirectory;
  private boolean isClearDegradedState;
  /**
   * Create a new rebuild configuraiton.
   * Create a new rebuild configuration.
   */
  public RebuildConfig()
  {
@@ -80,6 +83,7 @@
  /**
   * Get the base DN to rebuild.
   *
   * @return The base DN to rebuild.
   */
  public DN getBaseDN()
@@ -89,7 +93,9 @@
  /**
   * Set the base DN to rebuild.
   * @param baseDN The base DN to rebuild.
   *
   * @param baseDN
   *          The base DN to rebuild.
   */
  public void setBaseDN(DN baseDN)
  {
@@ -109,34 +115,35 @@
  /**
   * Add an index to be rebuilt into the configuration. Duplicate index names
   * will be ignored. Adding an index that causes a mix of complete and partial
   * rebuild for the same attribute index in the configuration will remove
   * the partial and just keep the complete attribute index name.
   * (ie. uid and uid.presence).
   * rebuild for the same attribute index in the configuration will remove the
   * partial and just keep the complete attribute index name. (ie. uid and
   * uid.presence).
   *
   * @param index The index to add.
   * @param index
   *          The index to add.
   */
  public void addRebuildIndex(String index)
  {
    String[] newIndexParts = index.split("\\.");
    for(String s : new ArrayList<String>(rebuildList))
    for (String s : new ArrayList<String>(rebuildList))
    {
      String[] existingIndexParts = s.split("\\.");
      if(existingIndexParts[0].equalsIgnoreCase(newIndexParts[0]))
      if (existingIndexParts[0].equalsIgnoreCase(newIndexParts[0]))
      {
        if(newIndexParts.length == 1 && existingIndexParts.length == 1)
        if (newIndexParts.length == 1 && existingIndexParts.length == 1)
        {
          return;
        }
        else if(newIndexParts.length > 1 && existingIndexParts.length == 1)
        else if (newIndexParts.length > 1 && existingIndexParts.length == 1)
        {
          return;
        }
        else if(newIndexParts.length == 1 && existingIndexParts.length > 1)
        else if (newIndexParts.length == 1 && existingIndexParts.length > 1)
        {
          rebuildList.remove(s);
        }
        else if(newIndexParts[1].equalsIgnoreCase(existingIndexParts[1]))
        else if (newIndexParts[1].equalsIgnoreCase(existingIndexParts[1]))
        {
          return;
        }
@@ -150,36 +157,37 @@
   * Check the given config for conflicts with this config. A conflict is
   * detected if both configs specify the same indexType/database to be rebuilt.
   *
   * @param config The rebuild config to check against.
   * @param config
   *          The rebuild config to check against.
   * @return the name of the indexType causing the conflict or null if no
   *         conflict is detected.
   */
  public String checkConflicts(RebuildConfig config)
  {
    //If they specify different base DNs, no conflicts can occur.
    if(this.baseDN.equals(config.baseDN))
    if (this.baseDN.equals(config.baseDN))
    {
      for(String thisIndex : this.rebuildList)
      for (String thisIndex : this.rebuildList)
      {
        for(String thatIndex : config.rebuildList)
        for (String thatIndex : config.rebuildList)
        {
          String[] existingIndexParts = thisIndex.split("\\.");
          String[] newIndexParts = thatIndex.split("\\.");
          if(existingIndexParts[0].equalsIgnoreCase(newIndexParts[0]))
          if (existingIndexParts[0].equalsIgnoreCase(newIndexParts[0]))
          {
            if(newIndexParts.length == 1 && existingIndexParts.length == 1)
            if (newIndexParts.length == 1 && existingIndexParts.length == 1)
            {
              return thatIndex;
            }
            else if(newIndexParts.length > 1 && existingIndexParts.length == 1)
            else if (newIndexParts.length > 1 && existingIndexParts.length == 1)
            {
              return thatIndex;
            }
            else if(newIndexParts.length == 1 && existingIndexParts.length > 1)
            else if (newIndexParts.length == 1 && existingIndexParts.length > 1)
            {
              return thatIndex;
            }
            else if(newIndexParts[1].equalsIgnoreCase(existingIndexParts[1]))
            else if (newIndexParts[1].equalsIgnoreCase(existingIndexParts[1]))
            {
              return thatIndex;
            }
@@ -198,17 +206,17 @@
   */
  public boolean includesSystemIndex()
  {
    for(String index : rebuildList)
    for (String index : rebuildList)
    {
      if(index.equalsIgnoreCase("id2entry"))
      if (index.equalsIgnoreCase("id2entry"))
      {
        return true;
      }
      if(index.equalsIgnoreCase("dn2id"))
      if (index.equalsIgnoreCase("dn2id"))
      {
        return true;
      }
      if(index.equalsIgnoreCase("dn2uri"))
      if (index.equalsIgnoreCase("dn2uri"))
      {
        return true;
      }
@@ -217,11 +225,11 @@
    return false;
  }
  /**
   * Set the temporary directory to the specified path.
   *
   * @param path The path to set the temporary directory to.
   * @param path
   *          The path to set the temporary directory to.
   */
  public void setTmpDirectory(String path)
  {
@@ -231,18 +239,18 @@
  /**
   * Return the temporary directory path.
   *
   * @return  The temporary directory string.
   * @return The temporary directory string.
   */
  public String getTmpDirectory()
  {
    return tmpDirectory;
  }
  /**
   * Sets the rebuild mode.
   *
   * @param mode The new rebuild mode.
   * @param mode
   *          The new rebuild mode.
   */
  public void setRebuildMode(RebuildMode mode)
  {
@@ -259,5 +267,27 @@
    return rebuildMode;
  }
  /**
   * Returns {@code true} if indexes should be forcefully marked as valid even
   * if they are currently degraded.
   *
   * @return {@code true} if index should be forcefully marked as valid.
   */
  public boolean isClearDegradedState()
  {
    return isClearDegradedState;
  }
  /**
   * Sets the 'clear degraded index' status.
   *
   * @param isClearDegradedState
   *          {@code true} if indexes should be forcefully marked as valid even
   *          if they are currently degraded.
   */
  public void isClearDegradedState(boolean isClearDegradedState)
  {
    this.isClearDegradedState = isClearDegradedState;
  }
}
opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java
Diff too large
opends/src/server/org/opends/server/config/ConfigConstants.java
@@ -23,7 +23,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions copyright 2011-2012 ForgeRock AS
 *      Portions copyright 2011-2013 ForgeRock AS
 */
package org.opends.server.config;
@@ -4332,6 +4332,13 @@
  public static final String ATTR_REBUILD_INDEX =
       NAME_PREFIX_TASK + "rebuild-index";
  /**
   * The name of the attribute in an rebuild task definition that specifies the
   * degraded index which needs to be clear.
   */
  public static final String ATTR_REBUILD_INDEX_CLEARDEGRADEDSTATE =
      ATTR_REBUILD_INDEX + "-clear-degraded-state";
  /**
   * The name of the attribute in an rebuild task definition that specifies the
opends/src/server/org/opends/server/tools/RebuildIndex.java
@@ -23,7 +23,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions copyright 2012 ForgeRock AS.
 *      Portions Copyright 2011-2013 ForgeRock AS
 */
package org.opends.server.tools;
import org.opends.messages.Message;
@@ -41,6 +41,7 @@
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.loggers.ErrorLogger.logError;
import org.opends.server.loggers.TextWriter;
import org.opends.server.loggers.ErrorLogger;
import org.opends.server.loggers.TextErrorLogPublisher;
@@ -85,6 +86,7 @@
  private StringArgument  tmpDirectory            = null;
  private BooleanArgument rebuildAll              = null;
  private BooleanArgument rebuildDegraded         = null;
  private BooleanArgument clearDegradedState      = null;
  /**
   * Processes the command-line arguments and invokes the rebuild process.
@@ -203,6 +205,10 @@
                    INFO_REBUILDINDEX_DESCRIPTION_REBUILD_DEGRADED.get());
      argParser.addArgument(rebuildDegraded);
      clearDegradedState =
          new BooleanArgument("clearDegradedState", null, "clearDegradedState",
                   INFO_REBUILDINDEX_DESCRIPTION_CLEAR_DEGRADED_STATE.get());
      argParser.addArgument(clearDegradedState);
      tmpDirectory =
           new StringArgument("tmpdirectory", null, "tmpdirectory", false,
@@ -557,6 +563,9 @@
    }
    else
    {
      if(clearDegradedState.isPresent()) {
        rebuildConfig.isClearDegradedState(true);
      }
      rebuildConfig.setRebuildMode(RebuildMode.USER_DEFINED);
    }
@@ -660,6 +669,15 @@
      attributes.add(
              new LDAPAttribute(ATTR_REBUILD_INDEX, values));
    }
    if (clearDegradedState.getValue() != null &&
        !clearDegradedState.getValue().equals(
            clearDegradedState.getDefaultValue())) {
      values = new ArrayList<ByteString>(1);
      values.add(ByteString.valueOf("true"));
      attributes.add(
            new LDAPAttribute(ATTR_REBUILD_INDEX_CLEARDEGRADEDSTATE, values));
    }
  }
  /**