在阅读flume源码的时候发下如下函数:
private static void initSysPropFromEnvVar(String sysPropName, String envVarName,
String description) {
if (System.getProperty(sysPropName) != null) {
LOGGER.debug("Global SSL " + description + " has been initialized from system property.");
} else {
String envVarValue = System.getenv(envVarName);
if (envVarValue != null) {
System.setProperty(sysPropName, envVarValue);
LOGGER.debug("Global SSL " + description +
" has been initialized from environment variable.");
} else {
LOGGER.debug("No global SSL " + description + " specified.");
}
}
}
其中System.getenv()
& System.getProperty()
这两个函数不是很理解,google一下发下两个函数的区别:
getenv
gets an environment variable. getProperty
gets a Java property. Environment variables are specified at the OS level. Java properties are specified by passing the -D
option to the JVM (and can be set programmatically).