类 EnvUtil
- java.lang.Object
-
- com.alibaba.nacos.sys.env.EnvUtil
-
public class EnvUtil extends java.lang.ObjectIts own configuration information manipulation tool class.- 作者:
- liaochuntao
-
-
字段概要
字段 修饰符和类型 字段 说明 private static java.lang.StringconfPathprivate static java.lang.StringcontextPathprivate static java.lang.StringCUSTOM_CONFIG_LOCATION_PROPERTYprivate static java.lang.StringDEFAULT_ADDITIONAL_FILEprivate static java.lang.StringDEFAULT_ADDITIONAL_PATHprivate static java.lang.StringDEFAULT_CONFIG_LOCATIONprivate static java.lang.StringDEFAULT_RESOURCE_PATHprivate static intDEFAULT_SERVER_PORTprivate static java.lang.StringDEFAULT_WEB_CONTEXT_PATHprivate static org.springframework.core.env.ConfigurableEnvironmentenvironmentprivate static java.lang.StringFILE_PREFIXstatic java.lang.StringFUNCTION_MODE_CONFIGstatic java.lang.StringFUNCTION_MODE_NAMINGprivate static java.lang.StringfunctionModeTypeprivate static java.lang.BooleanisStandaloneprivate static java.lang.StringlocalAddressprivate static java.lang.StringMEMBER_LIST_PROPERTYprivate static java.lang.StringNACOS_HOME_ADDITIONAL_FILEPATHstatic java.lang.StringNACOS_HOME_KEYThe key of nacos home.private static java.lang.StringNACOS_HOME_PROPERTYprivate static java.lang.StringNACOS_TEMP_DIR_1private static java.lang.StringNACOS_TEMP_DIR_2private static java.lang.StringnacosHomePathprivate static java.lang.StringnacosTmpDirprivate static com.sun.management.OperatingSystemMXBeanOPERATING_SYSTEM_MX_BEANprivate static intportprivate static java.lang.StringSERVER_PORT_PROPERTYstatic java.lang.StringSTANDALONE_MODE_ALONEstatic java.lang.StringSTANDALONE_MODE_CLUSTER
-
构造器概要
构造器 构造器 说明 EnvUtil()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static java.util.List<java.lang.String>analyzeClusterConf(java.io.Reader reader)read file stream to ip list.static booleancontainsProperty(java.lang.String key)static org.springframework.core.io.ResourcegetApplicationConfFileResource()static intgetAvailableProcessors()Get available processor numbers from environment.static intgetAvailableProcessors(double scale)Get a scale of available processor numbers from environment.static intgetAvailableProcessors(int multiple)Get a multiple time of available processor numbers from environment.static java.lang.StringgetClusterConfFilePath()static java.lang.StringgetConfPath()static java.lang.StringgetContextPath()static floatgetCPU()private static org.springframework.core.io.ResourcegetCustomFileResource()private static org.springframework.core.io.ResourcegetDefaultResource()static org.springframework.core.env.ConfigurableEnvironmentgetEnvironment()static java.lang.StringgetFunctionMode()server function mode.static java.util.List<java.lang.String>getIPsBySystemEnv(java.lang.String key)static floatgetLoad()static java.lang.StringgetLocalAddress()static floatgetMem()static java.lang.StringgetMemberList()static java.lang.StringgetNacosHome()static java.lang.StringgetNacosTmpDir()static intgetPort()static java.lang.StringgetProperty(java.lang.String key)static <T> TgetProperty(java.lang.String key, java.lang.Class<T> targetType)static <T> TgetProperty(java.lang.String key, java.lang.Class<T> targetType, T defaultValue)static java.lang.StringgetProperty(java.lang.String key, java.lang.String defaultValue)static java.util.List<java.lang.String>getPropertyList(java.lang.String key)private static org.springframework.core.io.ResourcegetRelativePathResource(java.lang.String parentPath, java.lang.String path)static java.lang.StringgetRequiredProperty(java.lang.String key)static <T> TgetRequiredProperty(java.lang.String key, java.lang.Class<T> targetType)static booleangetStandaloneMode()Standalone mode or not.static java.lang.StringgetSystemEnv(java.lang.String key)static java.util.Map<java.lang.String,?>loadProperties(org.springframework.core.io.Resource resource)load resource to map.static java.util.List<java.lang.String>readClusterConf()read cluster.conf to ip list.static java.lang.StringresolvePlaceholders(java.lang.String text)static java.lang.StringresolveRequiredPlaceholders(java.lang.String text)static voidsetConfPath(java.lang.String confPath)static voidsetContextPath(java.lang.String contextPath)static voidsetEnvironment(org.springframework.core.env.ConfigurableEnvironment environment)static voidsetIsStandalone(java.lang.Boolean isStandalone)static voidsetLocalAddress(java.lang.String localAddress)static voidsetNacosHomePath(java.lang.String nacosHomePath)static voidsetPort(int port)static voidwriteClusterConf(java.lang.String content)
-
-
-
字段详细资料
-
STANDALONE_MODE_ALONE
public static final java.lang.String STANDALONE_MODE_ALONE
- 另请参阅:
- 常量字段值
-
STANDALONE_MODE_CLUSTER
public static final java.lang.String STANDALONE_MODE_CLUSTER
- 另请参阅:
- 常量字段值
-
FUNCTION_MODE_CONFIG
public static final java.lang.String FUNCTION_MODE_CONFIG
- 另请参阅:
- 常量字段值
-
FUNCTION_MODE_NAMING
public static final java.lang.String FUNCTION_MODE_NAMING
- 另请参阅:
- 常量字段值
-
NACOS_HOME_KEY
public static final java.lang.String NACOS_HOME_KEY
The key of nacos home.- 另请参阅:
- 常量字段值
-
localAddress
private static java.lang.String localAddress
-
port
private static int port
-
isStandalone
private static java.lang.Boolean isStandalone
-
functionModeType
private static java.lang.String functionModeType
-
contextPath
private static java.lang.String contextPath
-
FILE_PREFIX
private static final java.lang.String FILE_PREFIX
- 另请参阅:
- 常量字段值
-
SERVER_PORT_PROPERTY
private static final java.lang.String SERVER_PORT_PROPERTY
- 另请参阅:
- 常量字段值
-
DEFAULT_SERVER_PORT
private static final int DEFAULT_SERVER_PORT
- 另请参阅:
- 常量字段值
-
DEFAULT_WEB_CONTEXT_PATH
private static final java.lang.String DEFAULT_WEB_CONTEXT_PATH
- 另请参阅:
- 常量字段值
-
MEMBER_LIST_PROPERTY
private static final java.lang.String MEMBER_LIST_PROPERTY
- 另请参阅:
- 常量字段值
-
NACOS_HOME_PROPERTY
private static final java.lang.String NACOS_HOME_PROPERTY
- 另请参阅:
- 常量字段值
-
CUSTOM_CONFIG_LOCATION_PROPERTY
private static final java.lang.String CUSTOM_CONFIG_LOCATION_PROPERTY
- 另请参阅:
- 常量字段值
-
DEFAULT_CONFIG_LOCATION
private static final java.lang.String DEFAULT_CONFIG_LOCATION
- 另请参阅:
- 常量字段值
-
DEFAULT_RESOURCE_PATH
private static final java.lang.String DEFAULT_RESOURCE_PATH
- 另请参阅:
- 常量字段值
-
DEFAULT_ADDITIONAL_PATH
private static final java.lang.String DEFAULT_ADDITIONAL_PATH
- 另请参阅:
- 常量字段值
-
DEFAULT_ADDITIONAL_FILE
private static final java.lang.String DEFAULT_ADDITIONAL_FILE
- 另请参阅:
- 常量字段值
-
NACOS_HOME_ADDITIONAL_FILEPATH
private static final java.lang.String NACOS_HOME_ADDITIONAL_FILEPATH
- 另请参阅:
- 常量字段值
-
NACOS_TEMP_DIR_1
private static final java.lang.String NACOS_TEMP_DIR_1
- 另请参阅:
- 常量字段值
-
NACOS_TEMP_DIR_2
private static final java.lang.String NACOS_TEMP_DIR_2
- 另请参阅:
- 常量字段值
-
confPath
private static java.lang.String confPath
-
nacosHomePath
private static java.lang.String nacosHomePath
-
OPERATING_SYSTEM_MX_BEAN
private static final com.sun.management.OperatingSystemMXBean OPERATING_SYSTEM_MX_BEAN
-
environment
private static org.springframework.core.env.ConfigurableEnvironment environment
-
nacosTmpDir
private static java.lang.String nacosTmpDir
-
-
方法详细资料
-
getEnvironment
public static org.springframework.core.env.ConfigurableEnvironment getEnvironment()
-
setEnvironment
public static void setEnvironment(org.springframework.core.env.ConfigurableEnvironment environment)
-
containsProperty
public static boolean containsProperty(java.lang.String key)
-
getProperty
public static java.lang.String getProperty(java.lang.String key)
-
getProperty
public static java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
-
getProperty
public static <T> T getProperty(java.lang.String key, java.lang.Class<T> targetType)
-
getProperty
public static <T> T getProperty(java.lang.String key, java.lang.Class<T> targetType, T defaultValue)
-
getRequiredProperty
public static java.lang.String getRequiredProperty(java.lang.String key) throws java.lang.IllegalStateException- 抛出:
java.lang.IllegalStateException
-
getRequiredProperty
public static <T> T getRequiredProperty(java.lang.String key, java.lang.Class<T> targetType) throws java.lang.IllegalStateException- 抛出:
java.lang.IllegalStateException
-
resolvePlaceholders
public static java.lang.String resolvePlaceholders(java.lang.String text)
-
resolveRequiredPlaceholders
public static java.lang.String resolveRequiredPlaceholders(java.lang.String text) throws java.lang.IllegalArgumentException- 抛出:
java.lang.IllegalArgumentException
-
getPropertyList
public static java.util.List<java.lang.String> getPropertyList(java.lang.String key)
-
getLocalAddress
public static java.lang.String getLocalAddress()
-
setLocalAddress
public static void setLocalAddress(java.lang.String localAddress)
-
getPort
public static int getPort()
-
setPort
public static void setPort(int port)
-
getContextPath
public static java.lang.String getContextPath()
-
setContextPath
public static void setContextPath(java.lang.String contextPath)
-
setIsStandalone
public static void setIsStandalone(java.lang.Boolean isStandalone)
-
getStandaloneMode
public static boolean getStandaloneMode()
Standalone mode or not.
-
getFunctionMode
public static java.lang.String getFunctionMode()
server function mode.
-
getNacosTmpDir
public static java.lang.String getNacosTmpDir()
-
getNacosHome
public static java.lang.String getNacosHome()
-
setNacosHomePath
public static void setNacosHomePath(java.lang.String nacosHomePath)
-
getIPsBySystemEnv
public static java.util.List<java.lang.String> getIPsBySystemEnv(java.lang.String key)
-
getSystemEnv
public static java.lang.String getSystemEnv(java.lang.String key)
-
getLoad
public static float getLoad()
-
getCPU
public static float getCPU()
-
getMem
public static float getMem()
-
getConfPath
public static java.lang.String getConfPath()
-
setConfPath
public static void setConfPath(java.lang.String confPath)
-
getClusterConfFilePath
public static java.lang.String getClusterConfFilePath()
-
readClusterConf
public static java.util.List<java.lang.String> readClusterConf() throws java.io.IOExceptionread cluster.conf to ip list.- 返回:
- ip list.
- 抛出:
java.io.IOException- ioexceptionIOException
-
analyzeClusterConf
public static java.util.List<java.lang.String> analyzeClusterConf(java.io.Reader reader) throws java.io.IOExceptionread file stream to ip list.- 参数:
reader- reader- 返回:
- ip list.
- 抛出:
java.io.IOException- IOException
-
writeClusterConf
public static void writeClusterConf(java.lang.String content) throws java.io.IOException- 抛出:
java.io.IOException
-
getMemberList
public static java.lang.String getMemberList()
-
loadProperties
public static java.util.Map<java.lang.String,?> loadProperties(org.springframework.core.io.Resource resource) throws java.io.IOExceptionload resource to map.- 参数:
resource- resource- 返回:
- Map<String, Object>
- 抛出:
java.io.IOException- IOException
-
getApplicationConfFileResource
public static org.springframework.core.io.Resource getApplicationConfFileResource()
-
getCustomFileResource
private static org.springframework.core.io.Resource getCustomFileResource()
-
getRelativePathResource
private static org.springframework.core.io.Resource getRelativePathResource(java.lang.String parentPath, java.lang.String path)
-
getDefaultResource
private static org.springframework.core.io.Resource getDefaultResource()
-
getAvailableProcessors
public static int getAvailableProcessors()
Get available processor numbers from environment.If there are setting of
nacos.core.sys.basic.processorsin config/JVM/system, use it. If no setting, use the one timeThreadUtils.getSuitableThreadCount().- 返回:
- available processor numbers from environment, will not lower than 1.
-
getAvailableProcessors
public static int getAvailableProcessors(int multiple)
Get a multiple time of available processor numbers from environment.- 参数:
multiple- multiple of available processor numbers- 返回:
- available processor numbers from environment, will not lower than 1.
-
getAvailableProcessors
public static int getAvailableProcessors(double scale)
Get a scale of available processor numbers from environment.- 参数:
scale- scale from 0 to 1.- 返回:
- available processor numbers from environment, will not lower than 1.
-
-