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

vharseko
18.23.2023 bffeb78279ded6c57eb050f7237201ad93f8a4c2
FIX Setup Issue - Error Creating Base Entry (#286)

https://github.com/OpenIdentityPlatform/OpenDJ/issues/274
10 files modified
96 ■■■■ changed files
.github/workflows/build.yml 8 ●●●● patch | view | raw | blame | history
opendj-doc-generated-ref/pom.xml 1 ●●●● patch | view | raw | blame | history
opendj-packages/opendj-docker/Dockerfile 2 ●●● patch | view | raw | blame | history
opendj-packages/opendj-docker/Dockerfile-alpine 3 ●●●● patch | view | raw | blame | history
opendj-server-legacy/resource/config/java.properties 14 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/quicksetup/UserData.java 29 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/InstallerHelper.java 15 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/OnDiskMergeImporter.java 16 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java 2 ●●● patch | view | raw | blame | history
pom.xml 6 ●●●● patch | view | raw | blame | history
.github/workflows/build.yml
@@ -65,15 +65,19 @@
    - name: Test on Unix
      if: runner.os != 'Windows'
      run:   |
        opendj-server-legacy/target/package/opendj/setup -h localhost -p 1389 --ldapsPort 1636 --adminConnectorPort 4444 --enableStartTLS --generateSelfSignedCertificate --rootUserDN "cn=Directory Manager" --rootUserPassword password --baseDN dc=example,dc=com --addBaseEntry --cli --acceptLicense --no-prompt
        export OPENDJ_JAVA_ARGS="-server -Xmx1g"
        opendj-server-legacy/target/package/opendj/setup -h localhost -p 1389 --ldapsPort 1636 --adminConnectorPort 4444 --enableStartTLS --generateSelfSignedCertificate --rootUserDN "cn=Directory Manager" --rootUserPassword password --baseDN dc=example,dc=com --sampleData 50000 --cli --acceptLicense --no-prompt
        opendj-server-legacy/target/package/opendj/bin/status --bindDN "cn=Directory Manager" --bindPassword password
        opendj-server-legacy/target/package/opendj/bin/ldapsearch --hostname localhost --port 1636 --bindDN "cn=Directory Manager" --bindPassword password --useSsl --trustAll --baseDN "dc=example,dc=com" --searchScope base "(objectClass=*)" 1.1
        opendj-server-legacy/target/package/opendj/bin/ldapsearch --hostname localhost --port 1636 --bindDN "cn=Directory Manager" --bindPassword password --useSsl --trustAll --baseDN "ou=people,dc=example,dc=com" --searchScope sub "(uid=user.*)" dn | grep ^dn: | wc -l | grep -q 50000
    - name: Test on Windows
      if: runner.os == 'Windows'
      run:   |
        opendj-server-legacy\target\package\opendj\setup.bat -h localhost -p 1389 --ldapsPort 1636 --adminConnectorPort 4444 --enableStartTLS --generateSelfSignedCertificate --rootUserDN "cn=Directory Manager" --rootUserPassword password --baseDN dc=example,dc=com --addBaseEntry --cli --acceptLicense --no-prompt
        set OPENDJ_JAVA_ARGS="-server -Xmx1g"
        opendj-server-legacy\target\package\opendj\setup.bat -h localhost -p 1389 --ldapsPort 1636 --adminConnectorPort 4444 --enableStartTLS --generateSelfSignedCertificate --rootUserDN "cn=Directory Manager" --rootUserPassword password --baseDN dc=example,dc=com --sampleData 50000 --cli --acceptLicense --no-prompt
        opendj-server-legacy\target\package\opendj\bat\status.bat --bindDN "cn=Directory Manager" --bindPassword password
        opendj-server-legacy\target\package\opendj\bat\ldapsearch.bat --hostname localhost --port 1636 --bindDN "cn=Directory Manager" --bindPassword password --useSsl --trustAll --baseDN "dc=example,dc=com" --searchScope base "(objectClass=*)" 1.1
        opendj-server-legacy\target\package\opendj\bat\ldapsearch.bat --hostname localhost --port 1636 --bindDN "cn=Directory Manager" --bindPassword password --useSsl --trustAll --baseDN "dc=example,dc=com" --searchScope sub "(uid=user.*)" dn | find /c '"dn:"' | findstr "50000"
    - name: Upload artifacts OpenDJ Server
      uses: actions/upload-artifact@v3
      with:
opendj-doc-generated-ref/pom.xml
@@ -46,6 +46,7 @@
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <ignorePermissions>true</ignorePermissions>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.openidentityplatform.opendj</groupId>
opendj-packages/opendj-docker/Dockerfile
@@ -14,7 +14,7 @@
    MASTER_SERVER=${MASTER_SERVER} \
    OPENDJ_REPLICATION_TYPE=${OPENDJ_REPLICATION_TYPE} \
    OPENDJ_USER="opendj" \
    OPENDJ_JAVA_ARGS=""
    OPENDJ_JAVA_ARGS="-server -XX:+UseContainerSupport"
ARG VERSION=@project_version@
opendj-packages/opendj-docker/Dockerfile-alpine
@@ -13,7 +13,8 @@
    OPENDJ_SSL_OPTIONS=${SSL_OPTIONS:-"--generateSelfSignedCertificate"} \
    MASTER_SERVER=${MASTER_SERVER} \
    OPENDJ_REPLICATION_TYPE=${OPENDJ_REPLICATION_TYPE} \
    OPENDJ_USER="opendj"
    OPENDJ_USER="opendj"\
    OPENDJ_JAVA_ARGS="-server -XX:+UseContainerSupport"
ARG VERSION=@project_version@
opendj-server-legacy/resource/config/java.properties
@@ -12,7 +12,7 @@
#
# Copyright 2008-2010 Sun Microsystems, Inc.
# Portions Copyright 2011-2016 ForgeRock AS.
# Portions Copyright 2018- 3A Systems LLC.
#
# This file contains the java properties that the different command lines will
# use when launched.  You can specify the location of the java binaries to be
@@ -42,7 +42,7 @@
# Examples:
#
# Specify to use a particular Java Virtual Machine for the offline import:
# import-ldif.offline.java-home=/usr/jdk1.7
# import-ldif.offline.java-home=/usr/jdk1.8
#
# Specify to use -client argument when running dsconfig:
# dsconfig.java-args=-client
@@ -52,15 +52,11 @@
#
# Specify to use the java home for all the command-lines that have not
# an associated property defined:
# default.java-home=/usr/jdk1.6
# default.java-home=/usr/jdk1.8
#
# Specify to use the -client argument for all the command-lines that have not
# an associated property defined:
# default.java-args=-client
# default.java-args=-server
default.java-home=$JAVA_HOME
default.java-args=-Xms32m -client
import-ldif.offline.java-args=-server
rebuild-index.offline.java-args=-server
start-ds.java-args=-server
ldifdiff.java-args=-server
default.java-args=-server
opendj-server-legacy/src/main/java/org/opends/quicksetup/UserData.java
@@ -23,6 +23,7 @@
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
@@ -866,42 +867,26 @@
  private void createDefaultJavaArguments()
  {
    hmJavaArguments = new HashMap<>();
    int maxMemoryMb = 256;
    int minMemoryMb = 128;
    final int maxMemoryBytes = maxMemoryMb * 1024 * 1024;
    // If the current max memory is bigger than the max heap we want to set,
    // assume that the JVM ergonomics are going to be able to allocate enough
    // memory.
    long currentMaxMemoryBytes = Runtime.getRuntime().maxMemory();
    if (currentMaxMemoryBytes > maxMemoryBytes)
    {
      maxMemoryMb = -1;
      minMemoryMb = -1;
    }
    hmJavaArguments = new LinkedHashMap<>();
    JavaArguments defaultPanelJavaArgument = new JavaArguments();
    hmJavaArguments.put("default", defaultPanelJavaArgument);
    for (String clientScript : getClientScripts())
    {
      JavaArguments javaArgument = new JavaArguments();
      javaArgument.setInitialMemory(8);
      javaArgument.setAdditionalArguments(new String[] {"-client"});
      hmJavaArguments.put(clientScript, javaArgument);
    }
    for (String serverScript : getServerScripts())
    {
      JavaArguments javaArgument = new JavaArguments();
      javaArgument.setInitialMemory(minMemoryMb);
      javaArgument.setMaxMemory(maxMemoryMb);
      javaArgument.setAdditionalArguments(new String[] {"-server"});
      hmJavaArguments.put(serverScript, javaArgument);
    }
    JavaArguments controlPanelJavaArgument = new JavaArguments();
    controlPanelJavaArgument.setInitialMemory(64);
    controlPanelJavaArgument.setMaxMemory(128);
    controlPanelJavaArgument.setAdditionalArguments(new String[] {"-client"});
    hmJavaArguments.put("control-panel", controlPanelJavaArgument);
    hmDefaultJavaArguments = new HashMap<>(hmJavaArguments);
    hmDefaultJavaArguments = new LinkedHashMap<>(hmJavaArguments);
  }
  private String[] getClientScripts()
opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/InstallerHelper.java
@@ -35,8 +35,8 @@
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -142,7 +142,7 @@
    final ProcessBuilder processBuilder = new ProcessBuilder(argList.toArray(new String[argList.size()]));
    final Map<String, String> env = processBuilder.environment();
    env.remove(SetupUtils.OPENDJ_JAVA_HOME);
    env.remove(SetupUtils.OPENDJ_JAVA_ARGS);
    //env.remove(SetupUtils.OPENDJ_JAVA_ARGS);
    env.remove("CLASSPATH");
    processBuilder.directory(installPath);
@@ -755,7 +755,7 @@
    // Try to transform things if necessary.  The following map has as key
    // the original JavaArgument object and as value the 'transformed' JavaArgument.
    Map<JavaArguments, JavaArguments> hmJavaArguments = new HashMap<>();
    Map<JavaArguments, JavaArguments> hmJavaArguments = new LinkedHashMap<>();
    for (String script : uData.getScriptNamesForJavaArguments())
    {
      JavaArguments origJavaArguments = uData.getJavaArguments(script);
@@ -778,8 +778,8 @@
    }
    Properties fileProperties = getJavaPropertiesFileContents(getPropertiesFileName(installPath));
    Map<String, JavaArguments> args = new HashMap<>();
    Map<String, String> otherProperties = new HashMap<>();
    Map<String, JavaArguments> args = new LinkedHashMap<>();
    Map<String, String> otherProperties = new LinkedHashMap<>();
    for (String script : uData.getScriptNamesForJavaArguments())
    {
@@ -910,6 +910,7 @@
        break;
      }
    }
    reader.close();
    return commentLines;
  }
@@ -984,8 +985,8 @@
    {
      fLib.mkdir();
    }
    final String destinationFile = Utils.getPath(libDir, isWindows() ? SET_JAVA_PROPERTIES_FILE_WINDOWS
                                                                     : SET_JAVA_PROPERTIES_FILE_UNIX);
//    final String destinationFile = Utils.getPath(libDir, isWindows() ? SET_JAVA_PROPERTIES_FILE_WINDOWS
//                                                                     : SET_JAVA_PROPERTIES_FILE_UNIX);
  }
  /**
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/OnDiskMergeImporter.java
@@ -454,15 +454,15 @@
    private BufferPool newHeapBufferPool(final int nbBuffers, final long heapMemoryAvailable)
        throws InitializationException
    {
      final long minimumRequiredMemory = nbBuffers * MIN_BUFFER_SIZE + DB_CACHE_SIZE + REQUIRED_FREE_MEMORY;
      if (heapMemoryAvailable < minimumRequiredMemory)
      {
        // Not enough memory.
        throw new InitializationException(ERR_IMPORT_LDIF_LACK_MEM.get(heapMemoryAvailable, minimumRequiredMemory));
      }
//      final long minimumRequiredMemory = nbBuffers * MIN_BUFFER_SIZE + DB_CACHE_SIZE + REQUIRED_FREE_MEMORY;
//      if (heapMemoryAvailable < minimumRequiredMemory)
//      {
//        // Not enough memory.
//        throw new InitializationException(ERR_IMPORT_LDIF_LACK_MEM.get(heapMemoryAvailable, minimumRequiredMemory));
//      }
      logger.info(NOTE_IMPORT_LDIF_TOT_MEM_BUF, heapMemoryAvailable, nbBuffers);
      final long buffersMemory = heapMemoryAvailable - DB_CACHE_SIZE - REQUIRED_FREE_MEMORY;
      final int bufferSize = Math.min(((int) (buffersMemory / nbBuffers)), MAX_BUFFER_SIZE);
//      final long buffersMemory = heapMemoryAvailable - DB_CACHE_SIZE - REQUIRED_FREE_MEMORY;
      final int bufferSize =1024*1024; //Math.min(((int) (buffersMemory / nbBuffers)), MAX_BUFFER_SIZE);
      logger.info(NOTE_IMPORT_LDIF_DB_MEM_BUF_INFO, DB_CACHE_SIZE, bufferSize);
      return new BufferPool(nbBuffers, bufferSize, false);
    }
opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java
@@ -76,7 +76,7 @@
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  /** The buffer size that should be used when reading data from LDIF. */
  private static final int LDIF_BUFFER_SIZE = 1048576;
  private static final int LDIF_BUFFER_SIZE = 8192;
  /**
   * The main method for ImportLDIF tool.
pom.xml
@@ -414,7 +414,11 @@
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>3.1.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>3.6.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>