Class EnvUtil

java.lang.Object
com.alibaba.nacos.sys.env.EnvUtil

public class EnvUtil extends Object
Its own configuration information manipulation tool class.
Author:
liaochuntao
  • Field Details

  • 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

      public static boolean containsProperty(String key)
    • getProperty

      public static String getProperty(String key)
    • getProperty

      public static String getProperty(String key, String defaultValue)
    • getProperty

      public static <T> T getProperty(String key, Class<T> targetType)
    • getProperty

      public static <T> T getProperty(String key, Class<T> targetType, T defaultValue)
    • getRequiredProperty

      public static String getRequiredProperty(String key) throws IllegalStateException
      Throws:
      IllegalStateException
    • getRequiredProperty

      public static <T> T getRequiredProperty(String key, Class<T> targetType) throws IllegalStateException
      Throws:
      IllegalStateException
    • getProperties

      public static Properties getProperties()
    • resolvePlaceholders

      public static String resolvePlaceholders(String text)
    • resolveRequiredPlaceholders

      public static String resolveRequiredPlaceholders(String text) throws IllegalArgumentException
      Throws:
      IllegalArgumentException
    • getPropertyList

      public static List<String> getPropertyList(String key)
    • getLocalAddress

      public static String getLocalAddress()
    • setLocalAddress

      public static void setLocalAddress(String localAddress)
    • systemExit

      public static void systemExit()
    • getPort

      public static int getPort()
    • setPort

      public static void setPort(int port)
    • getContextPath

      public static String getContextPath()
    • setContextPath

      public static void setContextPath(String contextPath)
    • setIsStandalone

      public static void setIsStandalone(Boolean isStandalone)
    • getStandaloneMode

      public static boolean getStandaloneMode()
      Standalone mode or not.
    • getFunctionMode

      public static String getFunctionMode()
      server function mode.
    • getNacosTmpDir

      public static String getNacosTmpDir()
    • getNacosHome

      public static String getNacosHome()
    • setNacosHomePath

      public static void setNacosHomePath(String nacosHomePath)
    • getSystemEnv

      public static String getSystemEnv(String key)
    • getLoad

      public static float getLoad()
    • getCpu

      public static float getCpu()
    • getMem

      public static float getMem()
    • getConfPath

      public static String getConfPath()
    • setConfPath

      public static void setConfPath(String confPath)
    • getClusterConfFilePath

      public static String getClusterConfFilePath()
    • readClusterConf

      public static List<String> readClusterConf() throws IOException
      read cluster.conf to ip list.
      Returns:
      ip list.
      Throws:
      IOException - ioexception IOException
    • analyzeClusterConf

      public static List<String> analyzeClusterConf(Reader reader) throws IOException
      read file stream to ip list.
      Parameters:
      reader - reader
      Returns:
      ip list.
      Throws:
      IOException - IOException
    • writeClusterConf

      public static void writeClusterConf(String content) throws IOException
      Throws:
      IOException
    • getMemberList

      public static String 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.processors in config/JVM/system, use it. If no setting, use the one time ThreadUtils.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

      public static DeploymentType getDeploymentType()
    • setDeploymentType

      public static void setDeploymentType(DeploymentType deploymentType)