@InterfaceAudience.Private public interface Constraint extends org.apache.hadoop.conf.Configurable
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
BaseConstraint
,
Constraints
Modifier and Type | Method and Description |
---|---|
void |
check(Put p)
Check a
Put to ensure it is valid for the table. |
void check(Put p) throws ConstraintException
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.p
- Put
to checkConstraintException
- when the Put
does not
match the constraint.Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.