Class Schema


  • public class Schema
    extends java.lang.Object
    Represents and documents operations allowed for a given path pattern
    • Method Detail

      • builder

        public static SchemaBuilder builder​(java.lang.String path)
        Start a builder for the given full path. Note: full path schemas take precedence over regex path schemas.
        Parameters:
        path - full ZNode path. This schema only applies to an exact match
        Returns:
        builder
      • builder

        public static SchemaBuilder builder​(java.util.regex.Pattern pathRegex)
        Start a builder for the given path pattern.
        Parameters:
        pathRegex - regex for the path. This schema applies to any matching paths
        Returns:
        builder
      • builderForRecipeParent

        public static SchemaBuilder builderForRecipeParent​(java.lang.String parentPath)
        Start a schema builder for a typical Curator recipe's parent node
        Parameters:
        parentPath - Path to the parent node
        Returns:
        builder
      • builderForRecipe

        public static SchemaBuilder builderForRecipe​(java.lang.String parentPath)
        Start a schema builder for a typical Curator recipe's children
        Parameters:
        parentPath - Path to the parent node
        Returns:
        builder
      • validateDelete

        public void validateDelete​(java.lang.String path)
        Validate that this schema allows znode deletion
        Parameters:
        path - the znode full path
        Throws:
        SchemaViolation - if schema does not allow znode deletion
      • validateWatch

        public void validateWatch​(java.lang.String path,
                                  boolean isWatching)
        Validate that this schema's watching setting matches
        Parameters:
        path - the znode full path
        isWatching - true if attempt is being made to watch node
        Throws:
        SchemaViolation - if schema's watching setting does not match
      • validateCreate

        public void validateCreate​(org.apache.zookeeper.CreateMode mode,
                                   java.lang.String path,
                                   byte[] data,
                                   java.util.List<org.apache.zookeeper.data.ACL> acl)
        Validate that this schema's create mode setting matches and that the data is valid
        Parameters:
        mode - CreateMode being used
        path - the znode full path
        data - data being set
        acl - the creation acls
        Throws:
        SchemaViolation - if schema's create mode setting does not match or data is invalid
      • validateGeneral

        public void validateGeneral​(java.lang.String path,
                                    byte[] data,
                                    java.util.List<org.apache.zookeeper.data.ACL> acl)
        Validate that this schema validates the data
        Parameters:
        path - the znode full path
        data - data being set
        acl - if creating, the acls otherwise null or empty list
        Throws:
        SchemaViolation - if data is invalid
      • getName

        public java.lang.String getName()
      • getRawPath

        public java.lang.String getRawPath()
        Return the raw path for this schema. If a full path was used, it is returned. If a regex was used, it is returned
        Returns:
        path
      • getMetadata

        public java.util.Map<java.lang.String,​java.lang.String> getMetadata()
      • getPathRegex

        public java.util.regex.Pattern getPathRegex()
      • getPath

        public java.lang.String getPath()
      • getDocumentation

        public java.lang.String getDocumentation()
      • canBeDeleted

        public boolean canBeDeleted()
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toDocumentation

        public java.lang.String toDocumentation()