Package org.opends.quicksetup.installer
Class InstallerHelper
- java.lang.Object
-
- org.opends.quicksetup.installer.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 Summary
Constructors Constructor Description InstallerHelper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.opends.quicksetup.installer.ConfiguredReplicationconfigureReplication(ConnectionWrapper conn, Map<DN,Set<HostPort>> replicationServers, int replicationPort, boolean useSecureReplication, Set<Integer> usedReplicationServerIds, Set<Integer> usedReplicaServerIds)Configures the replication on a given server.voidcreateBackend(ConnectionWrapper conn, String backendName, Set<DN> baseDNs, ManagedObjectDefinition<? extends BackendCfgClient,? extends BackendCfg> backendType)Creates a database backend on the server.FilecreateBaseEntryTempFile(String baseDn)Creates a template LDIF file with an entry that has as dn the provided baseDn.voiddeleteBackend(String backendName)Deletes a backend on the server.voiddisableWindowsService()This method disables this server as a Windows service.voidenableWindowsService()This methods enables this server as a Windows service.static StringgetDomainName(String[] existingDomains, DN baseDN)Returns the name to be used for a new replication domain.StringgetImportProgressMessage(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.static StringgetRelevantLogMessage(List<String> logMsgs)Returns the message that best describes the outcome of a task among the messages it logged.static intgetReplicationId(Set<Integer> usedIds)Returns the ID to be used for a new replication server or domain.StringgetStartedId()Returns the LocalizableMessage ID that corresponds to a successfully started server.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.intinvokeConfigureServer(String[] args)Invokes the method ConfigureDS.configMain with the provided parameters.intinvokeImportLDIF(Application application, String[] args)Invokes the import-ldif command-line with the provided parameters.booleanisPeersNotFoundError(String logMsg)Tells whether the provided log message corresponds to a peers not found error during the initialization of a replica or not.booleanisPeersNotFoundError(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.voidunconfigureReplication(ConnectionWrapper conn, org.opends.quicksetup.installer.ConfiguredReplication replConf)Configures the replication on a given server.voidwriteSetOpenDSJavaHome(UserData uData, String installPath)Writes the set-java-home file that is used by the scripts to set the java home and the java arguments.
-
-
-
Method Detail
-
invokeConfigureServer
public int invokeConfigureServer(String[] args) throws ApplicationException
Invokes the method ConfigureDS.configMain with the provided parameters.- Parameters:
args- the arguments to be passed to ConfigureDS.configMain.- Returns:
- the return code of the ConfigureDS.configMain method.
- Throws:
ApplicationException- if something goes wrong.- See Also:
ConfigureDS.configMain(String[], java.io.OutputStream, java.io.OutputStream)
-
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.
-
enableWindowsService
public void enableWindowsService() throws ApplicationExceptionThis methods enables this server as a Windows service.- Throws:
ApplicationException- if something goes wrong.
-
disableWindowsService
public void disableWindowsService() throws ApplicationExceptionThis 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.
-
createBackend
public void createBackend(ConnectionWrapper conn, String backendName, Set<DN> baseDNs, ManagedObjectDefinition<? extends BackendCfgClient,? extends BackendCfg> backendType) throws ApplicationException
Creates a database backend on the server.- Parameters:
conn- the connection to the server.backendName- the name of the backend to be created.baseDNs- the list of base DNs to be defined on the server.backendType- the backend type.- 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.ERRORseverity 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 bygetTaskLogMessages(Entry).- Returns:
- the most relevant message,
nullif 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 benull.- Returns:
trueif the log message corresponds to a peers not found error during initialization,falseotherwise.
-
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 bygetTaskLogMessages(Entry).- Returns:
trueif one of the log messages corresponds to a peers not found error during initialization,falseotherwise.
-
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. Returnsnullotherwise.- Parameters:
msg- the message to be parsed.- Returns:
- the parsed import message.
-
-