类 NamingUtils


  • public class NamingUtils
    extends java.lang.Object
    NamingUtils.
    从以下版本开始:
    1.0.0
    作者:
    nkorange
    • 字段概要

      字段 
      修饰符和类型 字段 说明
      private static java.util.regex.Pattern CLUSTER_NAME_PATTERN  
      private static java.util.regex.Pattern NUMBER_PATTERN  
    • 构造器概要

      构造器 
      构造器 说明
      NamingUtils()  
    • 方法概要

      所有方法 静态方法 具体方法 
      修饰符和类型 方法 说明
      static void batchCheckInstanceIsLegal​(java.util.List<Instance> instances)
      Batch verify the validity of instances.
      static void checkInstanceIsEphemeral​(Instance instance)
      check batch register is Ephemeral.
      static void checkInstanceIsLegal​(Instance instance)
      Check instance param about keep alive.
      static void checkServiceNameFormat​(java.lang.String combineServiceName)
      check combineServiceName format. the serviceName can't be blank.
      static java.lang.String getGroupedName​(java.lang.String serviceName, java.lang.String groupName)
      Returns a combined string with serviceName and groupName. serviceName can not be nil.
      static java.lang.String getGroupedNameOptional​(java.lang.String serviceName, java.lang.String groupName)
      Returns a combined string with serviceName and groupName.
      static java.lang.String getGroupName​(java.lang.String serviceNameWithGroup)  
      static java.lang.String getServiceName​(java.lang.String serviceNameWithGroup)  
      static boolean isNumber​(java.lang.String str)
      Check string is a number or not.
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 字段详细资料

      • CLUSTER_NAME_PATTERN

        private static final java.util.regex.Pattern CLUSTER_NAME_PATTERN
      • NUMBER_PATTERN

        private static final java.util.regex.Pattern NUMBER_PATTERN
    • 构造器详细资料

      • NamingUtils

        public NamingUtils()
    • 方法详细资料

      • getGroupedName

        public static java.lang.String getGroupedName​(java.lang.String serviceName,
                                                      java.lang.String groupName)
        Returns a combined string with serviceName and groupName. serviceName can not be nil.

        In most cases, serviceName can not be nil. In other cases, for search or anything, See getGroupedNameOptional(String, String)

        etc:

        serviceName | groupName | result

        serviceA | groupA | groupA@@serviceA

        nil | groupA | threw IllegalArgumentException

        返回:
        'groupName@@serviceName'
      • getServiceName

        public static java.lang.String getServiceName​(java.lang.String serviceNameWithGroup)
      • getGroupName

        public static java.lang.String getGroupName​(java.lang.String serviceNameWithGroup)
      • checkServiceNameFormat

        public static void checkServiceNameFormat​(java.lang.String combineServiceName)
        check combineServiceName format. the serviceName can't be blank.
         serviceName = "@@";                 the length = 0; illegal
         serviceName = "group@@";            the length = 1; illegal
         serviceName = "@@serviceName";      the length = 2; illegal
         serviceName = "group@@serviceName"; the length = 2; legal
         
        参数:
        combineServiceName - such as: groupName@@serviceName
      • getGroupedNameOptional

        public static java.lang.String getGroupedNameOptional​(java.lang.String serviceName,
                                                              java.lang.String groupName)
        Returns a combined string with serviceName and groupName. Such as 'groupName@@serviceName'

        This method works similar with getGroupedName(java.lang.String, java.lang.String) But not verify any parameters.

        etc:

        serviceName | groupName | result

        serviceA | groupA | groupA@@serviceA

        nil | groupA | groupA@@

        nil | nil | @@

        返回:
        'groupName@@serviceName'
      • checkInstanceIsLegal

        public static void checkInstanceIsLegal​(Instance instance)
                                         throws NacosException

        Check instance param about keep alive.

         heart beat timeout must > heart beat interval
         ip delete timeout must  > heart beat interval
         
        参数:
        instance - need checked instance
        抛出:
        NacosException - if check failed, throw exception
      • checkInstanceIsEphemeral

        public static void checkInstanceIsEphemeral​(Instance instance)
                                             throws NacosException
        check batch register is Ephemeral.
        参数:
        instance - instance
        抛出:
        NacosException - NacosException
      • batchCheckInstanceIsLegal

        public static void batchCheckInstanceIsLegal​(java.util.List<Instance> instances)
                                              throws NacosException
        Batch verify the validity of instances.
        参数:
        instances - List of instances to be registered
        抛出:
        NacosException - Nacos
      • isNumber

        public static boolean isNumber​(java.lang.String str)
        Check string is a number or not.
        参数:
        str - a string of digits
        返回:
        if it is a string of digits, return true