| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| <!-- NewPage --> |
| <html lang="en"> |
| <head> |
| <!-- Generated by javadoc --> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| <title>org.apache.hadoop.hbase.coprocessor (Apache HBase 3.0.0-alpha-2-SNAPSHOT API)</title> |
| <link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style"> |
| <script type="text/javascript" src="../../../../../script.js"></script> |
| </head> |
| <body> |
| <script type="text/javascript"><!-- |
| try { |
| if (location.href.indexOf('is-external=true') == -1) { |
| parent.document.title="org.apache.hadoop.hbase.coprocessor (Apache HBase 3.0.0-alpha-2-SNAPSHOT API)"; |
| } |
| } |
| catch(err) { |
| } |
| //--> |
| </script> |
| <noscript> |
| <div>JavaScript is disabled on your browser.</div> |
| </noscript> |
| <!-- ========= START OF TOP NAVBAR ======= --> |
| <div class="topNav"><a name="navbar.top"> |
| <!-- --> |
| </a> |
| <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> |
| <a name="navbar.top.firstrow"> |
| <!-- --> |
| </a> |
| <ul class="navList" title="Navigation"> |
| <li><a href="../../../../../overview-summary.html">Overview</a></li> |
| <li class="navBarCell1Rev">Package</li> |
| <li>Class</li> |
| <li><a href="package-use.html">Use</a></li> |
| <li><a href="package-tree.html">Tree</a></li> |
| <li><a href="../../../../../deprecated-list.html">Deprecated</a></li> |
| <li><a href="../../../../../index-all.html">Index</a></li> |
| <li><a href="../../../../../help-doc.html">Help</a></li> |
| </ul> |
| </div> |
| <div class="subNav"> |
| <ul class="navList"> |
| <li><a href="../../../../../org/apache/hadoop/hbase/coordination/package-summary.html">Prev Package</a></li> |
| <li><a href="../../../../../org/apache/hadoop/hbase/coprocessor/example/package-summary.html">Next Package</a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../../index.html?org/apache/hadoop/hbase/coprocessor/package-summary.html" target="_top">Frames</a></li> |
| <li><a href="package-summary.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_top"> |
| <li><a href="../../../../../allclasses-noframe.html">All Classes</a></li> |
| </ul> |
| <div> |
| <script type="text/javascript"><!-- |
| allClassesLink = document.getElementById("allclasses_navbar_top"); |
| if(window==top) { |
| allClassesLink.style.display = "block"; |
| } |
| else { |
| allClassesLink.style.display = "none"; |
| } |
| //--> |
| </script> |
| </div> |
| <a name="skip.navbar.top"> |
| <!-- --> |
| </a></div> |
| <!-- ========= END OF TOP NAVBAR ========= --> |
| <div class="header"> |
| <h1 title="Package" class="title">Package org.apache.hadoop.hbase.coprocessor</h1> |
| <div class="docSummary"> |
| <div class="block">Table of Contents</div> |
| </div> |
| <p>See: <a href="#package.description">Description</a></p> |
| </div> |
| <div class="contentContainer"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Interface Summary table, listing interfaces, and an explanation"> |
| <caption><span>Interface Summary</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Interface</th> |
| <th class="colLast" scope="col">Description</th> |
| </tr> |
| <tbody> |
| <tr class="altColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/BulkLoadObserver.html" title="interface in org.apache.hadoop.hbase.coprocessor">BulkLoadObserver</a></td> |
| <td class="colLast"> |
| <div class="block">Coprocessors implement this interface to observe and mediate bulk load operations.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/CoprocessorHost.ObserverGetter.html" title="interface in org.apache.hadoop.hbase.coprocessor">CoprocessorHost.ObserverGetter</a><C,O></td> |
| <td class="colLast"> |
| <div class="block">Implementations defined function to get an observer of type <code>O</code> from a coprocessor of |
| type <code>C</code>.</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/CoprocessorService.html" title="interface in org.apache.hadoop.hbase.coprocessor">CoprocessorService</a></td> |
| <td class="colLast">Deprecated |
| <div class="block"><span class="deprecationComment">Since 2.0.</span></div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/EndpointObserver.html" title="interface in org.apache.hadoop.hbase.coprocessor">EndpointObserver</a></td> |
| <td class="colLast"> |
| <div class="block">Coprocessors implement this interface to observe and mediate endpoint invocations |
| on a region.</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/HasMasterServices.html" title="interface in org.apache.hadoop.hbase.coprocessor">HasMasterServices</a></td> |
| <td class="colLast">Deprecated |
| <div class="block"><span class="deprecationComment">Since 2.0.0 to be removed in 3.0.0.</span></div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/HasRegionServerServices.html" title="interface in org.apache.hadoop.hbase.coprocessor">HasRegionServerServices</a></td> |
| <td class="colLast">Deprecated |
| <div class="block"><span class="deprecationComment">Since 2.0.0 to be removed in 3.0.0.</span></div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/MasterCoprocessor.html" title="interface in org.apache.hadoop.hbase.coprocessor">MasterCoprocessor</a></td> |
| <td class="colLast"> </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/MasterCoprocessorEnvironment.html" title="interface in org.apache.hadoop.hbase.coprocessor">MasterCoprocessorEnvironment</a></td> |
| <td class="colLast"> </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/MasterObserver.html" title="interface in org.apache.hadoop.hbase.coprocessor">MasterObserver</a></td> |
| <td class="colLast"> |
| <div class="block">Defines coprocessor hooks for interacting with operations on the |
| <a href="../../../../../org/apache/hadoop/hbase/master/HMaster.html" title="class in org.apache.hadoop.hbase.master"><code>HMaster</code></a> process.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/ObserverContext.html" title="interface in org.apache.hadoop.hbase.coprocessor">ObserverContext</a><E extends <a href="../../../../../org/apache/hadoop/hbase/CoprocessorEnvironment.html" title="interface in org.apache.hadoop.hbase">CoprocessorEnvironment</a>></td> |
| <td class="colLast"> |
| <div class="block">Carries the execution state for a given invocation of an Observer coprocessor |
| (<a href="../../../../../org/apache/hadoop/hbase/coprocessor/RegionObserver.html" title="interface in org.apache.hadoop.hbase.coprocessor"><code>RegionObserver</code></a>, <a href="../../../../../org/apache/hadoop/hbase/coprocessor/MasterObserver.html" title="interface in org.apache.hadoop.hbase.coprocessor"><code>MasterObserver</code></a>, or <a href="../../../../../org/apache/hadoop/hbase/coprocessor/WALObserver.html" title="interface in org.apache.hadoop.hbase.coprocessor"><code>WALObserver</code></a>) |
| method.</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/RegionCoprocessor.html" title="interface in org.apache.hadoop.hbase.coprocessor">RegionCoprocessor</a></td> |
| <td class="colLast"> </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/RegionCoprocessorEnvironment.html" title="interface in org.apache.hadoop.hbase.coprocessor">RegionCoprocessorEnvironment</a></td> |
| <td class="colLast"> </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/RegionObserver.html" title="interface in org.apache.hadoop.hbase.coprocessor">RegionObserver</a></td> |
| <td class="colLast"> |
| <div class="block">Coprocessors implement this interface to observe and mediate client actions on the region.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/RegionServerCoprocessor.html" title="interface in org.apache.hadoop.hbase.coprocessor">RegionServerCoprocessor</a></td> |
| <td class="colLast"> </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/RegionServerCoprocessorEnvironment.html" title="interface in org.apache.hadoop.hbase.coprocessor">RegionServerCoprocessorEnvironment</a></td> |
| <td class="colLast"> </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/RegionServerObserver.html" title="interface in org.apache.hadoop.hbase.coprocessor">RegionServerObserver</a></td> |
| <td class="colLast"> |
| <div class="block">Defines coprocessor hooks for interacting with operations on the |
| <a href="../../../../../org/apache/hadoop/hbase/regionserver/HRegionServer.html" title="class in org.apache.hadoop.hbase.regionserver"><code>HRegionServer</code></a> process.</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/WALCoprocessor.html" title="interface in org.apache.hadoop.hbase.coprocessor">WALCoprocessor</a></td> |
| <td class="colLast"> |
| <div class="block">WALCoprocessor don't support loading services using <a href="../../../../../org/apache/hadoop/hbase/Coprocessor.html#getServices--"><code>Coprocessor.getServices()</code></a>.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/WALCoprocessorEnvironment.html" title="interface in org.apache.hadoop.hbase.coprocessor">WALCoprocessorEnvironment</a></td> |
| <td class="colLast"> </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/WALObserver.html" title="interface in org.apache.hadoop.hbase.coprocessor">WALObserver</a></td> |
| <td class="colLast"> |
| <div class="block">It's provided to have a way for coprocessors to observe, rewrite, |
| or skip WALEdits as they are being written to the WAL.</div> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </li> |
| <li class="blockList"> |
| <table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Class Summary table, listing classes, and an explanation"> |
| <caption><span>Class Summary</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Class</th> |
| <th class="colLast" scope="col">Description</th> |
| </tr> |
| <tbody> |
| <tr class="altColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/BaseEnvironment.html" title="class in org.apache.hadoop.hbase.coprocessor">BaseEnvironment</a><C extends <a href="../../../../../org/apache/hadoop/hbase/Coprocessor.html" title="interface in org.apache.hadoop.hbase">Coprocessor</a>></td> |
| <td class="colLast"> |
| <div class="block">Encapsulation of the environment of each coprocessor</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/ColumnInterpreter.html" title="class in org.apache.hadoop.hbase.coprocessor">ColumnInterpreter</a><T,S,P extends org.apache.hbase.thirdparty.com.google.protobuf.Message,Q extends org.apache.hbase.thirdparty.com.google.protobuf.Message,R extends org.apache.hbase.thirdparty.com.google.protobuf.Message></td> |
| <td class="colLast"> |
| <div class="block">Defines how value for specific column is interpreted and provides utility |
| methods like compare, add, multiply etc for them.</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/CoprocessorHost.html" title="class in org.apache.hadoop.hbase.coprocessor">CoprocessorHost</a><C extends <a href="../../../../../org/apache/hadoop/hbase/Coprocessor.html" title="interface in org.apache.hadoop.hbase">Coprocessor</a>,E extends <a href="../../../../../org/apache/hadoop/hbase/CoprocessorEnvironment.html" title="interface in org.apache.hadoop.hbase">CoprocessorEnvironment</a><C>></td> |
| <td class="colLast"> |
| <div class="block">Provides the common setup framework and runtime services for coprocessor |
| invocation from HBase services.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/CoprocessorHost.EnvironmentPriorityComparator.html" title="class in org.apache.hadoop.hbase.coprocessor">CoprocessorHost.EnvironmentPriorityComparator</a></td> |
| <td class="colLast"> |
| <div class="block">Environment priority comparator.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/MetaTableMetrics.html" title="class in org.apache.hadoop.hbase.coprocessor">MetaTableMetrics</a></td> |
| <td class="colLast"> |
| <div class="block">A coprocessor that collects metrics from meta table.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/MetricsCoprocessor.html" title="class in org.apache.hadoop.hbase.coprocessor">MetricsCoprocessor</a></td> |
| <td class="colLast"> |
| <div class="block">Utility class for tracking metrics for various types of coprocessors.</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/MultiRowMutationEndpoint.html" title="class in org.apache.hadoop.hbase.coprocessor">MultiRowMutationEndpoint</a></td> |
| <td class="colLast"> |
| <div class="block">This class implements atomic multi row transactions using |
| <a href="../../../../../org/apache/hadoop/hbase/regionserver/HRegion.html#mutateRowsWithLocks-java.util.Collection-java.util.Collection-long-long-"><code>HRegion.mutateRowsWithLocks(Collection, Collection, long, long)</code></a> and Coprocessor |
| endpoints.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/ObserverContextImpl.html" title="class in org.apache.hadoop.hbase.coprocessor">ObserverContextImpl</a><E extends <a href="../../../../../org/apache/hadoop/hbase/CoprocessorEnvironment.html" title="interface in org.apache.hadoop.hbase">CoprocessorEnvironment</a>></td> |
| <td class="colLast"> |
| <div class="block">This is the only implementation of <a href="../../../../../org/apache/hadoop/hbase/coprocessor/ObserverContext.html" title="interface in org.apache.hadoop.hbase.coprocessor"><code>ObserverContext</code></a>, which serves as the interface for |
| third-party Coprocessor developers.</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/ReadOnlyConfiguration.html" title="class in org.apache.hadoop.hbase.coprocessor">ReadOnlyConfiguration</a></td> |
| <td class="colLast"> |
| <div class="block">Wraps a Configuration to make it read-only.</div> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </li> |
| <li class="blockList"> |
| <table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Enum Summary table, listing enums, and an explanation"> |
| <caption><span>Enum Summary</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Enum</th> |
| <th class="colLast" scope="col">Description</th> |
| </tr> |
| <tbody> |
| <tr class="altColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/MetaTableMetrics.MetaTableOps.html" title="enum in org.apache.hadoop.hbase.coprocessor">MetaTableMetrics.MetaTableOps</a></td> |
| <td class="colLast"> </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/RegionObserver.MutationType.html" title="enum in org.apache.hadoop.hbase.coprocessor">RegionObserver.MutationType</a></td> |
| <td class="colLast"> |
| <div class="block">Mutation type for postMutationBeforeWAL hook</div> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </li> |
| <li class="blockList"> |
| <table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Exception Summary table, listing exceptions, and an explanation"> |
| <caption><span>Exception Summary</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Exception</th> |
| <th class="colLast" scope="col">Description</th> |
| </tr> |
| <tbody> |
| <tr class="altColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/CoprocessorException.html" title="class in org.apache.hadoop.hbase.coprocessor">CoprocessorException</a></td> |
| <td class="colLast"> |
| <div class="block">Thrown if a coprocessor encounters any exception.</div> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </li> |
| <li class="blockList"> |
| <table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Annotation Types Summary table, listing annotation types, and an explanation"> |
| <caption><span>Annotation Types Summary</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Annotation Type</th> |
| <th class="colLast" scope="col">Description</th> |
| </tr> |
| <tbody> |
| <tr class="altColor"> |
| <td class="colFirst"><a href="../../../../../org/apache/hadoop/hbase/coprocessor/CoreCoprocessor.html" title="annotation in org.apache.hadoop.hbase.coprocessor">CoreCoprocessor</a></td> |
| <td class="colLast"> |
| <div class="block">Marker annotation that denotes Coprocessors that are core to HBase.</div> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </li> |
| </ul> |
| <a name="package.description"> |
| <!-- --> |
| </a> |
| <h2 title="Package org.apache.hadoop.hbase.coprocessor Description">Package org.apache.hadoop.hbase.coprocessor Description</h2> |
| <div class="block"><h2>Table of Contents</h2> |
| <ul> |
| <li><a href="#overview">Overview</a></li> |
| <li><a href="#coprocessor">Coprocessor</a></li> |
| <li><a href="#regionobserver">RegionObserver</a></li> |
| <li><a href="#commandtarget">Endpoint</a></li> |
| <li><a href="#load">Coprocessor loading</a></li> |
| </ul> |
| |
| <h2><a name="overview">Overview</a></h2> |
| Coprocessors are code that runs in-process on each region server. Regions |
| contain references to the coprocessor implementation classes associated |
| with them. Coprocessor classes can be loaded either from local |
| jars on the region server's classpath or via the HDFS classloader. |
| <p> |
| Multiple types of coprocessors are provided to provide sufficient flexibility |
| for potential use cases. Right now there are: |
| <p> |
| <ul> |
| <li>Coprocessor: provides region lifecycle management hooks, e.g., region |
| open/close/split/flush/compact operations.</li> |
| <li>RegionObserver: provides hook for monitor table operations from |
| client side, such as table get/put/scan/delete, etc.</li> |
| <li>Endpoint: provides on demand triggers for any arbitrary function |
| executed at a region. One use case is column aggregation at region |
| server. </li> |
| </ul> |
| |
| <h2><a name="coprocessor">Coprocessor</a></h2> |
| A coprocessor is required to |
| implement <code>Coprocessor</code> interface so that coprocessor framework |
| can manage it internally. |
| <p> |
| Another design goal of this interface is to provide simple features for |
| making coprocessors useful, while exposing no more internal state or |
| control actions of the region server than necessary and not exposing them |
| directly. |
| <p> |
| Over the lifecycle of a region, the methods of this interface are invoked |
| when the corresponding events happen. The master transitions regions |
| through the following states: |
| <p> |
| |
| unassigned -> pendingOpen -> open -> pendingClose -7gt; closed. |
| <p> |
| Coprocessors have opportunity to intercept and handle events in |
| pendingOpen, open, and pendingClose states. |
| <p> |
| |
| <h3>PendingOpen</h3> |
| <p> |
| The region server is opening a region to bring it online. Coprocessors |
| can piggyback or fail this process. |
| <p> |
| <ul> |
| <li>preOpen, postOpen: Called before and after the region is reported as |
| online to the master.</li> |
| </ul> |
| <p> |
| <h3>Open</h3> |
| The region is open on the region server and is processing both client |
| requests (get, put, scan, etc.) and administrative actions (flush, compact, |
| split, etc.). Coprocessors can piggyback administrative actions via: |
| <p> |
| <ul> |
| <li>preFlush, postFlush: Called before and after the memstore is flushed |
| into a new store file.</li> |
| <li>preCompact, postCompact: Called before and after compaction.</li> |
| <li>preSplit, postSplit: Called after the region is split.</li> |
| </ul> |
| <p> |
| <h3>PendingClose</h3> |
| The region server is closing the region. This can happen as part of normal |
| operations or may happen when the region server is aborting due to fatal |
| conditions such as OOME, health check failure, or fatal filesystem |
| problems. Coprocessors can piggyback this event. If the server is aborting |
| an indication to this effect will be passed as an argument. |
| <p> |
| <ul> |
| <li>preClose and postClose: Called before and after the region is |
| reported as closed to the master.</li> |
| </ul> |
| <p> |
| |
| <h2><a name="regionobserver">RegionObserver</a></h2> |
| If the coprocessor implements the <code>RegionObserver</code> interface it can |
| observe and mediate client actions on the region: |
| <p> |
| <ul> |
| <li>preGet, postGet: Called before and after a client makes a Get |
| request.</li> |
| <li>preExists, postExists: Called before and after the client tests |
| for existence using a Get.</li> |
| <li>prePut and postPut: Called before and after the client stores a value. |
| </li> |
| <li>preDelete and postDelete: Called before and after the client |
| deletes a value.</li> |
| <li>preScannerOpen postScannerOpen: Called before and after the client |
| opens a new scanner.</li> |
| <li>preScannerNext, postScannerNext: Called before and after the client |
| asks for the next row on a scanner.</li> |
| <li>preScannerClose, postScannerClose: Called before and after the client |
| closes a scanner.</li> |
| <li>preCheckAndPut, postCheckAndPut: Called before and after the client |
| calls checkAndPut().</li> |
| <li>preCheckAndDelete, postCheckAndDelete: Called before and after the client |
| calls checkAndDelete().</li> |
| </ul> |
| <p> |
| Here's an example of what a simple RegionObserver might look like. This |
| example shows how to implement access control for HBase. This |
| coprocessor checks user information for a given client request, e.g., |
| Get/Put/Delete/Scan by injecting code at certain |
| <code>RegionObserver</code> |
| preXXX hooks. If the user is not allowed to access the resource, a |
| CoprocessorException will be thrown. And the client request will be |
| denied by receiving this exception. |
| <div style="background-color: #cccccc; padding: 2px"> |
| <blockquote><pre> |
| package org.apache.hadoop.hbase.coprocessor; |
| |
| import org.apache.hadoop.hbase.client.Get; |
| |
| // Sample access-control coprocessor. It utilizes RegionObserver |
| // and intercept preXXX() method to check user privilege for the given table |
| // and column family. |
| public class AccessControlCoprocessor extends BaseRegionObserverCoprocessor { |
| // @Override |
| public Get preGet(CoprocessorEnvironment e, Get get) |
| throws CoprocessorException { |
| |
| // check permissions.. |
| if (access_not_allowed) { |
| throw new AccessDeniedException("User is not allowed to access."); |
| } |
| return get; |
| } |
| |
| // override prePut(), preDelete(), etc. |
| } |
| </pre></blockquote> |
| </div> |
| |
| <h2><a name="commandtarget">Endpoint</a></h2> |
| <code>Coprocessor</code> and <code>RegionObserver</code> provide certain hooks |
| for injecting user code running at each region. The user code will be triggered |
| by existing <code>HTable</code> and <code>HBaseAdmin</code> operations at |
| the certain hook points. |
| <p> |
| Coprocessor Endpoints allow you to define your own dynamic RPC protocol to communicate |
| between clients and region servers, i.e., you can create a new method, specifying custom |
| request parameters and return types. RPC methods exposed by coprocessor Endpoints can be |
| triggered by calling client side dynamic RPC functions -- <code>HTable.coprocessorService(...) |
| </code>. |
| <p> |
| To implement an Endpoint, you need to: |
| <ul> |
| <li>Define a protocol buffer Service and supporting Message types for the RPC methods. |
| See the |
| <a href="https://developers.google.com/protocol-buffers/docs/proto#services">protocol buffer guide</a> |
| for more details on defining services.</li> |
| <li>Generate the Service and Message code using the protoc compiler</li> |
| <li>Implement the generated Service interface and override get*Service() method in |
| relevant Coprocessor to return a reference to the Endpoint's protocol buffer Service instance. |
| </ul> |
| <p> |
| For a more detailed discussion of how to implement a coprocessor Endpoint, along with some sample |
| code, see the <code>org.apache.hadoop.hbase.client.coprocessor</code> package documentation. |
| </p> |
| |
| <h2><a name="load">Coprocessor loading</a></h2> |
| A customized coprocessor can be loaded by two different ways, by configuration, |
| or by <code>TableDescriptor</code> for a newly created table. |
| <p> |
| (Currently we don't really have an on demand coprocessor loading mechanism for |
| opened regions.) |
| <h3>Load from configuration</h3> |
| Whenever a region is opened, it will read coprocessor class names from |
| <code>hbase.coprocessor.region.classes</code> from <code>Configuration</code>. |
| Coprocessor framework will automatically load the configured classes as |
| default coprocessors. The classes must be included in the classpath already. |
| |
| <p> |
| <div style="background-color: #cccccc; padding: 2px"> |
| <blockquote><pre> |
| <property> |
| <name>hbase.coprocessor.region.classes</name> |
| <value>org.apache.hadoop.hbase.coprocessor.AccessControlCoprocessor, org.apache.hadoop.hbase.coprocessor.ColumnAggregationProtocol</value> |
| <description>A comma-separated list of Coprocessors that are loaded by |
| default. For any override coprocessor method from RegionObservor or |
| Coprocessor, these classes' implementation will be called |
| in order. After implement your own |
| Coprocessor, just put it in HBase's classpath and add the fully |
| qualified class name here. |
| </description> |
| </property> |
| </pre></blockquote> |
| </div> |
| <p> |
| The first defined coprocessor will be assigned |
| <code>Coprocessor.Priority.SYSTEM</code> as priority. And each following |
| coprocessor's priority will be incremented by one. Coprocessors are executed |
| in order according to the natural ordering of the int. |
| |
| <h3>Load from table attribute</h3> |
| Coprocessor classes can also be configured at table attribute. The |
| attribute key must start with "Coprocessor" and values of the form is |
| <path>:<class>:<priority>, so that the framework can |
| recognize and load it. |
| <p> |
| <div style="background-color: #cccccc; padding: 2px"> |
| <blockquote><pre> |
| 'COPROCESSOR$1' => 'hdfs://localhost:8020/hbase/coprocessors/test.jar:Test:1000' |
| 'COPROCESSOR$2' => '/hbase/coprocessors/test2.jar:AnotherTest:1001' |
| </pre></blockquote> |
| </div> |
| <p> |
| <path> must point to a jar, can be on any filesystem supported by the |
| Hadoop <code>FileSystem</code> object. |
| <p> |
| <class> is the coprocessor implementation class. A jar can contain |
| more than one coprocessor implementation, but only one can be specified |
| at a time in each table attribute. |
| <p> |
| <priority> is an integer. Coprocessors are executed in order according |
| to the natural ordering of the int. Coprocessors can optionally abort |
| actions. So typically one would want to put authoritative CPs (security |
| policy implementations, perhaps) ahead of observers. |
| <p> |
| <div style="background-color: #cccccc; padding: 2px"> |
| <blockquote><pre> |
| Path path = new Path(fs.getUri() + Path.SEPARATOR + |
| "TestClassloading.jar"); |
| |
| // create a table that references the jar |
| TableDescriptor htd = TableDescriptorBuilder |
| .newBuilder(TableName.valueOf(getClass().getTableName())) |
| .setColumnFamily(ColumnFamilyDescriptorBuilder.of("test")) |
| .setValue(Bytes.toBytes("Coprocessor$1", path.toString()+ |
| ":" + classFullName + |
| ":" + Coprocessor.Priority.USER)) |
| .build(); |
| Admin admin = connection.getAdmin(); |
| admin.createTable(htd); |
| </pre></blockquote> |
| <h3>Chain of RegionObservers</h3> |
| As described above, multiple coprocessors can be loaded at one region at the |
| same time. In case of RegionObserver, you can have more than one |
| RegionObservers register to one same hook point, i.e, preGet(), etc. |
| When a region reach the |
| hook point, the framework will invoke each registered RegionObserver by the |
| order of assigned priority. |
| </div></div> |
| </div> |
| <!-- ======= START OF BOTTOM NAVBAR ====== --> |
| <div class="bottomNav"><a name="navbar.bottom"> |
| <!-- --> |
| </a> |
| <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> |
| <a name="navbar.bottom.firstrow"> |
| <!-- --> |
| </a> |
| <ul class="navList" title="Navigation"> |
| <li><a href="../../../../../overview-summary.html">Overview</a></li> |
| <li class="navBarCell1Rev">Package</li> |
| <li>Class</li> |
| <li><a href="package-use.html">Use</a></li> |
| <li><a href="package-tree.html">Tree</a></li> |
| <li><a href="../../../../../deprecated-list.html">Deprecated</a></li> |
| <li><a href="../../../../../index-all.html">Index</a></li> |
| <li><a href="../../../../../help-doc.html">Help</a></li> |
| </ul> |
| </div> |
| <div class="subNav"> |
| <ul class="navList"> |
| <li><a href="../../../../../org/apache/hadoop/hbase/coordination/package-summary.html">Prev Package</a></li> |
| <li><a href="../../../../../org/apache/hadoop/hbase/coprocessor/example/package-summary.html">Next Package</a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../../index.html?org/apache/hadoop/hbase/coprocessor/package-summary.html" target="_top">Frames</a></li> |
| <li><a href="package-summary.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_bottom"> |
| <li><a href="../../../../../allclasses-noframe.html">All Classes</a></li> |
| </ul> |
| <div> |
| <script type="text/javascript"><!-- |
| allClassesLink = document.getElementById("allclasses_navbar_bottom"); |
| if(window==top) { |
| allClassesLink.style.display = "block"; |
| } |
| else { |
| allClassesLink.style.display = "none"; |
| } |
| //--> |
| </script> |
| </div> |
| <a name="skip.navbar.bottom"> |
| <!-- --> |
| </a></div> |
| <!-- ======== END OF BOTTOM NAVBAR ======= --> |
| <p class="legalCopy"><small>Copyright © 2007–2021 <a href="https://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p> |
| </body> |
| </html> |