C
- type of specific coprocessor this host will handleE
- type of specific coprocessor environment this host requires. provides@InterfaceAudience.Private public abstract class CoprocessorHost<C extends Coprocessor,E extends CoprocessorEnvironment<C>> extends Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
CoprocessorHost.EnvironmentPriorityComparator
Environment priority comparator.
|
static interface |
CoprocessorHost.ObserverGetter<C,O>
Implementations defined function to get an observer of type
O from a coprocessor of
type C . |
private class |
CoprocessorHost.ObserverOperation<O> |
class |
CoprocessorHost.ObserverOperationWithoutResult<O> |
class |
CoprocessorHost.ObserverOperationWithResult<O,R> |
Modifier and Type | Field and Description |
---|---|
static String |
ABORT_ON_ERROR_KEY |
protected Abortable |
abortable |
protected org.apache.hadoop.conf.Configuration |
conf |
protected SortedList<E> |
coprocEnvironments
Ordered set of loaded coprocessors with lock
|
private static Set<String> |
coprocessorNames
Not to be confused with the per-object _coprocessors_ (above), coprocessorNames is static and
stores the set of all coprocessors ever loaded by any thread in this JVM.
|
static String |
COPROCESSORS_ENABLED_CONF_KEY |
static boolean |
DEFAULT_ABORT_ON_ERROR |
static boolean |
DEFAULT_COPROCESSORS_ENABLED |
static boolean |
DEFAULT_SKIP_LOAD_DUPLICATE_TABLE_COPROCESSOR |
static boolean |
DEFAULT_USER_COPROCESSORS_ENABLED |
private static Set<Class<? extends Coprocessor>> |
legacyWarning
Used to limit legacy handling to once per Coprocessor class per classloader.
|
protected AtomicInteger |
loadSequence |
private static org.slf4j.Logger |
LOG |
static String |
MASTER_COPROCESSOR_CONF_KEY |
protected String |
pathPrefix |
static String |
REGION_COPROCESSOR_CONF_KEY |
static String |
REGIONSERVER_COPROCESSOR_CONF_KEY |
static String |
SKIP_LOAD_DUPLICATE_TABLE_COPROCESSOR |
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(E environment,
Throwable e) |
protected void |
abortServer(String coprocessorName,
Throwable e) |
abstract C |
checkAndGetInstance(Class<?> implClass)
Called when a new Coprocessor class needs to be loaded.
|
E |
checkAndLoadInstance(Class<?> implClass,
int priority,
org.apache.hadoop.conf.Configuration conf) |
abstract E |
createEnvironment(C instance,
int priority,
int sequence,
org.apache.hadoop.conf.Configuration conf)
Called when a new Coprocessor class is loaded
|
protected <O> boolean |
execOperation(CoprocessorHost.ObserverOperation<O> observerOperation) |
protected <O,R> R |
execOperationWithResult(CoprocessorHost.ObserverOperationWithResult<O,R> observerOperation)
Do not call with an observerOperation that is null! Have the caller check.
|
protected <O> boolean |
execShutdown(CoprocessorHost.ObserverOperation<O> observerOperation)
Coprocessor classes can be configured in any order, based on that priority is set and chained
in a sorted order.
|
<T extends C> |
findCoprocessor(Class<T> cls) |
C |
findCoprocessor(String className)
Find coprocessors by full class name or simple name.
|
E |
findCoprocessorEnvironment(String className)
Find a coprocessor environment by class name
|
<T extends C> |
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.
|
(package private) Set<ClassLoader> |
getExternalClassLoaders()
Retrieves the set of classloaders used to instantiate Coprocessor classes defined in external
jar files.
|
static Set<String> |
getLoadedCoprocessors() |
protected void |
handleCoprocessorThrowable(E env,
Throwable e)
This is used by coprocessor hooks which are declared to throw IOException (or its subtypes).
|
void |
load(Class<? extends C> 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 |
load(org.apache.hadoop.fs.Path path,
String className,
int priority,
org.apache.hadoop.conf.Configuration conf,
String[] includedClassPrefixes)
Load a coprocessor implementation into the host
|
protected void |
loadSystemCoprocessors(org.apache.hadoop.conf.Configuration conf,
String confKey)
Load system coprocessors once only.
|
void |
shutdown(E e) |
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
public static final String SKIP_LOAD_DUPLICATE_TABLE_COPROCESSOR
public static final boolean DEFAULT_SKIP_LOAD_DUPLICATE_TABLE_COPROCESSOR
private static final org.slf4j.Logger LOG
protected final SortedList<E extends CoprocessorEnvironment<C>> coprocEnvironments
protected org.apache.hadoop.conf.Configuration conf
protected String pathPrefix
protected AtomicInteger loadSequence
private static Set<String> coprocessorNames
private static final Set<Class<? extends Coprocessor>> legacyWarning
public CoprocessorHost(Abortable abortable)
public static Set<String> getLoadedCoprocessors()
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 E load(org.apache.hadoop.fs.Path path, String className, int priority, org.apache.hadoop.conf.Configuration conf, String[] includedClassPrefixes) throws IOException
path
- path to implementation jarclassName
- the main class namepriority
- chaining priorityconf
- configuration for coprocessorincludedClassPrefixes
- class name prefixes to includeIOException
- Exceptionpublic void load(Class<? extends C> implClass, int priority, org.apache.hadoop.conf.Configuration conf) throws IOException
IOException
public E checkAndLoadInstance(Class<?> implClass, int priority, org.apache.hadoop.conf.Configuration conf) throws IOException
implClass
- Implementation classpriority
- priorityconf
- configurationIOException
- Exceptionpublic abstract E createEnvironment(C instance, int priority, int sequence, org.apache.hadoop.conf.Configuration conf)
public abstract C checkAndGetInstance(Class<?> implClass) throws InstantiationException, IllegalAccessException
public C findCoprocessor(String className)
public <T extends C> T findCoprocessor(Class<T> cls)
public <T extends C> List<T> findCoprocessors(Class<T> cls)
cls
- the class/interface to look forpublic E findCoprocessorEnvironment(String className)
className
- the class nameSet<ClassLoader> getExternalClassLoaders()
protected void abortServer(E environment, Throwable e)
protected void abortServer(String coprocessorName, Throwable e)
protected void handleCoprocessorThrowable(E env, Throwable e) throws IOException
env
- Coprocessor Environmente
- Throwable object thrown by coprocessor.IOException
- Exceptionprotected <O,R> R execOperationWithResult(CoprocessorHost.ObserverOperationWithResult<O,R> observerOperation) throws IOException
IOException
protected <O> boolean execOperation(CoprocessorHost.ObserverOperation<O> observerOperation) throws IOException
true
if
ObserverOperation#isBypassable().IOException
protected <O> boolean execShutdown(CoprocessorHost.ObserverOperation<O> observerOperation) throws IOException
IOException
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.