Class InstallerHelper


  • public class InstallerHelper
    extends Object
    This is the only class that uses classes in org.opends.server (excluding the case of DynamicConstants, SetupUtils and CertificateManager which are already included in quicksetup.jar). Important note: do not include references to this class until OpenDS.jar has been loaded. These classes must be loaded during Runtime. The code is written in a way that when we execute the code that uses these classes the required jar files are already loaded. However these jar files are not necessarily loaded when we create this class.
    • Constructor Detail

      • InstallerHelper

        public InstallerHelper()
    • Method Detail

      • invokeImportLDIF

        public int invokeImportLDIF​(Application application,
                                    String[] args)
                             throws IOException,
                                    InterruptedException
        Invokes the import-ldif command-line with the provided parameters.
        Parameters:
        application - the application that is launching this.
        args - the arguments to be passed to import-ldif.
        Returns:
        the return code of the import-ldif call.
        Throws:
        IOException - if the process could not be launched.
        InterruptedException - if the process was interrupted.
      • getStartedId

        public String getStartedId()
        Returns the LocalizableMessage ID that corresponds to a successfully started server.
        Returns:
        the LocalizableMessage ID that corresponds to a successfully started server.
      • disableWindowsService

        public void disableWindowsService()
                                   throws ApplicationException
        This method disables this server as a Windows service.
        Throws:
        ApplicationException - if something goes worong.
      • createBaseEntryTempFile

        public File createBaseEntryTempFile​(String baseDn)
                                     throws ApplicationException
        Creates a template LDIF file with an entry that has as dn the provided baseDn.
        Parameters:
        baseDn - the dn of the entry that will be created in the LDIF file.
        Returns:
        the File object pointing to the created temporary file.
        Throws:
        ApplicationException - if something goes wrong.
      • deleteBackend

        public void deleteBackend​(String backendName)
                           throws ApplicationException
        Deletes a backend on the server. It assumes the server is stopped.
        Parameters:
        backendName - the name of the backend to be deleted.
        Throws:
        ApplicationException - if something goes wrong.
      • configureReplication

        public org.opends.quicksetup.installer.ConfiguredReplication configureReplication​(ConnectionWrapper conn,
                                                                                          Map<DN,​Set<HostPort>> replicationServers,
                                                                                          int replicationPort,
                                                                                          boolean useSecureReplication,
                                                                                          Set<Integer> usedReplicationServerIds,
                                                                                          Set<Integer> usedReplicaServerIds)
                                                                                   throws ApplicationException
        Configures the replication on a given server.
        Parameters:
        conn - the connection to the server where we want to configure the replication.
        replicationServers - a Map where the key value is the base dn and the value is the list of replication servers for that base dn (or domain).
        replicationPort - the replicationPort of the server that is being configured (it might not exist and the user specified it in the setup).
        useSecureReplication - whether to encrypt connections with the replication port or not.
        usedReplicationServerIds - the list of replication server ids that are already used.
        usedReplicaServerIds - the list of server ids (domain ids) that are already used by replicas.
        Returns:
        a ConfiguredReplication object describing what has been configured.
        Throws:
        ApplicationException - if something goes wrong.
      • unconfigureReplication

        public void unconfigureReplication​(ConnectionWrapper conn,
                                           org.opends.quicksetup.installer.ConfiguredReplication replConf)
                                    throws ApplicationException
        Configures the replication on a given server.
        Parameters:
        conn - the connection to the server where we want to configure the replication.
        replConf - the object describing what was configured.
        Throws:
        ApplicationException - if something goes wrong.
      • getTaskLogMessages

        public static List<String> getTaskLogMessages​(Entry taskEntry)
        Returns the messages logged by the task described by the provided entry, in the order the server logged them.
        Parameters:
        taskEntry - the entry of the task.
        Returns:
        the messages logged by the task, an empty list if it logged none.
      • getRelevantLogMessage

        public static String getRelevantLogMessage​(List<String> logMsgs)
        Returns the message that best describes the outcome of a task among the messages it logged.

        This is the last message logged with the Severity.ERROR severity when there is one: a task keeps logging after it failed - the task scheduler itself appends a completion notice once the task is over - and those trailing messages hide the cause of the failure. It is the last message logged otherwise.

        Parameters:
        logMsgs - the messages logged by the task, as returned by getTaskLogMessages(Entry).
        Returns:
        the most relevant message, null if the task logged none.
      • isPeersNotFoundError

        public boolean isPeersNotFoundError​(String logMsg)
        Tells whether the provided log message corresponds to a peers not found error during the initialization of a replica or not.

        The message is recognized by the id a task logs it with, which is made of the name of the resource the message belongs to and of its ordinal within that resource.

        Parameters:
        logMsg - the log message, may be null.
        Returns:
        true if the log message corresponds to a peers not found error during initialization, false otherwise.
      • isPeersNotFoundError

        public boolean isPeersNotFoundError​(Collection<String> logMsgs)
        Tells whether one of the provided log messages corresponds to a peers not found error during the initialization of a replica or not.

        All the messages must be tested: the message reporting the failure is neither the first one logged by the task nor, since the task scheduler appends a completion notice, the last one.

        Parameters:
        logMsgs - the log messages of the task, as returned by getTaskLogMessages(Entry).
        Returns:
        true if one of the log messages corresponds to a peers not found error during initialization, false otherwise.
      • getReplicationId

        public static int getReplicationId​(Set<Integer> usedIds)
        Returns the ID to be used for a new replication server or domain.
        Parameters:
        usedIds - the list of already used ids.
        Returns:
        the ID to be used for a new replication server or domain.
      • getDomainName

        public static String getDomainName​(String[] existingDomains,
                                           DN baseDN)
        Returns the name to be used for a new replication domain.
        Parameters:
        existingDomains - the existing domains names.
        baseDN - the base DN of the domain.
        Returns:
        the name to be used for a new replication domain.
      • writeSetOpenDSJavaHome

        public void writeSetOpenDSJavaHome​(UserData uData,
                                           String installPath)
                                    throws IOException
        Writes the set-java-home file that is used by the scripts to set the java home and the java arguments.
        Parameters:
        uData - the data provided by the user.
        installPath - where the server is installed.
        Throws:
        IOException - if an error occurred writing the file.
      • getImportProgressMessage

        public String getImportProgressMessage​(String msg)
        If the log message is of type "[03/Apr/2008:21:25:43 +0200] category=JEB severity=NOTICE msgID=8847454 Processed 1 entries, imported 0, skipped 1, rejected 0 and migrated 0 in 1 seconds (average rate 0.0/sec)" returns the message part. Returns null otherwise.
        Parameters:
        msg - the message to be parsed.
        Returns:
        the parsed import message.