Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
package org.apache.hadoop.hbase.constraint;
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,java.lang.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,java.lang.Class) and Constraints.disableConstraint(org.apache.hadoop.hbase.HTableDescriptor,java.lang.Class) for enabling/disabling of a given Constraint after it has been added.

If a org.apache.hadoop.hbase.client.Put is invalid, the Constraint should throw some sort of ConstraintException, indicating that the org.apache.hadoop.hbase.client.Put has failed. When this exception is thrown, not further retries of the org.apache.hadoop.hbase.client.Put are attempted nor are any other Constraints attempted (the org.apache.hadoop.hbase.client.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 org.apache.hadoop.hbase.client.Put via a ConstraintException, but instead throws a java.lang.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

public interface Constraint extends Configurable {

Check a org.apache.hadoop.hbase.client.Put to ensure it is valid for the table. If the org.apache.hadoop.hbase.client.Put is valid, then just return from the method. Otherwise, throw an java.lang.Exception specifying what happened. This java.lang.Exception is propagated back to the client so you can see what caused the org.apache.hadoop.hbase.client.Put to fail.

p org.apache.hadoop.hbase.client.Put to check
ConstraintException when the org.apache.hadoop.hbase.client.Put does not match the constraint.
  void check(Put pthrows ConstraintException;
New to GrepCode? Check out our FAQ X