org.apache.hadoop.hbase.constraint
Class Constraints

java.lang.Object
  extended by org.apache.hadoop.hbase.constraint.Constraints

@InterfaceAudience.Private
public final class Constraints
extends Object

Utilities for adding/removing constraints from a table.

Constraints can be added on table load time, via the HTableDescriptor.

NOTE: this class is NOT thread safe. Concurrent setting/enabling/disabling of constraints can cause constraints to be run at incorrect times or not at all.


Method Summary
static void add(HTableDescriptor desc, Class<? extends Constraint>... constraints)
          Add configuration-less constraints to the table.
static void add(HTableDescriptor desc, Class<? extends Constraint> constraint, org.apache.hadoop.conf.Configuration conf)
          Add a Constraint to the table with the given configuration
static void add(HTableDescriptor desc, Pair<Class<? extends Constraint>,org.apache.hadoop.conf.Configuration>... constraints)
          Add constraints and their associated configurations to the table.
static void disable(HTableDescriptor desc)
          Turn off processing constraints for a given table, even if constraints have been turned on or added.
static void disableConstraint(HTableDescriptor desc, Class<? extends Constraint> clazz)
          Disable the given Constraint.
static void enable(HTableDescriptor desc)
          Enable constraints on a table.
static void enableConstraint(HTableDescriptor desc, Class<? extends Constraint> clazz)
          Enable the given Constraint.
static boolean enabled(HTableDescriptor desc, Class<? extends Constraint> clazz)
          Check to see if the given constraint is enabled.
static boolean has(HTableDescriptor desc, Class<? extends Constraint> clazz)
          Check to see if the Constraint is currently set.
static void remove(HTableDescriptor desc)
          Remove all Constraints that have been added to the table and turn off the constraint processing.
static void remove(HTableDescriptor desc, Class<? extends Constraint> clazz)
          Remove the constraint (and associated information) for the table descriptor.
static void setConfiguration(HTableDescriptor desc, Class<? extends Constraint> clazz, org.apache.hadoop.conf.Configuration configuration)
          Update the configuration for the Constraint; does not change the order in which the constraint is run.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

enable

public static void enable(HTableDescriptor desc)
                   throws IOException
Enable constraints on a table.

Currently, if you attempt to add a constraint to the table, then Constraints will automatically be turned on.

Parameters:
desc - table description to add the processor
Throws:
IOException - If the ConstraintProcessor CP couldn't be added to the table.

disable

public static void disable(HTableDescriptor desc)
Turn off processing constraints for a given table, even if constraints have been turned on or added.

Parameters:
desc - HTableDescriptor where to disable Constraints.

remove

public static void remove(HTableDescriptor desc)
Remove all Constraints that have been added to the table and turn off the constraint processing.

All Configurations and their associated Constraint are removed.

Parameters:
desc - HTableDescriptor to remove Constraints from.

has

public static boolean has(HTableDescriptor desc,
                          Class<? extends Constraint> clazz)
Check to see if the Constraint is currently set.

Parameters:
desc - HTableDescriptor to check
clazz - Constraint class to check for.
Returns:
true if the Constraint is present, even if it is disabled. false otherwise.

add

public static void add(HTableDescriptor desc,
                       Class<? extends Constraint>... constraints)
                throws IOException
Add configuration-less constraints to the table.

This will overwrite any configuration associated with the previous constraint of the same class.

Each constraint, when added to the table, will have a specific priority, dictating the order in which the Constraint will be run. A Constraint earlier in the list will be run before those later in the list. The same logic applies between two Constraints over time (earlier added is run first on the regionserver).

Parameters:
desc - HTableDescriptor to add Constraints
constraints - Constraints to add. All constraints are considered automatically enabled on add
Throws:
IOException - If constraint could not be serialized/added to table

add

public static void add(HTableDescriptor desc,
                       Pair<Class<? extends Constraint>,org.apache.hadoop.conf.Configuration>... constraints)
                throws IOException
Add constraints and their associated configurations to the table.

Adding the same constraint class twice will overwrite the first constraint's configuration

Each constraint, when added to the table, will have a specific priority, dictating the order in which the Constraint will be run. A Constraint earlier in the list will be run before those later in the list. The same logic applies between two Constraints over time (earlier added is run first on the regionserver).

Parameters:
desc - HTableDescriptor to add a Constraint
constraints - Pair of a Constraint and its associated Configuration. The Constraint will be configured on load with the specified configuration.All constraints are considered automatically enabled on add
Throws:
IOException - if any constraint could not be deserialized. Assumes if 1 constraint is not loaded properly, something has gone terribly wrong and that all constraints need to be enforced.

add

public static void add(HTableDescriptor desc,
                       Class<? extends Constraint> constraint,
                       org.apache.hadoop.conf.Configuration conf)
                throws IOException
Add a Constraint to the table with the given configuration

Each constraint, when added to the table, will have a specific priority, dictating the order in which the Constraint will be run. A Constraint added will run on the regionserver before those added to the HTableDescriptor later.

Parameters:
desc - table descriptor to the constraint to
constraint - to be added
conf - configuration associated with the constraint
Throws:
IOException - if any constraint could not be deserialized. Assumes if 1 constraint is not loaded properly, something has gone terribly wrong and that all constraints need to be enforced.

setConfiguration

public static void setConfiguration(HTableDescriptor desc,
                                    Class<? extends Constraint> clazz,
                                    org.apache.hadoop.conf.Configuration configuration)
                             throws IOException,
                                    IllegalArgumentException
Update the configuration for the Constraint; does not change the order in which the constraint is run.

Parameters:
desc - HTableDescriptor to update
clazz - Constraint to update
configuration - to update the Constraint with.
Throws:
IOException - if the Constraint was not stored correctly
IllegalArgumentException - if the Constraint was not present on this table.

remove

public static void remove(HTableDescriptor desc,
                          Class<? extends Constraint> clazz)
Remove the constraint (and associated information) for the table descriptor.

Parameters:
desc - HTableDescriptor to modify
clazz - Constraint class to remove

enableConstraint

public static void enableConstraint(HTableDescriptor desc,
                                    Class<? extends Constraint> clazz)
                             throws IOException
Enable the given Constraint. Retains all the information (e.g. Configuration) for the Constraint, but makes sure that it gets loaded on the table.

Parameters:
desc - HTableDescriptor to modify
clazz - Constraint to enable
Throws:
IOException - If the constraint cannot be properly deserialized

disableConstraint

public static void disableConstraint(HTableDescriptor desc,
                                     Class<? extends Constraint> clazz)
                              throws IOException
Disable the given Constraint. Retains all the information (e.g. Configuration) for the Constraint, but it just doesn't load the Constraint on the table.

Parameters:
desc - HTableDescriptor to modify
clazz - Constraint to disable.
Throws:
IOException - if the constraint cannot be found

enabled

public static boolean enabled(HTableDescriptor desc,
                              Class<? extends Constraint> clazz)
                       throws IOException
Check to see if the given constraint is enabled.

Parameters:
desc - HTableDescriptor to check.
clazz - Constraint to check for
Returns:
true if the Constraint is present and enabled. false otherwise.
Throws:
IOException - If the constraint has improperly stored in the table


Copyright © 2007–2015 The Apache Software Foundation. All rights reserved.