Interface Constraint

All Superinterfaces:
org.apache.hadoop.conf.Configurable
All Known Implementing Classes:
BaseConstraint

@Private public interface Constraint extends org.apache.hadoop.conf.Configurable
Apply a Constraint (in traditional database terminology) to a HTable. Any number of Constraints can be added to the table, in any order.

A Constraint must be added to a table before the table is loaded via Constraints.add(org.apache.hadoop.hbase.HTableDescriptor, Class[]) or Constraints.add(org.apache.hadoop.hbase.HTableDescriptor, org.apache.hadoop.hbase.util.Pair...) (if you want to add a configuration with the Constraint). Constraints will be run in the order that they are added. Further, a Constraint will be configured before it is run (on load).

See Constraints.enableConstraint(org.apache.hadoop.hbase.HTableDescriptor, Class) and Constraints.disableConstraint(org.apache.hadoop.hbase.HTableDescriptor, Class) for enabling/disabling of a given Constraint after it has been added.

If a Put is invalid, the Constraint should throw some sort of ConstraintException, indicating that the Put has failed. When this exception is thrown, not further retries of the Put are attempted nor are any other Constraints attempted (the Put is clearly not valid). Therefore, there are performance implications in the order in which Constraints are specified.

If a Constraint fails to fail the Put via a ConstraintException, but instead throws a RuntimeException, the entire constraint processing mechanism (ConstraintProcessor) will be unloaded from the table. This ensures that the region server is still functional, but no more Puts will be checked via Constraints.

Further, Constraints should probably not be used to enforce cross-table references as it will cause tremendous write slowdowns, but it is possible.

NOTE: Implementing classes must have a nullary (no-args) constructor

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Check a Put to ensure it is valid for the table.

    Methods inherited from interface org.apache.hadoop.conf.Configurable

    getConf, setConf
  • Method Details

    • check

      void check(Put p) throws ConstraintException
      Check a Put to ensure it is valid for the table. If the Put is valid, then just return from the method. Otherwise, throw an Exception specifying what happened. This Exception is propagated back to the client so you can see what caused the Put to fail.
      Parameters:
      p - Put to check
      Throws:
      ConstraintException - when the Put does not match the constraint.