org.apache.hadoop.hbase.coprocessor
Class CoprocessorHost<E extends CoprocessorEnvironment>

java.lang.Object
  extended by org.apache.hadoop.hbase.coprocessor.CoprocessorHost<E>
Type Parameters:
E - the specific environment extension that a concrete implementation provides
Direct Known Subclasses:
MasterCoprocessorHost, RegionCoprocessorHost, RegionServerCoprocessorHost, WALCoprocessorHost

@InterfaceAudience.Public
@InterfaceStability.Evolving
public abstract class CoprocessorHost<E extends CoprocessorEnvironment>
extends Object

Provides the common setup framework and runtime services for coprocessor invocation from HBase services.


Nested Class Summary
static class CoprocessorHost.Environment
          Encapsulation of the environment of each coprocessor
 
Field Summary
protected  org.apache.hadoop.conf.Configuration conf
           
protected  SortedSet<E> coprocessors
          Ordered set of loaded coprocessors with lock
protected  int loadSequence
           
static String MASTER_COPROCESSOR_CONF_KEY
           
protected  String pathPrefix
           
static String REGION_COPROCESSOR_CONF_KEY
           
static String REGIONSERVER_COPROCESSOR_CONF_KEY
           
static String USER_REGION_COPROCESSOR_CONF_KEY
           
static String WAL_COPROCESSOR_CONF_KEY
           
 
Constructor Summary
CoprocessorHost()
           
 
Method Summary
protected  void abortServer(CoprocessorEnvironment environment, Throwable e)
           
protected  void abortServer(String service, Server server, CoprocessorEnvironment environment, Throwable e)
           
abstract  E createEnvironment(Class<?> implClass, Coprocessor instance, int priority, int sequence, org.apache.hadoop.conf.Configuration conf)
          Called when a new Coprocessor class is loaded
 Coprocessor findCoprocessor(String className)
          Find a coprocessor implementation by class name
 CoprocessorEnvironment findCoprocessorEnvironment(String className)
          Find a coprocessor environment by class name
 Set<String> getCoprocessors()
          Used to create a parameter to the HServerLoad constructor so that HServerLoad can provide information about the coprocessors loaded by this regionserver.
static Set<String> getLoadedCoprocessors()
           
protected  void handleCoprocessorThrowable(CoprocessorEnvironment env, Throwable e)
          This is used by coprocessor hooks which are declared to throw IOException (or its subtypes).
 void load(Class<?> implClass, int priority, org.apache.hadoop.conf.Configuration conf)
           
 E load(org.apache.hadoop.fs.Path path, String className, int priority, org.apache.hadoop.conf.Configuration conf)
          Load a coprocessor implementation into the host
 E loadInstance(Class<?> implClass, int priority, org.apache.hadoop.conf.Configuration conf)
           
protected  void loadSystemCoprocessors(org.apache.hadoop.conf.Configuration conf, String confKey)
          Load system coprocessors.
 void shutdown(CoprocessorEnvironment e)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REGION_COPROCESSOR_CONF_KEY

public static final String REGION_COPROCESSOR_CONF_KEY
See Also:
Constant Field Values

REGIONSERVER_COPROCESSOR_CONF_KEY

public static final String REGIONSERVER_COPROCESSOR_CONF_KEY
See Also:
Constant Field Values

USER_REGION_COPROCESSOR_CONF_KEY

public static final String USER_REGION_COPROCESSOR_CONF_KEY
See Also:
Constant Field Values

MASTER_COPROCESSOR_CONF_KEY

public static final String MASTER_COPROCESSOR_CONF_KEY
See Also:
Constant Field Values

WAL_COPROCESSOR_CONF_KEY

public static final String WAL_COPROCESSOR_CONF_KEY
See Also:
Constant Field Values

coprocessors

protected SortedSet<E extends CoprocessorEnvironment> coprocessors
Ordered set of loaded coprocessors with lock


conf

protected org.apache.hadoop.conf.Configuration conf

pathPrefix

protected String pathPrefix

loadSequence

protected volatile int loadSequence
Constructor Detail

CoprocessorHost

public CoprocessorHost()
Method Detail

getLoadedCoprocessors

public static Set<String> getLoadedCoprocessors()

getCoprocessors

public Set<String> getCoprocessors()
Used to create a parameter to the HServerLoad constructor so that HServerLoad can provide information about the coprocessors loaded by this regionserver. (HBASE-4070: Improve region server metrics to report loaded coprocessors to master).


loadSystemCoprocessors

protected void loadSystemCoprocessors(org.apache.hadoop.conf.Configuration conf,
                                      String confKey)
Load system coprocessors. Read the class names from configuration. Called by constructor.


load

public E load(org.apache.hadoop.fs.Path path,
              String className,
              int priority,
              org.apache.hadoop.conf.Configuration conf)
                                      throws IOException
Load a coprocessor implementation into the host

Parameters:
path - path to implementation jar
className - the main class name
priority - chaining priority
conf - configuration for coprocessor
Throws:
IOException - Exception

load

public void load(Class<?> implClass,
                 int priority,
                 org.apache.hadoop.conf.Configuration conf)
          throws IOException
Parameters:
implClass - Implementation class
priority - priority
conf - configuration
Throws:
IOException - Exception

loadInstance

public E loadInstance(Class<?> implClass,
                      int priority,
                      org.apache.hadoop.conf.Configuration conf)
                                              throws IOException
Parameters:
implClass - Implementation class
priority - priority
conf - configuration
Throws:
IOException - Exception

createEnvironment

public abstract E createEnvironment(Class<?> implClass,
                                    Coprocessor instance,
                                    int priority,
                                    int sequence,
                                    org.apache.hadoop.conf.Configuration conf)
Called when a new Coprocessor class is loaded


shutdown

public void shutdown(CoprocessorEnvironment e)

findCoprocessor

public Coprocessor findCoprocessor(String className)
Find a coprocessor implementation by class name

Parameters:
className - the class name
Returns:
the coprocessor, or null if not found

findCoprocessorEnvironment

public CoprocessorEnvironment findCoprocessorEnvironment(String className)
Find a coprocessor environment by class name

Parameters:
className - the class name
Returns:
the coprocessor, or null if not found

abortServer

protected void abortServer(String service,
                           Server server,
                           CoprocessorEnvironment environment,
                           Throwable e)

abortServer

protected void abortServer(CoprocessorEnvironment environment,
                           Throwable e)

handleCoprocessorThrowable

protected void handleCoprocessorThrowable(CoprocessorEnvironment env,
                                          Throwable e)
                                   throws IOException
This is used by coprocessor hooks which are declared to throw IOException (or its subtypes). For such hooks, we should handle throwable objects depending on the Throwable's type. Those which are instances of IOException should be passed on to the client. This is in conformance with the HBase idiom regarding IOException: that it represents a circumstance that should be passed along to the client for its own handling. For example, a coprocessor that implements access controls would throw a subclass of IOException, such as AccessDeniedException, in its preGet() method to prevent an unauthorized client's performing a Get on a particular table.

Parameters:
env - Coprocessor Environment
e - Throwable object thrown by coprocessor.
Throws:
IOException - Exception


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.