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 int
ADDRESS_PING_TIMEOUT_MS
protected static Path
BAD_INSTANCE_CLID_PATH
protected static String[]
COMPLIANT_JAVA_VERSIONS
protected static String
DEFAULT_CONTEXT_NAME
protected static String
JVMCHECK_FAIL
protected static String
JVMCHECK_NOFAIL
protected static String
JVMCHECK_PROP
protected static int
MAX_PORT
protected static int
MIN_PORT
protected static int
PARAM_POLICY_DEFAULT_DELAY_IN_MS
protected static int
PARAM_RETRY_POLICY_DEFAULT_RETRIES
protected static String
PARAM_RETRY_POLICY_DELAY_IN_MS
protected static String
PARAM_RETRY_POLICY_ENABLED
protected static String
PARAM_RETRY_POLICY_MAX_RETRIES
protected Properties
systemProperties
-
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.RetryPolicy
buildRetryPolicy(ConfigurationHolder configHolder)
protected void
checkAddressesAndPorts(ConfigurationHolder configHolder)
Will check the configured addresses are reachable and Nuxeo required ports are available on those addresses.protected void
checkAddressReachable(InetAddress address)
void
checkBackingServices(ConfigurationHolder configHolder)
Calls allBackingChecker
if they accept the current configuration.static void
checkJavaVersion()
Checks that the process is executed with a supported Java version.static boolean
checkJavaVersion(String version, String requiredVersion)
Checks the java version compared to the required one.protected void
checkJavaVersion(String version, String[] compliantVersions)
Checks the given java version compared to the given compliant ones.protected boolean
checkJavaVersion(String version, String requiredVersion, boolean allowNoFailFlag, boolean warnIfLooseCompliance)
Checks the java version compared to the required one.protected void
checkJavaVersionIsCompliant()
Checks the java version present in system properties compared to compliant ones.protected void
checkPaths(ConfigurationHolder configHolder)
Checks server paths; warn if deprecated paths exist.protected void
checkPortAvailable(InetAddress address, int port)
Checks if port is available on given address.protected URL
convertToJarFileURL(Path path)
protected URLClassLoader
getBackingCheckerClassLoader(ConfigurationHolder configHolder, String checker)
Build a ClassLoader based on the classpath definition of a template.protected String
getBackingCheckerClasspath(ConfigurationHolder configHolder, String template)
Read the classpath parameter from the template and expand parameters with their value.protected InetAddress
getBindAddress(ConfigurationHolder configHolder)
Checks the userConfig bind address is not 0.0.0.0 and replaces it with 127.0.0.1 if neededprotected String
getContextName(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)
boolean
isConfigured(ConfigurationHolder configHolder)
void
verify(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 ConfigurationException
Checks 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
- iftrue
then check jvmcheck=nofail flag to always have loose compliancewarnIfLooseCompliance
- iftrue
then 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 allBackingChecker
if 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 ConfigurationException
Checks 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
-
-