@InterfaceAudience.Private public class ObserverContextImpl<E extends CoprocessorEnvironment> extends Object implements ObserverContext<E>
ObserverContext
, which serves as the interface for
third-party Coprocessor developers.Modifier and Type | Field and Description |
---|---|
private boolean |
bypass |
private boolean |
bypassable
Is this operation bypassable?
|
private User |
caller |
private E |
env |
Constructor and Description |
---|
ObserverContextImpl(User caller) |
ObserverContextImpl(User caller,
boolean bypassable) |
Modifier and Type | Method and Description |
---|---|
void |
bypass()
Call to indicate that the current coprocessor's return value (or parameter -- depends on the
call-type) should be used in place of the value that would be obtained via normal processing;
i.e.
|
static <E extends CoprocessorEnvironment> |
createAndPrepare(E env)
Deprecated.
|
Optional<User> |
getCaller()
Returns the active user for the coprocessor call.
|
E |
getEnvironment() |
boolean |
isBypassable() |
void |
prepare(E env) |
boolean |
shouldBypass() |
private E extends CoprocessorEnvironment env
private boolean bypass
private final boolean bypassable
public ObserverContextImpl(User caller)
public ObserverContextImpl(User caller, boolean bypassable)
public E getEnvironment()
getEnvironment
in interface ObserverContext<E extends CoprocessorEnvironment>
public boolean isBypassable()
public void bypass()
ObserverContext
bypass
is supported.
This behavior of honoring only a subset of methods is new since hbase-2.0.0.
Where bypass is supported what is being bypassed is all of the core code implementing the remainder of the operation. In order to understand what calling bypass() will skip, a coprocessor implementer should read and understand all of the remaining code and its nuances. Although this is good practice for coprocessor developers in general, it demands a lot. What is skipped is extremely version dependent. The core code will vary, perhaps significantly, even between point releases. We do not provide the promise of consistent behavior even between point releases for the bypass semantic. To achieve that we could not change any code between hook points. Therefore the coprocessor implementer becomes an HBase core developer in practice as soon as they rely on bypass(). Every release of HBase may break the assumption that the replacement for the bypassed code takes care of all necessary skipped concerns. Because those concerns can change at any point, such an assumption is never safe.
As of hbase2, when bypass has been set, we will NOT call any Coprocessors follow the bypassing Coprocessor; we cut short the processing and return the bypassing Coprocessors response (this used be a separate 'complete' option that has been folded into the 'bypass' in hbase2.
bypass
in interface ObserverContext<E extends CoprocessorEnvironment>
public boolean shouldBypass()
true
, if ObserverContext.bypass()
was called by one of the loaded
coprocessors, false
otherwise.public Optional<User> getCaller()
ObserverContext
User
instance was
provided to the constructor, that will be returned, otherwise if we are in the context of an
RPC call, the remote user is used. May not be present if the execution is outside of an RPC
context.getCaller
in interface ObserverContext<E extends CoprocessorEnvironment>
@Deprecated public static <E extends CoprocessorEnvironment> ObserverContext<E> createAndPrepare(E env)
null
and
sets the environment in the new or existing instance. This allows deferring the instantiation
of a ObserverContext until it is actually needed.E
- The environment type for the contextenv
- The coprocessor environment to setObserverContext
with the environment setCopyright © 2007–2020 The Apache Software Foundation. All rights reserved.