Interface Constraint
- All Superinterfaces:
org.apache.hadoop.conf.Configurable
- All Known Implementing Classes:
BaseConstraint
Apply a
Constraint
(in traditional database terminology) to a Table. 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.client.TableDescriptorBuilder, Class...)
or
Constraints.add(org.apache.hadoop.hbase.client.TableDescriptorBuilder, 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.client.TableDescriptorBuilder, Class)
and
Constraints.disableConstraint(org.apache.hadoop.hbase.client.TableDescriptorBuilder, 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
Methods inherited from interface org.apache.hadoop.conf.Configurable
getConf, setConf
-
Method Details
-
check
Check aPut
to ensure it is valid for the table. If thePut
is valid, then just return from the method. Otherwise, throw anException
specifying what happened. ThisException
is propagated back to the client so you can see what caused thePut
to fail.- Parameters:
p
-Put
to check- Throws:
ConstraintException
- when thePut
does not match the constraint.
-