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

boli
24.14.2007 14809a0c5e44468632e3ddf56000c88bacaec0aa
Added the JE backend configuration attribute to enable or disable compression when encoding entries for ID2Entry. When backend-compact-encoding 
is enabled, attribute type descriptions and object class sets will be encoded using a compressed form. This behavior is enabled by default.

Fix for issue 2135
6 files modified
129 ■■■■ changed files
opends/resource/schema/02-config.ldif 7 ●●●● patch | view | raw | blame | history
opends/src/admin/defn/org/opends/server/admin/std/JEBackendConfiguration.xml 35 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/backends/jeb/DataConfig.java 59 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/backends/jeb/EntryContainer.java 10 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/backends/jeb/JebFormat.java 14 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestVerifyJob.java 4 ●●●● patch | view | raw | blame | history
opends/resource/schema/02-config.ldif
@@ -1573,6 +1573,10 @@
attributeTypes: ( 1.3.6.1.4.1.26027.1.1.468
  NAME 'ds-cfg-unique-attribute-base-dn' SYNTAX 1.3.6.1.4.1.1466.115.121.1.12
  X-ORIGIN 'OpenDS Directory Server' )
attributeTypes: ( 1.3.6.1.4.1.26027.1.1.471
  NAME 'ds-cfg-backend-compact-encoding'
  SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE
  X-ORIGIN 'OpenDS Directory Server' )
objectClasses: ( 1.3.6.1.4.1.26027.1.2.1
  NAME 'ds-cfg-access-control-handler' SUP top STRUCTURAL
  MUST ( cn $ ds-cfg-acl-handler-class $ ds-cfg-acl-handler-enabled )
@@ -1619,7 +1623,8 @@
  ds-cfg-database-logging-file-handler-on $ ds-cfg-database-logging-level $
  ds-cfg-database-checkpointer-bytes-interval $
  ds-cfg-database-checkpointer-wakeup-interval $
  ds-cfg-database-lock-num-lock-tables $ ds-cfg-database-cleaner-num-threads )
  ds-cfg-database-lock-num-lock-tables $ ds-cfg-database-cleaner-num-threads $
  ds-cfg-backend-compact-encoding )
  X-ORIGIN 'OpenDS Directory Server' )
objectClasses: ( 1.3.6.1.4.1.26027.1.2.7 NAME 'ds-cfg-je-database'
  SUP top STRUCTURAL MAY ( cn $ ds-cfg-database-cache-percent $
opends/src/admin/defn/org/opends/server/admin/std/JEBackendConfiguration.xml
@@ -145,6 +145,41 @@
      </ldap:attribute>
    </adm:profile>
  </adm:property>
  <adm:property name="backend-compact-encoding"
                mandatory="false"
                multi-valued="false">
    <adm:synopsis>
      Indicates whether the backend should use a compact form when encoding
      entries by compressing the attribute descriptions and object class sets.
    </adm:synopsis>
    <adm:description>
      Note that this property applies only to the entries themselves
      and does not impact the index data.
    </adm:description>
    <adm:requires-admin-action>
      <adm:other>
        <adm:synopsis>
          Changes to this setting will only take effect for writes that occur
          after the change is made.  It will not be retroactively applied to
          existing data.
        </adm:synopsis>
      </adm:other>
    </adm:requires-admin-action>
    <adm:default-behavior>
      <adm:defined>
        <adm:value>true</adm:value>
      </adm:defined>
    </adm:default-behavior>
    <adm:syntax>
      <adm:boolean />
    </adm:syntax>
    <adm:profile name="ldap">
      <ldap:attribute>
        <ldap:oid>1.3.6.1.4.1.26027.1.1.471</ldap:oid>
        <ldap:name>ds-cfg-backend-compact-encoding</ldap:name>
      </ldap:attribute>
    </adm:profile>
  </adm:property>
  <adm:property name="backend-entries-compressed"
    mandatory="false"
    multi-valued="false">
opends/src/server/org/opends/server/backends/jeb/DataConfig.java
@@ -26,6 +26,8 @@
 */
package org.opends.server.backends.jeb;
import org.opends.server.types.EntryEncodeConfig;
/**
 * Configuration class to indicate desired compression and cryptographic options
 * for the data stored in the database.
@@ -37,7 +39,24 @@
   */
  private boolean compressed = false;
  /**
   * The configuration to use when encoding entries in the database.
   */
  private EntryEncodeConfig encodeConfig = new EntryEncodeConfig();
  /**
   * Constrct a new DataConfig object with the specified settings.
   *
   * @param compressed true if data should be compressed, false if not.
   * @param compactEncoding true if data should be encoded in compact form,
   * false if not.
   */
  public DataConfig(boolean compressed, boolean compactEncoding)
  {
    this.compressed = compressed;
    this.encodeConfig = new EntryEncodeConfig(false, compactEncoding,
                                              compactEncoding);
  }
  /**
   * Determine whether data should be compressed before writing to the database.
@@ -48,6 +67,16 @@
    return compressed;
  }
  /**
   * Determine whether entries should be encoded with the compact form before
   * writing to the database.
   * @return true if data should be encoded in the compact form.
   */
  public boolean isCompactEncoding()
  {
    return encodeConfig.compressAttributeDescriptions();
  }
  /**
@@ -60,16 +89,38 @@
  }
  /**
   * Configure whether data should be encoded with the compact form before
   * writing to the database.
   * @param compactEncoding true if data should be encoded in compact form,
   * false if not.
   */
  public void setCompactEncoding(boolean compactEncoding)
  {
    this.encodeConfig = new EntryEncodeConfig(false, compactEncoding,
                                              compactEncoding);
  }
  /**
   * Get the EntryEncodeConfig object in use by this configuration.
   * @return the EntryEncodeConfig object in use by this configuration.
   */
  public EntryEncodeConfig getEntryEncodeConfig()
  {
    return this.encodeConfig;
  }
  /**
   * Get a string representation of this object.
   * @return A string representation of this object.
   */
  public String toString()
  {
    StringBuilder builder = new StringBuilder();
    if (compressed)
    {
      builder.append("[compressed]");
    }
    builder.append("DataConfig(compressed=");
    builder.append(compressed);
    builder.append(", ");
    encodeConfig.toString(builder);
    builder.append(")");
    return builder.toString();
  }
}
opends/src/server/org/opends/server/backends/jeb/EntryContainer.java
@@ -481,8 +481,9 @@
  {
    try
    {
      DataConfig entryDataConfig = new DataConfig();
      entryDataConfig.setCompressed(config.isBackendEntriesCompressed());
      DataConfig entryDataConfig =
          new DataConfig(config.isBackendEntriesCompressed(),
                         config.isBackendCompactEncoding());
      id2entry = new ID2Entry(databasePrefix + "_" + ID2ENTRY_DATABASE_NAME,
                              entryDataConfig, env, this);
@@ -4241,8 +4242,9 @@
      }
    }
    DataConfig entryDataConfig = new DataConfig();
    entryDataConfig.setCompressed(cfg.isBackendEntriesCompressed());
    DataConfig entryDataConfig =
        new DataConfig(cfg.isBackendEntriesCompressed(),
                       cfg.isBackendCompactEncoding());
    id2entry.setDataConfig(entryDataConfig);
    this.config = cfg;
opends/src/server/org/opends/server/backends/jeb/JebFormat.java
@@ -73,11 +73,6 @@
  public static final byte TAG_DIRECTORY_SERVER_ENTRY = 0x61;
  /**
   * The configuration to use when encoding entries in the database.
   */
  private static EntryEncodeConfig encodeConfig = new EntryEncodeConfig();
  /**
   * Decode a DatabaseEntry.  The encoded bytes may be compressed and/or
   * encrypted.
   *
@@ -249,7 +244,8 @@
  static public byte[] entryToDatabase(Entry entry, DataConfig dataConfig)
         throws DirectoryException
  {
    byte[] uncompressedBytes = encodeDirectoryServerEntry(entry);
    byte[] uncompressedBytes = encodeDirectoryServerEntry(entry,
                                             dataConfig.getEntryEncodeConfig());
    return encodeDatabaseEntry(uncompressedBytes, dataConfig);
  }
@@ -265,19 +261,21 @@
  static public byte[] entryToDatabase(Entry entry)
         throws DirectoryException
  {
    return entryToDatabase(entry, new DataConfig());
    return entryToDatabase(entry, new DataConfig(false, false));
  }
  /**
   * Encode a ASN1 DirectoryServerEntry.
   *
   * @param entry The entry to encode.
   * @encodeConfig The configuration to use when encoding the entry.
   * @return A byte array containing the encoded DirectoryServerEntry.
   *
   * @throws  DirectoryException  If a problem occurs while attempting to encode
   *                              the entry.
   */
  static private byte[] encodeDirectoryServerEntry(Entry entry)
  static private byte[] encodeDirectoryServerEntry(Entry entry,
                                                 EntryEncodeConfig encodeConfig)
         throws DirectoryException
  {
    return entry.encode(encodeConfig);
opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestVerifyJob.java
@@ -443,7 +443,7 @@
      DatabaseEntry key= new DatabaseEntry(shortBytes);
      Entry testEntry=bldStatEntry(junkDN);
      byte []entryBytes =
           JebFormat.entryToDatabase(testEntry, new DataConfig());
           JebFormat.entryToDatabase(testEntry, new DataConfig(false, false));
      DatabaseEntry data= new DatabaseEntry(entryBytes);
      assertTrue(id2entry.putRaw(txn, key, data));
@@ -773,7 +773,7 @@
    DatabaseEntry key= new EntryID(id).getDatabaseEntry();
    Entry testEntry=bldStatEntry(dn);
    byte []entryBytes =
         JebFormat.entryToDatabase(testEntry, new DataConfig());
         JebFormat.entryToDatabase(testEntry, new DataConfig(false, false));
    if(trashFormat)
      entryBytes[0] = 0x67;
    DatabaseEntry data= new DatabaseEntry(entryBytes);