类 FuzzyGroupKeyPattern

java.lang.Object
com.alibaba.nacos.common.utils.FuzzyGroupKeyPattern

public class FuzzyGroupKeyPattern extends Object
Utility class for matching group keys against a given pattern.

This class provides methods to match group keys based on a pattern specified. It supports matching based on dataId, group, and namespace components of the group key.

作者:
stone-98
  • 构造器详细资料

    • FuzzyGroupKeyPattern

      public FuzzyGroupKeyPattern()
  • 方法详细资料

    • generatePattern

      public static String generatePattern(String resourcePattern, String groupPattern, String fixNamespace)
      Generates a fuzzy listen group key pattern based on the given dataId pattern, group, and optional tenant. pattern result as: fixNamespace>>groupPattern>>dataIdPattern
      参数:
      resourcePattern - The pattern for matching dataIds or service names.
      groupPattern - The groupPattern associated with the groups.
      fixNamespace - (Optional) The tenant associated with the dataIds (can be null or empty).
      返回:
      A unique group key pattern for fuzzy listen.
      抛出:
      IllegalArgumentException - If the dataId pattern or group is blank.
    • filterMatchedPatterns

      public static Set<String> filterMatchedPatterns(Collection<String> groupKeyPatterns, String resourceName, String group, String namespace)
      Given a dataId, group, and a collection of completed group key patterns, returns the patterns that match.
      参数:
      resourceName - The dataId or service name to match.
      group - The group to match.
      namespace - The group to match.
      groupKeyPatterns - The collection of completed group key patterns to match against.
      返回:
      A set of patterns that match the dataId and group.
    • matchPattern

      public static boolean matchPattern(String groupKeyPattern, String resourceName, String group, String namespace)
      check if the resource match the groupKeyPattern.
      参数:
      resourceName - The dataId or service name to match.
      group - The group to match.
      namespace - The group to match.
      groupKeyPattern - The pattern to match.
      返回:
      matched or not.
    • getNamespaceFromPattern

      public static String getNamespaceFromPattern(String groupKeyPattern)
    • diffGroupKeys

      public static List<FuzzyGroupKeyPattern.GroupKeyState> diffGroupKeys(Set<String> basedGroupKeys, Set<String> followedGroupKeys)
      Calculates and merges the differences between the matched group keys and the client's existing group keys into a list of ConfigState objects.
      参数:
      basedGroupKeys - The matched group keys set
      followedGroupKeys - The followed existing group keys set
      返回:
      a different list of GroupKeyState objects representing the states which the followed sets should be added or removed GroupKeyState#exist true presents follow set should add,GroupKeyState#exist false presents follow set should removed.