E
- the specific environment extension that a concrete implementation
provides@InterfaceAudience.LimitedPrivate(value="Coprocesssor") @InterfaceStability.Evolving public abstract class CoprocessorHost<E extends CoprocessorEnvironment> extends Object
Modifier and Type | Class and Description |
---|---|
static class |
CoprocessorHost.Environment
Encapsulation of the environment of each coprocessor
|
Modifier and Type | Field and Description |
---|---|
static String |
ABORT_ON_ERROR_KEY |
protected Abortable |
abortable |
protected org.apache.hadoop.conf.Configuration |
conf |
protected SortedSet<E> |
coprocessors
Ordered set of loaded coprocessors with lock
|
static String |
COPROCESSORS_ENABLED_CONF_KEY |
static boolean |
DEFAULT_ABORT_ON_ERROR |
static boolean |
DEFAULT_COPROCESSORS_ENABLED |
static boolean |
DEFAULT_USER_COPROCESSORS_ENABLED |
protected AtomicInteger |
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_COPROCESSORS_ENABLED_CONF_KEY |
static String |
USER_REGION_COPROCESSOR_CONF_KEY |
static String |
WAL_COPROCESSOR_CONF_KEY |
Constructor and Description |
---|
CoprocessorHost(Abortable abortable) |
Modifier and Type | Method and Description |
---|---|
protected void |
abortServer(CoprocessorEnvironment environment,
Throwable e) |
protected void |
abortServer(String coprocessorName,
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
|
<T extends Coprocessor> |
findCoprocessors(Class<T> cls)
Find list of coprocessors that extend/implement the given class/interface
|
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).
|
protected void |
legacyWarning(Class<? extends Coprocessor> clazz,
String message)
limits the amount of logging to once per coprocessor class.
|
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 once only.
|
void |
shutdown(CoprocessorEnvironment e) |
protected static boolean |
useLegacyMethod(Class<? extends Coprocessor> clazz,
String methodName,
Class<?>... parameterTypes)
Used to gracefully handle fallback to deprecated methods when we
evolve coprocessor APIs.
|
public static final String REGION_COPROCESSOR_CONF_KEY
public static final String REGIONSERVER_COPROCESSOR_CONF_KEY
public static final String USER_REGION_COPROCESSOR_CONF_KEY
public static final String MASTER_COPROCESSOR_CONF_KEY
public static final String WAL_COPROCESSOR_CONF_KEY
public static final String ABORT_ON_ERROR_KEY
public static final boolean DEFAULT_ABORT_ON_ERROR
public static final String COPROCESSORS_ENABLED_CONF_KEY
public static final boolean DEFAULT_COPROCESSORS_ENABLED
public static final String USER_COPROCESSORS_ENABLED_CONF_KEY
public static final boolean DEFAULT_USER_COPROCESSORS_ENABLED
protected Abortable abortable
protected SortedSet<E extends CoprocessorEnvironment> coprocessors
protected org.apache.hadoop.conf.Configuration conf
protected String pathPrefix
protected AtomicInteger loadSequence
public CoprocessorHost(Abortable abortable)
public Set<String> getCoprocessors()
protected void loadSystemCoprocessors(org.apache.hadoop.conf.Configuration conf, String confKey)
public E load(org.apache.hadoop.fs.Path path, String className, int priority, org.apache.hadoop.conf.Configuration conf) throws IOException
path
- path to implementation jarclassName
- the main class namepriority
- chaining priorityconf
- configuration for coprocessorIOException
- Exceptionpublic void load(Class<?> implClass, int priority, org.apache.hadoop.conf.Configuration conf) throws IOException
implClass
- Implementation classpriority
- priorityconf
- configurationIOException
- Exceptionpublic E loadInstance(Class<?> implClass, int priority, org.apache.hadoop.conf.Configuration conf) throws IOException
implClass
- Implementation classpriority
- priorityconf
- configurationIOException
- Exceptionpublic abstract E createEnvironment(Class<?> implClass, Coprocessor instance, int priority, int sequence, org.apache.hadoop.conf.Configuration conf)
public void shutdown(CoprocessorEnvironment e)
public Coprocessor findCoprocessor(String className)
className
- the class namepublic <T extends Coprocessor> List<T> findCoprocessors(Class<T> cls)
cls
- the class/interface to look forpublic CoprocessorEnvironment findCoprocessorEnvironment(String className)
className
- the class nameprotected void abortServer(CoprocessorEnvironment environment, Throwable e)
protected void handleCoprocessorThrowable(CoprocessorEnvironment env, Throwable e) throws IOException
env
- Coprocessor Environmente
- Throwable object thrown by coprocessor.IOException
- Exception@InterfaceAudience.Private protected static boolean useLegacyMethod(Class<? extends Coprocessor> clazz, String methodName, Class<?>... parameterTypes)
legacyWarning(Class, String)
should be used to let operators know.
For examples of this in action, see the implementation of
clazz
- Coprocessor you wish to evaluatemethodName
- the name of the non-deprecated method versionparameterTypes
- the Class of the non-deprecated method's arguments in the order they are
declared.@InterfaceAudience.Private protected void legacyWarning(Class<? extends Coprocessor> clazz, String message)
useLegacyMethod(Class, String, Class[])
when a runtime issue
prevents properly supporting the legacy version of a coprocessor API.
Since coprocessors can be in tight loops this serves to limit the amount of log spam we create.Copyright © 2007-2016 The Apache Software Foundation. All Rights Reserved.