Tabnine Logo
Constraint
Code IndexAdd Tabnine to your IDE (free)

How to use
Constraint
in
org.apache.hadoop.hbase.constraint

Best Java code snippets using org.apache.hadoop.hbase.constraint.Constraint (Showing top 11 results out of 315)

origin: apache/hbase

 @Override
 public int compare(Constraint c1, Constraint c2) {
  // compare the priorities of the constraints stored in their configuration
  return Long.compare(c1.getConf().getLong(PRIORITY_KEY, DEFAULT_PRIORITY),
    c2.getConf().getLong(PRIORITY_KEY, DEFAULT_PRIORITY));
 }
};
origin: apache/hbase

@Override
public void prePut(ObserverContext<RegionCoprocessorEnvironment> e, Put put,
  WALEdit edit, Durability durability) throws IOException {
 // check the put against the stored constraints
 for (Constraint c : constraints) {
  c.check(put);
 }
 // if we made it here, then the Put is valid
}
origin: apache/hbase

   .asSubclass(Constraint.class);
 Constraint constraint = clazz.getDeclaredConstructor().newInstance();
 constraint.setConf(conf);
 constraints.add(constraint);
} catch (InvocationTargetException | NoSuchMethodException | ClassNotFoundException |
origin: apache/hbase

@Test
public void testConfigurationPreserved() throws Throwable {
 Configuration conf = new Configuration();
 conf.setBoolean("_ENABLED", false);
 conf.setLong("_PRIORITY", 10);
 HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(name.getMethodName()));
 Constraints.add(desc, AlsoWorks.class, conf);
 Constraints.add(desc, WorksConstraint.class);
 assertFalse(Constraints.enabled(desc, AlsoWorks.class));
 List<? extends Constraint> constraints = Constraints.getConstraints(desc,
   this.getClass().getClassLoader());
 for (Constraint c : constraints) {
  Configuration storedConf = c.getConf();
  if (c instanceof AlsoWorks)
   assertEquals(10, storedConf.getLong("_PRIORITY", -1));
  // its just a worksconstraint
  else
   assertEquals(2, storedConf.getLong("_PRIORITY", -1));
 }
}
origin: co.cask.hbase/hbase

 @Override
 public void prePut(ObserverContext<RegionCoprocessorEnvironment> e, Put put,
   WALEdit edit, boolean writeToWAL) throws IOException {
  // check the put against the stored constraints
  for (Constraint c : constraints) {
   c.check(put);
  }
  // if we made it here, then the Put is valid
 }
}
origin: co.cask.hbase/hbase

   .asSubclass(Constraint.class);
 Constraint constraint = clazz.newInstance();
 constraint.setConf(conf);
 constraints.add(constraint);
} catch (ClassNotFoundException e1) {
origin: co.cask.hbase/hbase

 @Override
 public int compare(Constraint c1, Constraint c2) {
  // compare the priorities of the constraints stored in their configuration
  return Long.valueOf(c1.getConf().getLong(PRIORITY_KEY, DEFAULT_PRIORITY))
    .compareTo(c2.getConf().getLong(PRIORITY_KEY, DEFAULT_PRIORITY));
 }
};
origin: harbby/presto-connectors

 @Override
 public void prePut(ObserverContext<RegionCoprocessorEnvironment> e, Put put,
   WALEdit edit, Durability durability) throws IOException {
  // check the put against the stored constraints
  for (Constraint c : constraints) {
   c.check(put);
  }
  // if we made it here, then the Put is valid
 }
}
origin: harbby/presto-connectors

   .asSubclass(Constraint.class);
 Constraint constraint = clazz.newInstance();
 constraint.setConf(conf);
 constraints.add(constraint);
} catch (ClassNotFoundException e1) {
origin: harbby/presto-connectors

 @Override
 public int compare(Constraint c1, Constraint c2) {
  // compare the priorities of the constraints stored in their configuration
  return Long.valueOf(c1.getConf().getLong(PRIORITY_KEY, DEFAULT_PRIORITY))
    .compareTo(c2.getConf().getLong(PRIORITY_KEY, DEFAULT_PRIORITY));
 }
};
origin: org.apache.hbase/hbase-server

@Test
public void testConfigurationPreserved() throws Throwable {
 Configuration conf = new Configuration();
 conf.setBoolean("_ENABLED", false);
 conf.setLong("_PRIORITY", 10);
 HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(name.getMethodName()));
 Constraints.add(desc, AlsoWorks.class, conf);
 Constraints.add(desc, WorksConstraint.class);
 assertFalse(Constraints.enabled(desc, AlsoWorks.class));
 List<? extends Constraint> constraints = Constraints.getConstraints(desc,
   this.getClass().getClassLoader());
 for (Constraint c : constraints) {
  Configuration storedConf = c.getConf();
  if (c instanceof AlsoWorks)
   assertEquals(10, storedConf.getLong("_PRIORITY", -1));
  // its just a worksconstraint
  else
   assertEquals(2, storedConf.getLong("_PRIORITY", -1));
 }
}
org.apache.hadoop.hbase.constraintConstraint

Javadoc

Apply a Constraint (in traditional database terminology) to a HTable. Any number of Constraint 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 org.apache.hadoop.hbase.constraint.ConstraintException, indicating that the Put has failed. When this exception is thrown, not further retries of the Put are attempted nor are any other Constraint attempted (the Put is clearly not valid). Therefore, there are performance implications in the order in which BaseConstraint are specified.

If a Constraint fails to fail the Put via a org.apache.hadoop.hbase.constraint.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 Put will be checked via Constraint.

Further, Constraint 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

Most used methods

  • getConf
  • check
    Check a Put to ensure it is valid for the table. If the Putis valid, then just return from the metho
  • setConf

Popular in Java

  • Creating JSON documents from java classes using gson
  • startActivity (Activity)
  • setRequestProperty (URLConnection)
  • runOnUiThread (Activity)
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now