Package com.alibaba.nacos.sys.env
Class EnvUtil
java.lang.Object
com.alibaba.nacos.sys.env.EnvUtil
Its own configuration information manipulation tool class.
- Author:
- liaochuntao
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionanalyzeClusterConf(Reader reader) read file stream to ip list.static booleancontainsProperty(String key) static voidcustomEnvironment.static org.springframework.core.io.Resourcestatic intGet 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 Stringstatic Stringstatic Stringstatic floatgetCpu()static DeploymentTypestatic org.springframework.core.env.ConfigurableEnvironmentstatic Stringserver function mode.static floatgetLoad()static Stringstatic floatgetMem()static Stringstatic Stringstatic Stringstatic intgetPort()static Propertiesstatic StringgetProperty(String key) static <T> TgetProperty(String key, Class<T> targetType) static <T> TgetProperty(String key, Class<T> targetType, T defaultValue) static StringgetProperty(String key, String defaultValue) getPropertyList(String key) static Stringstatic <T> TgetRequiredProperty(String key, Class<T> targetType) static booleanStandalone mode or not.static StringgetSystemEnv(String key) loadProperties(org.springframework.core.io.Resource resource) load resource to map.read cluster.conf to ip list.static StringresolvePlaceholders(String text) static Stringstatic voidsetConfPath(String confPath) static voidsetContextPath(String contextPath) static voidsetDeploymentType(DeploymentType deploymentType) static voidsetEnvironment(org.springframework.core.env.ConfigurableEnvironment environment) static voidsetIsStandalone(Boolean isStandalone) static voidsetLocalAddress(String localAddress) static voidsetNacosHomePath(String nacosHomePath) static voidsetPort(int port) static voidstatic voidwriteClusterConf(String content)
-
Field Details
-
STANDALONE_MODE_ALONE
- See Also:
-
STANDALONE_MODE_CLUSTER
- See Also:
-
FUNCTION_MODE_CONFIG
- See Also:
-
FUNCTION_MODE_NAMING
- See Also:
-
NACOS_HOME_KEY
The key of nacos home.- See Also:
-
-
Constructor Details
-
EnvUtil
public EnvUtil()
-
-
Method Details
-
customEnvironment
public static void customEnvironment()customEnvironment. -
getEnvironment
public static org.springframework.core.env.ConfigurableEnvironment getEnvironment() -
setEnvironment
public static void setEnvironment(org.springframework.core.env.ConfigurableEnvironment environment) -
containsProperty
-
getProperty
-
getProperty
-
getProperty
-
getProperty
-
getRequiredProperty
- Throws:
IllegalStateException
-
getRequiredProperty
public static <T> T getRequiredProperty(String key, Class<T> targetType) throws IllegalStateException - Throws:
IllegalStateException
-
getProperties
-
resolvePlaceholders
-
resolveRequiredPlaceholders
- Throws:
IllegalArgumentException
-
getPropertyList
-
getLocalAddress
-
setLocalAddress
-
systemExit
public static void systemExit() -
getPort
public static int getPort() -
setPort
public static void setPort(int port) -
getContextPath
-
setContextPath
-
setIsStandalone
-
getStandaloneMode
public static boolean getStandaloneMode()Standalone mode or not. -
getFunctionMode
server function mode. -
getNacosTmpDir
-
getNacosHome
-
setNacosHomePath
-
getSystemEnv
-
getLoad
public static float getLoad() -
getCpu
public static float getCpu() -
getMem
public static float getMem() -
getConfPath
-
setConfPath
-
getClusterConfFilePath
-
readClusterConf
read cluster.conf to ip list.- Returns:
- ip list.
- Throws:
IOException- ioexceptionIOException
-
analyzeClusterConf
read file stream to ip list.- Parameters:
reader- reader- Returns:
- ip list.
- Throws:
IOException- IOException
-
writeClusterConf
- Throws:
IOException
-
getMemberList
-
loadProperties
public static Map<String,?> loadProperties(org.springframework.core.io.Resource resource) throws IOException load resource to map.- Parameters:
resource- resource- Returns:
- Map<String, Object>
- Throws:
IOException- IOException
-
getApplicationConfFileResource
public static org.springframework.core.io.Resource getApplicationConfFileResource() -
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().- Returns:
- 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.- Parameters:
multiple- multiple of available processor numbers- Returns:
- 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.- Parameters:
scale- scale from 0 to 1.- Returns:
- available processor numbers from environment, will not lower than 1.
-
getDeploymentType
-
setDeploymentType
-