Class Schema

java.lang.Object
org.apache.curator.framework.schema.Schema

public class Schema extends Object
Represents and documents operations allowed for a given path pattern
  • Method Details

    • builder

      public static SchemaBuilder builder(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(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(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(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(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(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, String path, byte[] data, 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(String path, byte[] data, 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 String getName()
    • getRawPath

      public 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 Map<String,String> getMetadata()
    • getPathRegex

      public Pattern getPathRegex()
    • getPath

      public String getPath()
    • getDocumentation

      public String getDocumentation()
    • getSchemaValidator

      public SchemaValidator getSchemaValidator()
    • getEphemeral

      public Schema.Allowance getEphemeral()
    • getSequential

      public Schema.Allowance getSequential()
    • getWatched

      public Schema.Allowance getWatched()
    • canBeDeleted

      public boolean canBeDeleted()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

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

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

      public String toDocumentation()