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

Fabio Pistolesi
28.52.2016 09bc45b1b94dad21572ba75b07ffe05baba103df
OPENDJ-2973 Changing index entry limit should un-trust the index when the new value is bigger

The index was not marked as not trusted. The same can also be said about confidentiality,
turning it on should require a rebuild.
3 files modified
35 ■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/AttributeIndex.java 27 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DefaultIndex.java 6 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Index.java 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/AttributeIndex.java
@@ -939,10 +939,17 @@
        entryContainer.unlock();
      }
      for (Index updatedIndex : updatedIndexes.values())
      entryContainer.getRootContainer().getStorage().write(new WriteOperation()
      {
        updateIndex(updatedIndex, newConfiguration, ccr);
      }
        @Override
        public void run(WriteableTransaction txn) throws Exception
        {
          for (final Index updatedIndex : updatedIndexes.values())
          {
            updateIndex(updatedIndex, newConfiguration, ccr, txn);
          }
        }
      });
    }
    catch (Exception e)
    {
@@ -963,19 +970,27 @@
    }
  }
  private static void updateIndex(Index updatedIndex, BackendIndexCfg newConfig, ConfigChangeResult ccr)
  private static void updateIndex(Index updatedIndex, BackendIndexCfg newConfig, ConfigChangeResult ccr,
      WriteableTransaction txn)
  {
    // This index could still be used since a new smaller index size limit doesn't impact validity of the results.
    if (updatedIndex.setIndexEntryLimit(newConfig.getIndexEntryLimit()))
    boolean newLimitRequiresRebuild = updatedIndex.setIndexEntryLimit(newConfig.getIndexEntryLimit());
    if (newLimitRequiresRebuild)
    {
      ccr.setAdminActionRequired(true);
      ccr.addMessage(NOTE_CONFIG_INDEX_ENTRY_LIMIT_REQUIRES_REBUILD.get(updatedIndex.getName()));
    }
    if (updatedIndex.setProtected(newConfig.isConfidentialityEnabled()))
    // This index could still be used when disabling confidentiality.
    boolean newConfidentialityRequiresRebuild = updatedIndex.setConfidential(newConfig.isConfidentialityEnabled());
    if (newConfidentialityRequiresRebuild)
    {
      ccr.setAdminActionRequired(true);
      ccr.addMessage(NOTE_CONFIG_INDEX_CONFIDENTIALITY_REQUIRES_REBUILD.get(updatedIndex.getName()));
    }
    if (newLimitRequiresRebuild || newConfidentialityRequiresRebuild)
    {
      updatedIndex.setTrusted(txn, false);
    }
  }
  private static void deleteIndex(WriteableTransaction txn, EntryContainer entryContainer, Index index)
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DefaultIndex.java
@@ -291,10 +291,10 @@
  }
  @Override
  public boolean setProtected(boolean protectIndex)
  public boolean setConfidential(boolean indexConfidential)
  {
    final boolean rebuildRequired = this.encryptValues != protectIndex;
    this.encryptValues = protectIndex;
    final boolean rebuildRequired = !this.encryptValues && indexConfidential;
    this.encryptValues = indexConfidential;
    return rebuildRequired;
  }
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Index.java
@@ -39,7 +39,7 @@
  boolean setIndexEntryLimit(int indexEntryLimit);
  boolean setProtected(boolean protectIndex);
  boolean setConfidential(boolean indexConfidential);
  void setTrusted(WriteableTransaction txn, boolean trusted);