Package org.nuxeo.launcher.config
Class ConfigurationChecker
- java.lang.Object
-
- org.nuxeo.launcher.config.ConfigurationChecker
-
public class ConfigurationChecker extends Object
- Since:
- 11.5
-
-
Field Summary
Fields Modifier and Type Field Description protected static intADDRESS_PING_TIMEOUT_MSprotected static PathBAD_INSTANCE_CLID_PATHprotected static String[]COMPLIANT_JAVA_VERSIONSprotected static StringDEFAULT_CONTEXT_NAMEprotected static StringJVMCHECK_FAILprotected static StringJVMCHECK_NOFAILprotected static StringJVMCHECK_PROPprotected static intMAX_PORTprotected static intMIN_PORTprotected static intPARAM_POLICY_DEFAULT_DELAY_IN_MSprotected static intPARAM_RETRY_POLICY_DEFAULT_RETRIESprotected static StringPARAM_RETRY_POLICY_DELAY_IN_MSprotected static StringPARAM_RETRY_POLICY_ENABLEDprotected static StringPARAM_RETRY_POLICY_MAX_RETRIESprotected PropertiessystemProperties
-
Constructor Summary
Constructors Constructor Description ConfigurationChecker(Properties systemProperties)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected net.jodah.failsafe.RetryPolicybuildRetryPolicy(ConfigurationHolder configHolder)protected voidcheckAddressesAndPorts(ConfigurationHolder configHolder)Will check the configured addresses are reachable and Nuxeo required ports are available on those addresses.protected voidcheckAddressReachable(InetAddress address)voidcheckBackingServices(ConfigurationHolder configHolder)Calls allBackingCheckerif they accept the current configuration.static voidcheckJavaVersion()Checks that the process is executed with a supported Java version.static booleancheckJavaVersion(String version, String requiredVersion)Checks the java version compared to the required one.protected voidcheckJavaVersion(String version, String[] compliantVersions)Checks the given java version compared to the given compliant ones.protected booleancheckJavaVersion(String version, String requiredVersion, boolean allowNoFailFlag, boolean warnIfLooseCompliance)Checks the java version compared to the required one.protected voidcheckJavaVersionIsCompliant()Checks the java version present in system properties compared to compliant ones.protected voidcheckPaths(ConfigurationHolder configHolder)Checks server paths; warn if deprecated paths exist.protected voidcheckPortAvailable(InetAddress address, int port)Checks if port is available on given address.protected URLconvertToJarFileURL(Path path)protected URLClassLoadergetBackingCheckerClassLoader(ConfigurationHolder configHolder, String checker)Build a ClassLoader based on the classpath definition of a template.protected StringgetBackingCheckerClasspath(ConfigurationHolder configHolder, String template)Read the classpath parameter from the template and expand parameters with their value.protected InetAddressgetBindAddress(ConfigurationHolder configHolder)Checks the userConfig bind address is not 0.0.0.0 and replaces it with 127.0.0.1 if neededprotected StringgetContextName(ConfigurationHolder configHolder)protected Stream<Path>getJarsFromClasspathEntry(ConfigurationHolder configHolder, Path templatePath, String entry)Given a single classpath entry, return the list of JARs referenced by it.
For instance : nxserver/lib -> ${templatePath}/nxserver/lib /somePath/someLib-*.jarprotected List<BackingChecker>instantiateBackingCheckers(ConfigurationHolder configHolder)booleanisConfigured(ConfigurationHolder configHolder)voidverify(ConfigurationHolder configHolder)Verifies that the server is well configured and ready to be started.
-
-
-
Field Detail
-
PARAM_RETRY_POLICY_ENABLED
protected static final String PARAM_RETRY_POLICY_ENABLED
- See Also:
- Constant Field Values
-
PARAM_RETRY_POLICY_MAX_RETRIES
protected static final String PARAM_RETRY_POLICY_MAX_RETRIES
- See Also:
- Constant Field Values
-
PARAM_RETRY_POLICY_DELAY_IN_MS
protected static final String PARAM_RETRY_POLICY_DELAY_IN_MS
- See Also:
- Constant Field Values
-
PARAM_POLICY_DEFAULT_DELAY_IN_MS
protected static final int PARAM_POLICY_DEFAULT_DELAY_IN_MS
- See Also:
- Constant Field Values
-
PARAM_RETRY_POLICY_DEFAULT_RETRIES
protected static final int PARAM_RETRY_POLICY_DEFAULT_RETRIES
- See Also:
- Constant Field Values
-
DEFAULT_CONTEXT_NAME
protected static final String DEFAULT_CONTEXT_NAME
- See Also:
- Constant Field Values
-
COMPLIANT_JAVA_VERSIONS
protected static final String[] COMPLIANT_JAVA_VERSIONS
-
JVMCHECK_PROP
protected static final String JVMCHECK_PROP
- See Also:
- Constant Field Values
-
JVMCHECK_FAIL
protected static final String JVMCHECK_FAIL
- See Also:
- Constant Field Values
-
JVMCHECK_NOFAIL
protected static final String JVMCHECK_NOFAIL
- See Also:
- Constant Field Values
-
ADDRESS_PING_TIMEOUT_MS
protected static final int ADDRESS_PING_TIMEOUT_MS
- See Also:
- Constant Field Values
-
MIN_PORT
protected static final int MIN_PORT
- See Also:
- Constant Field Values
-
MAX_PORT
protected static final int MAX_PORT
- See Also:
- Constant Field Values
-
BAD_INSTANCE_CLID_PATH
protected static final Path BAD_INSTANCE_CLID_PATH
-
systemProperties
protected final Properties systemProperties
-
-
Constructor Detail
-
ConfigurationChecker
public ConfigurationChecker(Properties systemProperties)
-
-
Method Detail
-
isConfigured
public boolean isConfigured(ConfigurationHolder configHolder)
- Returns:
- true if server configuration files already exist
-
getContextName
protected String getContextName(ConfigurationHolder configHolder)
-
verify
public void verify(ConfigurationHolder configHolder) throws ConfigurationException
Verifies that the server is well configured and ready to be started.- Throws:
ConfigurationException
-
checkJavaVersionIsCompliant
protected void checkJavaVersionIsCompliant() throws ConfigurationExceptionChecks the java version present in system properties compared to compliant ones.- Throws:
ConfigurationException
-
checkJavaVersion
protected void checkJavaVersion(String version, String[] compliantVersions) throws ConfigurationException
Checks the given java version compared to the given compliant ones.- Parameters:
version- the java versioncompliantVersions- the compliant java versions- Throws:
ConfigurationException
-
checkJavaVersion
protected boolean checkJavaVersion(String version, String requiredVersion, boolean allowNoFailFlag, boolean warnIfLooseCompliance)
Checks the java version compared to the required one.Loose compliance is assumed if the major version is greater than the required major version or a jvmcheck=nofail flag is set.
- Parameters:
version- the java versionrequiredVersion- the required java versionallowNoFailFlag- iftruethen check jvmcheck=nofail flag to always have loose compliancewarnIfLooseCompliance- iftruethen log a WARN if the is loose compliance- Returns:
- true if the java version is compliant (maybe loosely) with the required version
-
checkAddressesAndPorts
protected void checkAddressesAndPorts(ConfigurationHolder configHolder) throws ConfigurationException
Will check the configured addresses are reachable and Nuxeo required ports are available on those addresses.- Throws:
ConfigurationException
-
getBindAddress
protected InetAddress getBindAddress(ConfigurationHolder configHolder) throws ConfigurationException
Checks the userConfig bind address is not 0.0.0.0 and replaces it with 127.0.0.1 if needed- Parameters:
configHolder- The configuration holding theConfigurationConstants.PARAM_BIND_ADDRESS- Returns:
- the userConfig bind address if not 0.0.0.0 else 127.0.0.1
- Throws:
ConfigurationException
-
checkAddressReachable
protected void checkAddressReachable(InetAddress address) throws ConfigurationException
- Parameters:
address- address to check for availability- Throws:
ConfigurationException
-
checkPortAvailable
protected void checkPortAvailable(InetAddress address, int port) throws ConfigurationException
Checks if port is available on given address.- Parameters:
port- port to check for availability- Throws:
ConfigurationException- Throws an exception if address is unavailable.
-
checkPaths
protected void checkPaths(ConfigurationHolder configHolder) throws ConfigurationException
Checks server paths; warn if deprecated paths exist.- Throws:
ConfigurationException
-
checkBackingServices
public void checkBackingServices(ConfigurationHolder configHolder) throws ConfigurationException
Calls allBackingCheckerif they accept the current configuration.- Throws:
ConfigurationException
-
buildRetryPolicy
protected net.jodah.failsafe.RetryPolicy buildRetryPolicy(ConfigurationHolder configHolder)
-
instantiateBackingCheckers
protected List<BackingChecker> instantiateBackingCheckers(ConfigurationHolder configHolder) throws ConfigurationException
- Throws:
ConfigurationException
-
getBackingCheckerClassLoader
protected URLClassLoader getBackingCheckerClassLoader(ConfigurationHolder configHolder, String checker)
Build a ClassLoader based on the classpath definition of a template.
-
getBackingCheckerClasspath
protected String getBackingCheckerClasspath(ConfigurationHolder configHolder, String template)
Read the classpath parameter from the template and expand parameters with their value. It allows classpath of the form ${nuxeo.home}/nxserver/bundles/...
-
getJarsFromClasspathEntry
protected Stream<Path> getJarsFromClasspathEntry(ConfigurationHolder configHolder, Path templatePath, String entry)
Given a single classpath entry, return the list of JARs referenced by it.
For instance :- nxserver/lib -> ${templatePath}/nxserver/lib
- /somePath/someLib-*.jar
-
checkJavaVersion
public static void checkJavaVersion() throws ConfigurationExceptionChecks that the process is executed with a supported Java version. See J2SE SDK/JRE Version String Naming Convention- Throws:
ConfigurationException
-
checkJavaVersion
public static boolean checkJavaVersion(String version, String requiredVersion)
Checks the java version compared to the required one.If major version is same as required major version and minor is greater or equal, it is compliant.
If major version is greater than required major version, it is compliant.
- Parameters:
version- the java versionrequiredVersion- the required java version- Returns:
- true if the java version is compliant with the required version
-
-