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

java.lang.Object
  extended by org.apache.hadoop.hbase.coprocessor.ObserverContext<E>
Type Parameters:
E - The CoprocessorEnvironment subclass applicable to the revelant Observer interface.

public class ObserverContext<E extends CoprocessorEnvironment>
extends Object

Carries the execution state for a given invocation of an Observer coprocessor (RegionObserver, MasterObserver, or WALObserver) method. The same ObserverContext instance is passed sequentially to all loaded coprocessors for a given Observer method trigger, with the CoprocessorEnvironment reference swapped out for each coprocessor.


Constructor Summary
ObserverContext()
           
 
Method Summary
 void bypass()
          Call to indicate that the current coprocessor's return value should be used in place of the normal HBase obtained value.
 void complete()
          Call to indicate that additional coprocessors further down the execution chain do not need to be invoked.
static
<T extends CoprocessorEnvironment>
ObserverContext<T>
createAndPrepare(T env, ObserverContext<T> context)
          Instantiates a new ObserverContext instance if the passed reference is null and sets the environment in the new or existing instance.
 E getEnvironment()
           
 void prepare(E env)
           
 boolean shouldBypass()
          For use by the coprocessor framework.
 boolean shouldComplete()
          For use by the coprocessor framework.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObserverContext

public ObserverContext()
Method Detail

getEnvironment

public E getEnvironment()

prepare

public void prepare(E env)

bypass

public void bypass()
Call to indicate that the current coprocessor's return value should be used in place of the normal HBase obtained value.


complete

public void complete()
Call to indicate that additional coprocessors further down the execution chain do not need to be invoked. Implies that this coprocessor's response is definitive.


shouldBypass

public boolean shouldBypass()
For use by the coprocessor framework.

Returns:
true if bypass() was called by one of the loaded coprocessors, false otherwise.

shouldComplete

public boolean shouldComplete()
For use by the coprocessor framework.

Returns:
true if complete() was called by one of the loaded coprocessors, false otherwise.

createAndPrepare

public static <T extends CoprocessorEnvironment> ObserverContext<T> createAndPrepare(T env,
                                                                                     ObserverContext<T> context)
Instantiates a new ObserverContext instance if the passed reference is null and sets the environment in the new or existing instance. This allows deferring the instantiation of a ObserverContext until it is actually needed.

Type Parameters:
T - The environment type for the context
Parameters:
env - The coprocessor environment to set
context - An existing ObserverContext instance to use, or null to create a new instance
Returns:
An instance of ObserverContext with the environment set


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