hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [12/19] hbase-site git commit: Published site at .
Date Sun, 19 Nov 2017 15:17:36 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/2424a45f/devapidocs/src-html/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.ObserverOperation.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.ObserverOperation.html b/devapidocs/src-html/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.ObserverOperation.html
index 61dceae..7f3de9e 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.ObserverOperation.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.ObserverOperation.html
@@ -567,178 +567,170 @@
 <span class="sourceLineNo">559</span>    }<a name="line.559"></a>
 <span class="sourceLineNo">560</span><a name="line.560"></a>
 <span class="sourceLineNo">561</span>    ObserverOperation(ObserverGetter&lt;C, O&gt; observerGetter, User user, boolean bypassable) {<a name="line.561"></a>
-<span class="sourceLineNo">562</span>      super(user != null? user: RpcServer.getRequestUser().orElse(null),<a name="line.562"></a>
-<span class="sourceLineNo">563</span>          bypassable, bypassable/*'completable': make completable same as bypassable*/);<a name="line.563"></a>
-<span class="sourceLineNo">564</span>      this.observerGetter = observerGetter;<a name="line.564"></a>
-<span class="sourceLineNo">565</span>    }<a name="line.565"></a>
-<span class="sourceLineNo">566</span><a name="line.566"></a>
-<span class="sourceLineNo">567</span>    abstract void callObserver() throws IOException;<a name="line.567"></a>
-<span class="sourceLineNo">568</span>    protected void postEnvCall() {}<a name="line.568"></a>
-<span class="sourceLineNo">569</span>  }<a name="line.569"></a>
-<span class="sourceLineNo">570</span><a name="line.570"></a>
-<span class="sourceLineNo">571</span>  // Can't derive ObserverOperation from ObserverOperationWithResult (R = Void) because then all<a name="line.571"></a>
-<span class="sourceLineNo">572</span>  // ObserverCaller implementations will have to have a return statement.<a name="line.572"></a>
-<span class="sourceLineNo">573</span>  // O = observer, E = environment, C = coprocessor, R=result type<a name="line.573"></a>
-<span class="sourceLineNo">574</span>  public abstract class ObserverOperationWithoutResult&lt;O&gt; extends ObserverOperation&lt;O&gt; {<a name="line.574"></a>
-<span class="sourceLineNo">575</span>    protected abstract void call(O observer) throws IOException;<a name="line.575"></a>
-<span class="sourceLineNo">576</span><a name="line.576"></a>
-<span class="sourceLineNo">577</span>    public ObserverOperationWithoutResult(ObserverGetter&lt;C, O&gt; observerGetter) {<a name="line.577"></a>
-<span class="sourceLineNo">578</span>      super(observerGetter);<a name="line.578"></a>
-<span class="sourceLineNo">579</span>    }<a name="line.579"></a>
-<span class="sourceLineNo">580</span><a name="line.580"></a>
-<span class="sourceLineNo">581</span>    public ObserverOperationWithoutResult(ObserverGetter&lt;C, O&gt; observerGetter, User user) {<a name="line.581"></a>
-<span class="sourceLineNo">582</span>      super(observerGetter, user);<a name="line.582"></a>
-<span class="sourceLineNo">583</span>    }<a name="line.583"></a>
-<span class="sourceLineNo">584</span><a name="line.584"></a>
-<span class="sourceLineNo">585</span>    public ObserverOperationWithoutResult(ObserverGetter&lt;C, O&gt; observerGetter, User user,<a name="line.585"></a>
-<span class="sourceLineNo">586</span>        boolean bypassable) {<a name="line.586"></a>
-<span class="sourceLineNo">587</span>      super(observerGetter, user, bypassable);<a name="line.587"></a>
-<span class="sourceLineNo">588</span>    }<a name="line.588"></a>
-<span class="sourceLineNo">589</span><a name="line.589"></a>
-<span class="sourceLineNo">590</span>    /**<a name="line.590"></a>
-<span class="sourceLineNo">591</span>     * In case of coprocessors which have many kinds of observers (for eg, {@link RegionCoprocessor}<a name="line.591"></a>
-<span class="sourceLineNo">592</span>     * has BulkLoadObserver, RegionObserver, etc), some implementations may not need all<a name="line.592"></a>
-<span class="sourceLineNo">593</span>     * observers, in which case they will return null for that observer's getter.<a name="line.593"></a>
-<span class="sourceLineNo">594</span>     * We simply ignore such cases.<a name="line.594"></a>
-<span class="sourceLineNo">595</span>     */<a name="line.595"></a>
-<span class="sourceLineNo">596</span>    @Override<a name="line.596"></a>
-<span class="sourceLineNo">597</span>    void callObserver() throws IOException {<a name="line.597"></a>
-<span class="sourceLineNo">598</span>      Optional&lt;O&gt; observer = observerGetter.apply(getEnvironment().getInstance());<a name="line.598"></a>
-<span class="sourceLineNo">599</span>      if (observer.isPresent()) {<a name="line.599"></a>
-<span class="sourceLineNo">600</span>        call(observer.get());<a name="line.600"></a>
-<span class="sourceLineNo">601</span>      }<a name="line.601"></a>
-<span class="sourceLineNo">602</span>    }<a name="line.602"></a>
-<span class="sourceLineNo">603</span>  }<a name="line.603"></a>
-<span class="sourceLineNo">604</span><a name="line.604"></a>
-<span class="sourceLineNo">605</span>  public abstract class ObserverOperationWithResult&lt;O, R&gt; extends ObserverOperation&lt;O&gt; {<a name="line.605"></a>
-<span class="sourceLineNo">606</span>    protected abstract R call(O observer) throws IOException;<a name="line.606"></a>
-<span class="sourceLineNo">607</span><a name="line.607"></a>
-<span class="sourceLineNo">608</span>    private R result;<a name="line.608"></a>
-<span class="sourceLineNo">609</span><a name="line.609"></a>
-<span class="sourceLineNo">610</span>    public ObserverOperationWithResult(ObserverGetter&lt;C, O&gt; observerGetter, R result) {<a name="line.610"></a>
-<span class="sourceLineNo">611</span>      this(observerGetter, result, false);<a name="line.611"></a>
-<span class="sourceLineNo">612</span>    }<a name="line.612"></a>
-<span class="sourceLineNo">613</span><a name="line.613"></a>
-<span class="sourceLineNo">614</span>    public ObserverOperationWithResult(ObserverGetter&lt;C, O&gt; observerGetter, R result,<a name="line.614"></a>
-<span class="sourceLineNo">615</span>        boolean bypassable) {<a name="line.615"></a>
-<span class="sourceLineNo">616</span>      this(observerGetter, result, null, bypassable);<a name="line.616"></a>
-<span class="sourceLineNo">617</span>    }<a name="line.617"></a>
-<span class="sourceLineNo">618</span><a name="line.618"></a>
-<span class="sourceLineNo">619</span>    public ObserverOperationWithResult(ObserverGetter&lt;C, O&gt; observerGetter, R result,<a name="line.619"></a>
-<span class="sourceLineNo">620</span>        User user) {<a name="line.620"></a>
-<span class="sourceLineNo">621</span>      this(observerGetter, result, user, false);<a name="line.621"></a>
-<span class="sourceLineNo">622</span>    }<a name="line.622"></a>
-<span class="sourceLineNo">623</span><a name="line.623"></a>
-<span class="sourceLineNo">624</span>    private ObserverOperationWithResult(ObserverGetter&lt;C, O&gt; observerGetter, R result, User user,<a name="line.624"></a>
-<span class="sourceLineNo">625</span>        boolean bypassable) {<a name="line.625"></a>
-<span class="sourceLineNo">626</span>      super(observerGetter, user, bypassable);<a name="line.626"></a>
-<span class="sourceLineNo">627</span>      this.result = result;<a name="line.627"></a>
-<span class="sourceLineNo">628</span>    }<a name="line.628"></a>
-<span class="sourceLineNo">629</span><a name="line.629"></a>
-<span class="sourceLineNo">630</span>    protected R getResult() {<a name="line.630"></a>
-<span class="sourceLineNo">631</span>      return this.result;<a name="line.631"></a>
-<span class="sourceLineNo">632</span>    }<a name="line.632"></a>
-<span class="sourceLineNo">633</span><a name="line.633"></a>
-<span class="sourceLineNo">634</span>    void callObserver() throws IOException {<a name="line.634"></a>
-<span class="sourceLineNo">635</span>      Optional&lt;O&gt; observer = observerGetter.apply(getEnvironment().getInstance());<a name="line.635"></a>
-<span class="sourceLineNo">636</span>      if (observer.isPresent()) {<a name="line.636"></a>
-<span class="sourceLineNo">637</span>        result = call(observer.get());<a name="line.637"></a>
-<span class="sourceLineNo">638</span>      }<a name="line.638"></a>
-<span class="sourceLineNo">639</span>    }<a name="line.639"></a>
-<span class="sourceLineNo">640</span>  }<a name="line.640"></a>
-<span class="sourceLineNo">641</span><a name="line.641"></a>
-<span class="sourceLineNo">642</span>  //////////////////////////////////////////////////////////////////////////////////////////<a name="line.642"></a>
-<span class="sourceLineNo">643</span>  // Functions to execute observer hooks and handle results (if any)<a name="line.643"></a>
-<span class="sourceLineNo">644</span>  //////////////////////////////////////////////////////////////////////////////////////////<a name="line.644"></a>
-<span class="sourceLineNo">645</span><a name="line.645"></a>
-<span class="sourceLineNo">646</span>  /**<a name="line.646"></a>
-<span class="sourceLineNo">647</span>   * Do not call with an observerOperation that is null! Have the caller check.<a name="line.647"></a>
-<span class="sourceLineNo">648</span>   */<a name="line.648"></a>
-<span class="sourceLineNo">649</span>  protected &lt;O, R&gt; R execOperationWithResult(<a name="line.649"></a>
-<span class="sourceLineNo">650</span>      final ObserverOperationWithResult&lt;O, R&gt; observerOperation) throws IOException {<a name="line.650"></a>
-<span class="sourceLineNo">651</span>    boolean bypass = execOperation(observerOperation);<a name="line.651"></a>
-<span class="sourceLineNo">652</span>    R result = observerOperation.getResult();<a name="line.652"></a>
-<span class="sourceLineNo">653</span>    return bypass == observerOperation.isBypassable()? result: null;<a name="line.653"></a>
-<span class="sourceLineNo">654</span>  }<a name="line.654"></a>
-<span class="sourceLineNo">655</span><a name="line.655"></a>
-<span class="sourceLineNo">656</span>  /**<a name="line.656"></a>
-<span class="sourceLineNo">657</span>   * @return True if we are to bypass (Can only be &lt;code&gt;true&lt;/code&gt; if<a name="line.657"></a>
-<span class="sourceLineNo">658</span>   * ObserverOperation#isBypassable().<a name="line.658"></a>
-<span class="sourceLineNo">659</span>   */<a name="line.659"></a>
-<span class="sourceLineNo">660</span>  protected &lt;O&gt; boolean execOperation(final ObserverOperation&lt;O&gt; observerOperation)<a name="line.660"></a>
-<span class="sourceLineNo">661</span>      throws IOException {<a name="line.661"></a>
-<span class="sourceLineNo">662</span>    boolean bypass = false;<a name="line.662"></a>
-<span class="sourceLineNo">663</span>    if (observerOperation == null) {<a name="line.663"></a>
-<span class="sourceLineNo">664</span>      return bypass;<a name="line.664"></a>
-<span class="sourceLineNo">665</span>    }<a name="line.665"></a>
-<span class="sourceLineNo">666</span>    List&lt;E&gt; envs = coprocEnvironments.get();<a name="line.666"></a>
-<span class="sourceLineNo">667</span>    for (E env : envs) {<a name="line.667"></a>
-<span class="sourceLineNo">668</span>      observerOperation.prepare(env);<a name="line.668"></a>
-<span class="sourceLineNo">669</span>      Thread currentThread = Thread.currentThread();<a name="line.669"></a>
-<span class="sourceLineNo">670</span>      ClassLoader cl = currentThread.getContextClassLoader();<a name="line.670"></a>
-<span class="sourceLineNo">671</span>      try {<a name="line.671"></a>
-<span class="sourceLineNo">672</span>        currentThread.setContextClassLoader(env.getClassLoader());<a name="line.672"></a>
-<span class="sourceLineNo">673</span>        observerOperation.callObserver();<a name="line.673"></a>
-<span class="sourceLineNo">674</span>      } catch (Throwable e) {<a name="line.674"></a>
-<span class="sourceLineNo">675</span>        handleCoprocessorThrowable(env, e);<a name="line.675"></a>
-<span class="sourceLineNo">676</span>      } finally {<a name="line.676"></a>
-<span class="sourceLineNo">677</span>        currentThread.setContextClassLoader(cl);<a name="line.677"></a>
-<span class="sourceLineNo">678</span>      }<a name="line.678"></a>
-<span class="sourceLineNo">679</span>      // Internal to shouldBypass, it checks if obeserverOperation#isBypassable().<a name="line.679"></a>
-<span class="sourceLineNo">680</span>      bypass |= observerOperation.shouldBypass();<a name="line.680"></a>
-<span class="sourceLineNo">681</span>      // Internal to shouldComplete, it checks if obeserverOperation#isCompletable().<a name="line.681"></a>
-<span class="sourceLineNo">682</span>      if (observerOperation.shouldComplete()) {<a name="line.682"></a>
-<span class="sourceLineNo">683</span>        break;<a name="line.683"></a>
-<span class="sourceLineNo">684</span>      }<a name="line.684"></a>
-<span class="sourceLineNo">685</span>      observerOperation.postEnvCall();<a name="line.685"></a>
-<span class="sourceLineNo">686</span>    }<a name="line.686"></a>
-<span class="sourceLineNo">687</span>    return bypass;<a name="line.687"></a>
-<span class="sourceLineNo">688</span>  }<a name="line.688"></a>
-<span class="sourceLineNo">689</span><a name="line.689"></a>
-<span class="sourceLineNo">690</span>  /**<a name="line.690"></a>
-<span class="sourceLineNo">691</span>   * Coprocessor classes can be configured in any order, based on that priority is set and<a name="line.691"></a>
-<span class="sourceLineNo">692</span>   * chained in a sorted order. Should be used preStop*() hooks i.e. when master/regionserver is<a name="line.692"></a>
-<span class="sourceLineNo">693</span>   * going down. This function first calls coprocessor methods (using ObserverOperation.call())<a name="line.693"></a>
-<span class="sourceLineNo">694</span>   * and then shutdowns the environment in postEnvCall(). &lt;br&gt;<a name="line.694"></a>
-<span class="sourceLineNo">695</span>   * Need to execute all coprocessor methods first then postEnvCall(), otherwise some coprocessors<a name="line.695"></a>
-<span class="sourceLineNo">696</span>   * may remain shutdown if any exception occurs during next coprocessor execution which prevent<a name="line.696"></a>
-<span class="sourceLineNo">697</span>   * master/regionserver stop or cluster shutdown. (Refer:<a name="line.697"></a>
-<span class="sourceLineNo">698</span>   * &lt;a href="https://issues.apache.org/jira/browse/HBASE-16663"&gt;HBASE-16663&lt;/a&gt;<a name="line.698"></a>
-<span class="sourceLineNo">699</span>   * @return true if bypaas coprocessor execution, false if not.<a name="line.699"></a>
-<span class="sourceLineNo">700</span>   * @throws IOException<a name="line.700"></a>
-<span class="sourceLineNo">701</span>   */<a name="line.701"></a>
-<span class="sourceLineNo">702</span>  protected &lt;O&gt; boolean execShutdown(final ObserverOperation&lt;O&gt; observerOperation)<a name="line.702"></a>
-<span class="sourceLineNo">703</span>      throws IOException {<a name="line.703"></a>
-<span class="sourceLineNo">704</span>    if (observerOperation == null) return false;<a name="line.704"></a>
-<span class="sourceLineNo">705</span>    boolean bypass = false;<a name="line.705"></a>
-<span class="sourceLineNo">706</span>    List&lt;E&gt; envs = coprocEnvironments.get();<a name="line.706"></a>
-<span class="sourceLineNo">707</span>    // Iterate the coprocessors and execute ObserverOperation's call()<a name="line.707"></a>
-<span class="sourceLineNo">708</span>    for (E env : envs) {<a name="line.708"></a>
-<span class="sourceLineNo">709</span>      observerOperation.prepare(env);<a name="line.709"></a>
-<span class="sourceLineNo">710</span>      Thread currentThread = Thread.currentThread();<a name="line.710"></a>
-<span class="sourceLineNo">711</span>      ClassLoader cl = currentThread.getContextClassLoader();<a name="line.711"></a>
-<span class="sourceLineNo">712</span>      try {<a name="line.712"></a>
-<span class="sourceLineNo">713</span>        currentThread.setContextClassLoader(env.getClassLoader());<a name="line.713"></a>
-<span class="sourceLineNo">714</span>        observerOperation.callObserver();<a name="line.714"></a>
-<span class="sourceLineNo">715</span>      } catch (Throwable e) {<a name="line.715"></a>
-<span class="sourceLineNo">716</span>        handleCoprocessorThrowable(env, e);<a name="line.716"></a>
-<span class="sourceLineNo">717</span>      } finally {<a name="line.717"></a>
-<span class="sourceLineNo">718</span>        currentThread.setContextClassLoader(cl);<a name="line.718"></a>
-<span class="sourceLineNo">719</span>      }<a name="line.719"></a>
-<span class="sourceLineNo">720</span>      bypass |= observerOperation.shouldBypass();<a name="line.720"></a>
-<span class="sourceLineNo">721</span>      if (observerOperation.shouldComplete()) {<a name="line.721"></a>
-<span class="sourceLineNo">722</span>        break;<a name="line.722"></a>
-<span class="sourceLineNo">723</span>      }<a name="line.723"></a>
-<span class="sourceLineNo">724</span>    }<a name="line.724"></a>
-<span class="sourceLineNo">725</span><a name="line.725"></a>
-<span class="sourceLineNo">726</span>    // Iterate the coprocessors and execute ObserverOperation's postEnvCall()<a name="line.726"></a>
-<span class="sourceLineNo">727</span>    for (E env : envs) {<a name="line.727"></a>
-<span class="sourceLineNo">728</span>      observerOperation.prepare(env);<a name="line.728"></a>
-<span class="sourceLineNo">729</span>      observerOperation.postEnvCall();<a name="line.729"></a>
-<span class="sourceLineNo">730</span>    }<a name="line.730"></a>
-<span class="sourceLineNo">731</span>    return bypass;<a name="line.731"></a>
-<span class="sourceLineNo">732</span>  }<a name="line.732"></a>
-<span class="sourceLineNo">733</span>}<a name="line.733"></a>
+<span class="sourceLineNo">562</span>      super(user != null? user: RpcServer.getRequestUser().orElse(null), bypassable);<a name="line.562"></a>
+<span class="sourceLineNo">563</span>      this.observerGetter = observerGetter;<a name="line.563"></a>
+<span class="sourceLineNo">564</span>    }<a name="line.564"></a>
+<span class="sourceLineNo">565</span><a name="line.565"></a>
+<span class="sourceLineNo">566</span>    abstract void callObserver() throws IOException;<a name="line.566"></a>
+<span class="sourceLineNo">567</span>    protected void postEnvCall() {}<a name="line.567"></a>
+<span class="sourceLineNo">568</span>  }<a name="line.568"></a>
+<span class="sourceLineNo">569</span><a name="line.569"></a>
+<span class="sourceLineNo">570</span>  // Can't derive ObserverOperation from ObserverOperationWithResult (R = Void) because then all<a name="line.570"></a>
+<span class="sourceLineNo">571</span>  // ObserverCaller implementations will have to have a return statement.<a name="line.571"></a>
+<span class="sourceLineNo">572</span>  // O = observer, E = environment, C = coprocessor, R=result type<a name="line.572"></a>
+<span class="sourceLineNo">573</span>  public abstract class ObserverOperationWithoutResult&lt;O&gt; extends ObserverOperation&lt;O&gt; {<a name="line.573"></a>
+<span class="sourceLineNo">574</span>    protected abstract void call(O observer) throws IOException;<a name="line.574"></a>
+<span class="sourceLineNo">575</span><a name="line.575"></a>
+<span class="sourceLineNo">576</span>    public ObserverOperationWithoutResult(ObserverGetter&lt;C, O&gt; observerGetter) {<a name="line.576"></a>
+<span class="sourceLineNo">577</span>      super(observerGetter);<a name="line.577"></a>
+<span class="sourceLineNo">578</span>    }<a name="line.578"></a>
+<span class="sourceLineNo">579</span><a name="line.579"></a>
+<span class="sourceLineNo">580</span>    public ObserverOperationWithoutResult(ObserverGetter&lt;C, O&gt; observerGetter, User user) {<a name="line.580"></a>
+<span class="sourceLineNo">581</span>      super(observerGetter, user);<a name="line.581"></a>
+<span class="sourceLineNo">582</span>    }<a name="line.582"></a>
+<span class="sourceLineNo">583</span><a name="line.583"></a>
+<span class="sourceLineNo">584</span>    public ObserverOperationWithoutResult(ObserverGetter&lt;C, O&gt; observerGetter, User user,<a name="line.584"></a>
+<span class="sourceLineNo">585</span>        boolean bypassable) {<a name="line.585"></a>
+<span class="sourceLineNo">586</span>      super(observerGetter, user, bypassable);<a name="line.586"></a>
+<span class="sourceLineNo">587</span>    }<a name="line.587"></a>
+<span class="sourceLineNo">588</span><a name="line.588"></a>
+<span class="sourceLineNo">589</span>    /**<a name="line.589"></a>
+<span class="sourceLineNo">590</span>     * In case of coprocessors which have many kinds of observers (for eg, {@link RegionCoprocessor}<a name="line.590"></a>
+<span class="sourceLineNo">591</span>     * has BulkLoadObserver, RegionObserver, etc), some implementations may not need all<a name="line.591"></a>
+<span class="sourceLineNo">592</span>     * observers, in which case they will return null for that observer's getter.<a name="line.592"></a>
+<span class="sourceLineNo">593</span>     * We simply ignore such cases.<a name="line.593"></a>
+<span class="sourceLineNo">594</span>     */<a name="line.594"></a>
+<span class="sourceLineNo">595</span>    @Override<a name="line.595"></a>
+<span class="sourceLineNo">596</span>    void callObserver() throws IOException {<a name="line.596"></a>
+<span class="sourceLineNo">597</span>      Optional&lt;O&gt; observer = observerGetter.apply(getEnvironment().getInstance());<a name="line.597"></a>
+<span class="sourceLineNo">598</span>      if (observer.isPresent()) {<a name="line.598"></a>
+<span class="sourceLineNo">599</span>        call(observer.get());<a name="line.599"></a>
+<span class="sourceLineNo">600</span>      }<a name="line.600"></a>
+<span class="sourceLineNo">601</span>    }<a name="line.601"></a>
+<span class="sourceLineNo">602</span>  }<a name="line.602"></a>
+<span class="sourceLineNo">603</span><a name="line.603"></a>
+<span class="sourceLineNo">604</span>  public abstract class ObserverOperationWithResult&lt;O, R&gt; extends ObserverOperation&lt;O&gt; {<a name="line.604"></a>
+<span class="sourceLineNo">605</span>    protected abstract R call(O observer) throws IOException;<a name="line.605"></a>
+<span class="sourceLineNo">606</span><a name="line.606"></a>
+<span class="sourceLineNo">607</span>    private R result;<a name="line.607"></a>
+<span class="sourceLineNo">608</span><a name="line.608"></a>
+<span class="sourceLineNo">609</span>    public ObserverOperationWithResult(ObserverGetter&lt;C, O&gt; observerGetter, R result) {<a name="line.609"></a>
+<span class="sourceLineNo">610</span>      this(observerGetter, result, false);<a name="line.610"></a>
+<span class="sourceLineNo">611</span>    }<a name="line.611"></a>
+<span class="sourceLineNo">612</span><a name="line.612"></a>
+<span class="sourceLineNo">613</span>    public ObserverOperationWithResult(ObserverGetter&lt;C, O&gt; observerGetter, R result,<a name="line.613"></a>
+<span class="sourceLineNo">614</span>        boolean bypassable) {<a name="line.614"></a>
+<span class="sourceLineNo">615</span>      this(observerGetter, result, null, bypassable);<a name="line.615"></a>
+<span class="sourceLineNo">616</span>    }<a name="line.616"></a>
+<span class="sourceLineNo">617</span><a name="line.617"></a>
+<span class="sourceLineNo">618</span>    public ObserverOperationWithResult(ObserverGetter&lt;C, O&gt; observerGetter, R result,<a name="line.618"></a>
+<span class="sourceLineNo">619</span>        User user) {<a name="line.619"></a>
+<span class="sourceLineNo">620</span>      this(observerGetter, result, user, false);<a name="line.620"></a>
+<span class="sourceLineNo">621</span>    }<a name="line.621"></a>
+<span class="sourceLineNo">622</span><a name="line.622"></a>
+<span class="sourceLineNo">623</span>    private ObserverOperationWithResult(ObserverGetter&lt;C, O&gt; observerGetter, R result, User user,<a name="line.623"></a>
+<span class="sourceLineNo">624</span>        boolean bypassable) {<a name="line.624"></a>
+<span class="sourceLineNo">625</span>      super(observerGetter, user, bypassable);<a name="line.625"></a>
+<span class="sourceLineNo">626</span>      this.result = result;<a name="line.626"></a>
+<span class="sourceLineNo">627</span>    }<a name="line.627"></a>
+<span class="sourceLineNo">628</span><a name="line.628"></a>
+<span class="sourceLineNo">629</span>    protected R getResult() {<a name="line.629"></a>
+<span class="sourceLineNo">630</span>      return this.result;<a name="line.630"></a>
+<span class="sourceLineNo">631</span>    }<a name="line.631"></a>
+<span class="sourceLineNo">632</span><a name="line.632"></a>
+<span class="sourceLineNo">633</span>    void callObserver() throws IOException {<a name="line.633"></a>
+<span class="sourceLineNo">634</span>      Optional&lt;O&gt; observer = observerGetter.apply(getEnvironment().getInstance());<a name="line.634"></a>
+<span class="sourceLineNo">635</span>      if (observer.isPresent()) {<a name="line.635"></a>
+<span class="sourceLineNo">636</span>        result = call(observer.get());<a name="line.636"></a>
+<span class="sourceLineNo">637</span>      }<a name="line.637"></a>
+<span class="sourceLineNo">638</span>    }<a name="line.638"></a>
+<span class="sourceLineNo">639</span>  }<a name="line.639"></a>
+<span class="sourceLineNo">640</span><a name="line.640"></a>
+<span class="sourceLineNo">641</span>  //////////////////////////////////////////////////////////////////////////////////////////<a name="line.641"></a>
+<span class="sourceLineNo">642</span>  // Functions to execute observer hooks and handle results (if any)<a name="line.642"></a>
+<span class="sourceLineNo">643</span>  //////////////////////////////////////////////////////////////////////////////////////////<a name="line.643"></a>
+<span class="sourceLineNo">644</span><a name="line.644"></a>
+<span class="sourceLineNo">645</span>  /**<a name="line.645"></a>
+<span class="sourceLineNo">646</span>   * Do not call with an observerOperation that is null! Have the caller check.<a name="line.646"></a>
+<span class="sourceLineNo">647</span>   */<a name="line.647"></a>
+<span class="sourceLineNo">648</span>  protected &lt;O, R&gt; R execOperationWithResult(<a name="line.648"></a>
+<span class="sourceLineNo">649</span>      final ObserverOperationWithResult&lt;O, R&gt; observerOperation) throws IOException {<a name="line.649"></a>
+<span class="sourceLineNo">650</span>    boolean bypass = execOperation(observerOperation);<a name="line.650"></a>
+<span class="sourceLineNo">651</span>    R result = observerOperation.getResult();<a name="line.651"></a>
+<span class="sourceLineNo">652</span>    return bypass == observerOperation.isBypassable()? result: null;<a name="line.652"></a>
+<span class="sourceLineNo">653</span>  }<a name="line.653"></a>
+<span class="sourceLineNo">654</span><a name="line.654"></a>
+<span class="sourceLineNo">655</span>  /**<a name="line.655"></a>
+<span class="sourceLineNo">656</span>   * @return True if we are to bypass (Can only be &lt;code&gt;true&lt;/code&gt; if<a name="line.656"></a>
+<span class="sourceLineNo">657</span>   * ObserverOperation#isBypassable().<a name="line.657"></a>
+<span class="sourceLineNo">658</span>   */<a name="line.658"></a>
+<span class="sourceLineNo">659</span>  protected &lt;O&gt; boolean execOperation(final ObserverOperation&lt;O&gt; observerOperation)<a name="line.659"></a>
+<span class="sourceLineNo">660</span>      throws IOException {<a name="line.660"></a>
+<span class="sourceLineNo">661</span>    boolean bypass = false;<a name="line.661"></a>
+<span class="sourceLineNo">662</span>    if (observerOperation == null) {<a name="line.662"></a>
+<span class="sourceLineNo">663</span>      return bypass;<a name="line.663"></a>
+<span class="sourceLineNo">664</span>    }<a name="line.664"></a>
+<span class="sourceLineNo">665</span>    List&lt;E&gt; envs = coprocEnvironments.get();<a name="line.665"></a>
+<span class="sourceLineNo">666</span>    for (E env : envs) {<a name="line.666"></a>
+<span class="sourceLineNo">667</span>      observerOperation.prepare(env);<a name="line.667"></a>
+<span class="sourceLineNo">668</span>      Thread currentThread = Thread.currentThread();<a name="line.668"></a>
+<span class="sourceLineNo">669</span>      ClassLoader cl = currentThread.getContextClassLoader();<a name="line.669"></a>
+<span class="sourceLineNo">670</span>      try {<a name="line.670"></a>
+<span class="sourceLineNo">671</span>        currentThread.setContextClassLoader(env.getClassLoader());<a name="line.671"></a>
+<span class="sourceLineNo">672</span>        observerOperation.callObserver();<a name="line.672"></a>
+<span class="sourceLineNo">673</span>      } catch (Throwable e) {<a name="line.673"></a>
+<span class="sourceLineNo">674</span>        handleCoprocessorThrowable(env, e);<a name="line.674"></a>
+<span class="sourceLineNo">675</span>      } finally {<a name="line.675"></a>
+<span class="sourceLineNo">676</span>        currentThread.setContextClassLoader(cl);<a name="line.676"></a>
+<span class="sourceLineNo">677</span>      }<a name="line.677"></a>
+<span class="sourceLineNo">678</span>      // Internal to shouldBypass, it checks if obeserverOperation#isBypassable().<a name="line.678"></a>
+<span class="sourceLineNo">679</span>      bypass |= observerOperation.shouldBypass();<a name="line.679"></a>
+<span class="sourceLineNo">680</span>      observerOperation.postEnvCall();<a name="line.680"></a>
+<span class="sourceLineNo">681</span>    }<a name="line.681"></a>
+<span class="sourceLineNo">682</span>    return bypass;<a name="line.682"></a>
+<span class="sourceLineNo">683</span>  }<a name="line.683"></a>
+<span class="sourceLineNo">684</span><a name="line.684"></a>
+<span class="sourceLineNo">685</span>  /**<a name="line.685"></a>
+<span class="sourceLineNo">686</span>   * Coprocessor classes can be configured in any order, based on that priority is set and<a name="line.686"></a>
+<span class="sourceLineNo">687</span>   * chained in a sorted order. Should be used preStop*() hooks i.e. when master/regionserver is<a name="line.687"></a>
+<span class="sourceLineNo">688</span>   * going down. This function first calls coprocessor methods (using ObserverOperation.call())<a name="line.688"></a>
+<span class="sourceLineNo">689</span>   * and then shutdowns the environment in postEnvCall(). &lt;br&gt;<a name="line.689"></a>
+<span class="sourceLineNo">690</span>   * Need to execute all coprocessor methods first then postEnvCall(), otherwise some coprocessors<a name="line.690"></a>
+<span class="sourceLineNo">691</span>   * may remain shutdown if any exception occurs during next coprocessor execution which prevent<a name="line.691"></a>
+<span class="sourceLineNo">692</span>   * master/regionserver stop or cluster shutdown. (Refer:<a name="line.692"></a>
+<span class="sourceLineNo">693</span>   * &lt;a href="https://issues.apache.org/jira/browse/HBASE-16663"&gt;HBASE-16663&lt;/a&gt;<a name="line.693"></a>
+<span class="sourceLineNo">694</span>   * @return true if bypaas coprocessor execution, false if not.<a name="line.694"></a>
+<span class="sourceLineNo">695</span>   * @throws IOException<a name="line.695"></a>
+<span class="sourceLineNo">696</span>   */<a name="line.696"></a>
+<span class="sourceLineNo">697</span>  protected &lt;O&gt; boolean execShutdown(final ObserverOperation&lt;O&gt; observerOperation)<a name="line.697"></a>
+<span class="sourceLineNo">698</span>      throws IOException {<a name="line.698"></a>
+<span class="sourceLineNo">699</span>    if (observerOperation == null) return false;<a name="line.699"></a>
+<span class="sourceLineNo">700</span>    boolean bypass = false;<a name="line.700"></a>
+<span class="sourceLineNo">701</span>    List&lt;E&gt; envs = coprocEnvironments.get();<a name="line.701"></a>
+<span class="sourceLineNo">702</span>    // Iterate the coprocessors and execute ObserverOperation's call()<a name="line.702"></a>
+<span class="sourceLineNo">703</span>    for (E env : envs) {<a name="line.703"></a>
+<span class="sourceLineNo">704</span>      observerOperation.prepare(env);<a name="line.704"></a>
+<span class="sourceLineNo">705</span>      Thread currentThread = Thread.currentThread();<a name="line.705"></a>
+<span class="sourceLineNo">706</span>      ClassLoader cl = currentThread.getContextClassLoader();<a name="line.706"></a>
+<span class="sourceLineNo">707</span>      try {<a name="line.707"></a>
+<span class="sourceLineNo">708</span>        currentThread.setContextClassLoader(env.getClassLoader());<a name="line.708"></a>
+<span class="sourceLineNo">709</span>        observerOperation.callObserver();<a name="line.709"></a>
+<span class="sourceLineNo">710</span>      } catch (Throwable e) {<a name="line.710"></a>
+<span class="sourceLineNo">711</span>        handleCoprocessorThrowable(env, e);<a name="line.711"></a>
+<span class="sourceLineNo">712</span>      } finally {<a name="line.712"></a>
+<span class="sourceLineNo">713</span>        currentThread.setContextClassLoader(cl);<a name="line.713"></a>
+<span class="sourceLineNo">714</span>      }<a name="line.714"></a>
+<span class="sourceLineNo">715</span>      bypass |= observerOperation.shouldBypass();<a name="line.715"></a>
+<span class="sourceLineNo">716</span>    }<a name="line.716"></a>
+<span class="sourceLineNo">717</span><a name="line.717"></a>
+<span class="sourceLineNo">718</span>    // Iterate the coprocessors and execute ObserverOperation's postEnvCall()<a name="line.718"></a>
+<span class="sourceLineNo">719</span>    for (E env : envs) {<a name="line.719"></a>
+<span class="sourceLineNo">720</span>      observerOperation.prepare(env);<a name="line.720"></a>
+<span class="sourceLineNo">721</span>      observerOperation.postEnvCall();<a name="line.721"></a>
+<span class="sourceLineNo">722</span>    }<a name="line.722"></a>
+<span class="sourceLineNo">723</span>    return bypass;<a name="line.723"></a>
+<span class="sourceLineNo">724</span>  }<a name="line.724"></a>
+<span class="sourceLineNo">725</span>}<a name="line.725"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/2424a45f/devapidocs/src-html/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.ObserverOperationWithResult.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.ObserverOperationWithResult.html b/devapidocs/src-html/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.ObserverOperationWithResult.html
index 61dceae..7f3de9e 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.ObserverOperationWithResult.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.ObserverOperationWithResult.html
@@ -567,178 +567,170 @@
 <span class="sourceLineNo">559</span>    }<a name="line.559"></a>
 <span class="sourceLineNo">560</span><a name="line.560"></a>
 <span class="sourceLineNo">561</span>    ObserverOperation(ObserverGetter&lt;C, O&gt; observerGetter, User user, boolean bypassable) {<a name="line.561"></a>
-<span class="sourceLineNo">562</span>      super(user != null? user: RpcServer.getRequestUser().orElse(null),<a name="line.562"></a>
-<span class="sourceLineNo">563</span>          bypassable, bypassable/*'completable': make completable same as bypassable*/);<a name="line.563"></a>
-<span class="sourceLineNo">564</span>      this.observerGetter = observerGetter;<a name="line.564"></a>
-<span class="sourceLineNo">565</span>    }<a name="line.565"></a>
-<span class="sourceLineNo">566</span><a name="line.566"></a>
-<span class="sourceLineNo">567</span>    abstract void callObserver() throws IOException;<a name="line.567"></a>
-<span class="sourceLineNo">568</span>    protected void postEnvCall() {}<a name="line.568"></a>
-<span class="sourceLineNo">569</span>  }<a name="line.569"></a>
-<span class="sourceLineNo">570</span><a name="line.570"></a>
-<span class="sourceLineNo">571</span>  // Can't derive ObserverOperation from ObserverOperationWithResult (R = Void) because then all<a name="line.571"></a>
-<span class="sourceLineNo">572</span>  // ObserverCaller implementations will have to have a return statement.<a name="line.572"></a>
-<span class="sourceLineNo">573</span>  // O = observer, E = environment, C = coprocessor, R=result type<a name="line.573"></a>
-<span class="sourceLineNo">574</span>  public abstract class ObserverOperationWithoutResult&lt;O&gt; extends ObserverOperation&lt;O&gt; {<a name="line.574"></a>
-<span class="sourceLineNo">575</span>    protected abstract void call(O observer) throws IOException;<a name="line.575"></a>
-<span class="sourceLineNo">576</span><a name="line.576"></a>
-<span class="sourceLineNo">577</span>    public ObserverOperationWithoutResult(ObserverGetter&lt;C, O&gt; observerGetter) {<a name="line.577"></a>
-<span class="sourceLineNo">578</span>      super(observerGetter);<a name="line.578"></a>
-<span class="sourceLineNo">579</span>    }<a name="line.579"></a>
-<span class="sourceLineNo">580</span><a name="line.580"></a>
-<span class="sourceLineNo">581</span>    public ObserverOperationWithoutResult(ObserverGetter&lt;C, O&gt; observerGetter, User user) {<a name="line.581"></a>
-<span class="sourceLineNo">582</span>      super(observerGetter, user);<a name="line.582"></a>
-<span class="sourceLineNo">583</span>    }<a name="line.583"></a>
-<span class="sourceLineNo">584</span><a name="line.584"></a>
-<span class="sourceLineNo">585</span>    public ObserverOperationWithoutResult(ObserverGetter&lt;C, O&gt; observerGetter, User user,<a name="line.585"></a>
-<span class="sourceLineNo">586</span>        boolean bypassable) {<a name="line.586"></a>
-<span class="sourceLineNo">587</span>      super(observerGetter, user, bypassable);<a name="line.587"></a>
-<span class="sourceLineNo">588</span>    }<a name="line.588"></a>
-<span class="sourceLineNo">589</span><a name="line.589"></a>
-<span class="sourceLineNo">590</span>    /**<a name="line.590"></a>
-<span class="sourceLineNo">591</span>     * In case of coprocessors which have many kinds of observers (for eg, {@link RegionCoprocessor}<a name="line.591"></a>
-<span class="sourceLineNo">592</span>     * has BulkLoadObserver, RegionObserver, etc), some implementations may not need all<a name="line.592"></a>
-<span class="sourceLineNo">593</span>     * observers, in which case they will return null for that observer's getter.<a name="line.593"></a>
-<span class="sourceLineNo">594</span>     * We simply ignore such cases.<a name="line.594"></a>
-<span class="sourceLineNo">595</span>     */<a name="line.595"></a>
-<span class="sourceLineNo">596</span>    @Override<a name="line.596"></a>
-<span class="sourceLineNo">597</span>    void callObserver() throws IOException {<a name="line.597"></a>
-<span class="sourceLineNo">598</span>      Optional&lt;O&gt; observer = observerGetter.apply(getEnvironment().getInstance());<a name="line.598"></a>
-<span class="sourceLineNo">599</span>      if (observer.isPresent()) {<a name="line.599"></a>
-<span class="sourceLineNo">600</span>        call(observer.get());<a name="line.600"></a>
-<span class="sourceLineNo">601</span>      }<a name="line.601"></a>
-<span class="sourceLineNo">602</span>    }<a name="line.602"></a>
-<span class="sourceLineNo">603</span>  }<a name="line.603"></a>
-<span class="sourceLineNo">604</span><a name="line.604"></a>
-<span class="sourceLineNo">605</span>  public abstract class ObserverOperationWithResult&lt;O, R&gt; extends ObserverOperation&lt;O&gt; {<a name="line.605"></a>
-<span class="sourceLineNo">606</span>    protected abstract R call(O observer) throws IOException;<a name="line.606"></a>
-<span class="sourceLineNo">607</span><a name="line.607"></a>
-<span class="sourceLineNo">608</span>    private R result;<a name="line.608"></a>
-<span class="sourceLineNo">609</span><a name="line.609"></a>
-<span class="sourceLineNo">610</span>    public ObserverOperationWithResult(ObserverGetter&lt;C, O&gt; observerGetter, R result) {<a name="line.610"></a>
-<span class="sourceLineNo">611</span>      this(observerGetter, result, false);<a name="line.611"></a>
-<span class="sourceLineNo">612</span>    }<a name="line.612"></a>
-<span class="sourceLineNo">613</span><a name="line.613"></a>
-<span class="sourceLineNo">614</span>    public ObserverOperationWithResult(ObserverGetter&lt;C, O&gt; observerGetter, R result,<a name="line.614"></a>
-<span class="sourceLineNo">615</span>        boolean bypassable) {<a name="line.615"></a>
-<span class="sourceLineNo">616</span>      this(observerGetter, result, null, bypassable);<a name="line.616"></a>
-<span class="sourceLineNo">617</span>    }<a name="line.617"></a>
-<span class="sourceLineNo">618</span><a name="line.618"></a>
-<span class="sourceLineNo">619</span>    public ObserverOperationWithResult(ObserverGetter&lt;C, O&gt; observerGetter, R result,<a name="line.619"></a>
-<span class="sourceLineNo">620</span>        User user) {<a name="line.620"></a>
-<span class="sourceLineNo">621</span>      this(observerGetter, result, user, false);<a name="line.621"></a>
-<span class="sourceLineNo">622</span>    }<a name="line.622"></a>
-<span class="sourceLineNo">623</span><a name="line.623"></a>
-<span class="sourceLineNo">624</span>    private ObserverOperationWithResult(ObserverGetter&lt;C, O&gt; observerGetter, R result, User user,<a name="line.624"></a>
-<span class="sourceLineNo">625</span>        boolean bypassable) {<a name="line.625"></a>
-<span class="sourceLineNo">626</span>      super(observerGetter, user, bypassable);<a name="line.626"></a>
-<span class="sourceLineNo">627</span>      this.result = result;<a name="line.627"></a>
-<span class="sourceLineNo">628</span>    }<a name="line.628"></a>
-<span class="sourceLineNo">629</span><a name="line.629"></a>
-<span class="sourceLineNo">630</span>    protected R getResult() {<a name="line.630"></a>
-<span class="sourceLineNo">631</span>      return this.result;<a name="line.631"></a>
-<span class="sourceLineNo">632</span>    }<a name="line.632"></a>
-<span class="sourceLineNo">633</span><a name="line.633"></a>
-<span class="sourceLineNo">634</span>    void callObserver() throws IOException {<a name="line.634"></a>
-<span class="sourceLineNo">635</span>      Optional&lt;O&gt; observer = observerGetter.apply(getEnvironment().getInstance());<a name="line.635"></a>
-<span class="sourceLineNo">636</span>      if (observer.isPresent()) {<a name="line.636"></a>
-<span class="sourceLineNo">637</span>        result = call(observer.get());<a name="line.637"></a>
-<span class="sourceLineNo">638</span>      }<a name="line.638"></a>
-<span class="sourceLineNo">639</span>    }<a name="line.639"></a>
-<span class="sourceLineNo">640</span>  }<a name="line.640"></a>
-<span class="sourceLineNo">641</span><a name="line.641"></a>
-<span class="sourceLineNo">642</span>  //////////////////////////////////////////////////////////////////////////////////////////<a name="line.642"></a>
-<span class="sourceLineNo">643</span>  // Functions to execute observer hooks and handle results (if any)<a name="line.643"></a>
-<span class="sourceLineNo">644</span>  //////////////////////////////////////////////////////////////////////////////////////////<a name="line.644"></a>
-<span class="sourceLineNo">645</span><a name="line.645"></a>
-<span class="sourceLineNo">646</span>  /**<a name="line.646"></a>
-<span class="sourceLineNo">647</span>   * Do not call with an observerOperation that is null! Have the caller check.<a name="line.647"></a>
-<span class="sourceLineNo">648</span>   */<a name="line.648"></a>
-<span class="sourceLineNo">649</span>  protected &lt;O, R&gt; R execOperationWithResult(<a name="line.649"></a>
-<span class="sourceLineNo">650</span>      final ObserverOperationWithResult&lt;O, R&gt; observerOperation) throws IOException {<a name="line.650"></a>
-<span class="sourceLineNo">651</span>    boolean bypass = execOperation(observerOperation);<a name="line.651"></a>
-<span class="sourceLineNo">652</span>    R result = observerOperation.getResult();<a name="line.652"></a>
-<span class="sourceLineNo">653</span>    return bypass == observerOperation.isBypassable()? result: null;<a name="line.653"></a>
-<span class="sourceLineNo">654</span>  }<a name="line.654"></a>
-<span class="sourceLineNo">655</span><a name="line.655"></a>
-<span class="sourceLineNo">656</span>  /**<a name="line.656"></a>
-<span class="sourceLineNo">657</span>   * @return True if we are to bypass (Can only be &lt;code&gt;true&lt;/code&gt; if<a name="line.657"></a>
-<span class="sourceLineNo">658</span>   * ObserverOperation#isBypassable().<a name="line.658"></a>
-<span class="sourceLineNo">659</span>   */<a name="line.659"></a>
-<span class="sourceLineNo">660</span>  protected &lt;O&gt; boolean execOperation(final ObserverOperation&lt;O&gt; observerOperation)<a name="line.660"></a>
-<span class="sourceLineNo">661</span>      throws IOException {<a name="line.661"></a>
-<span class="sourceLineNo">662</span>    boolean bypass = false;<a name="line.662"></a>
-<span class="sourceLineNo">663</span>    if (observerOperation == null) {<a name="line.663"></a>
-<span class="sourceLineNo">664</span>      return bypass;<a name="line.664"></a>
-<span class="sourceLineNo">665</span>    }<a name="line.665"></a>
-<span class="sourceLineNo">666</span>    List&lt;E&gt; envs = coprocEnvironments.get();<a name="line.666"></a>
-<span class="sourceLineNo">667</span>    for (E env : envs) {<a name="line.667"></a>
-<span class="sourceLineNo">668</span>      observerOperation.prepare(env);<a name="line.668"></a>
-<span class="sourceLineNo">669</span>      Thread currentThread = Thread.currentThread();<a name="line.669"></a>
-<span class="sourceLineNo">670</span>      ClassLoader cl = currentThread.getContextClassLoader();<a name="line.670"></a>
-<span class="sourceLineNo">671</span>      try {<a name="line.671"></a>
-<span class="sourceLineNo">672</span>        currentThread.setContextClassLoader(env.getClassLoader());<a name="line.672"></a>
-<span class="sourceLineNo">673</span>        observerOperation.callObserver();<a name="line.673"></a>
-<span class="sourceLineNo">674</span>      } catch (Throwable e) {<a name="line.674"></a>
-<span class="sourceLineNo">675</span>        handleCoprocessorThrowable(env, e);<a name="line.675"></a>
-<span class="sourceLineNo">676</span>      } finally {<a name="line.676"></a>
-<span class="sourceLineNo">677</span>        currentThread.setContextClassLoader(cl);<a name="line.677"></a>
-<span class="sourceLineNo">678</span>      }<a name="line.678"></a>
-<span class="sourceLineNo">679</span>      // Internal to shouldBypass, it checks if obeserverOperation#isBypassable().<a name="line.679"></a>
-<span class="sourceLineNo">680</span>      bypass |= observerOperation.shouldBypass();<a name="line.680"></a>
-<span class="sourceLineNo">681</span>      // Internal to shouldComplete, it checks if obeserverOperation#isCompletable().<a name="line.681"></a>
-<span class="sourceLineNo">682</span>      if (observerOperation.shouldComplete()) {<a name="line.682"></a>
-<span class="sourceLineNo">683</span>        break;<a name="line.683"></a>
-<span class="sourceLineNo">684</span>      }<a name="line.684"></a>
-<span class="sourceLineNo">685</span>      observerOperation.postEnvCall();<a name="line.685"></a>
-<span class="sourceLineNo">686</span>    }<a name="line.686"></a>
-<span class="sourceLineNo">687</span>    return bypass;<a name="line.687"></a>
-<span class="sourceLineNo">688</span>  }<a name="line.688"></a>
-<span class="sourceLineNo">689</span><a name="line.689"></a>
-<span class="sourceLineNo">690</span>  /**<a name="line.690"></a>
-<span class="sourceLineNo">691</span>   * Coprocessor classes can be configured in any order, based on that priority is set and<a name="line.691"></a>
-<span class="sourceLineNo">692</span>   * chained in a sorted order. Should be used preStop*() hooks i.e. when master/regionserver is<a name="line.692"></a>
-<span class="sourceLineNo">693</span>   * going down. This function first calls coprocessor methods (using ObserverOperation.call())<a name="line.693"></a>
-<span class="sourceLineNo">694</span>   * and then shutdowns the environment in postEnvCall(). &lt;br&gt;<a name="line.694"></a>
-<span class="sourceLineNo">695</span>   * Need to execute all coprocessor methods first then postEnvCall(), otherwise some coprocessors<a name="line.695"></a>
-<span class="sourceLineNo">696</span>   * may remain shutdown if any exception occurs during next coprocessor execution which prevent<a name="line.696"></a>
-<span class="sourceLineNo">697</span>   * master/regionserver stop or cluster shutdown. (Refer:<a name="line.697"></a>
-<span class="sourceLineNo">698</span>   * &lt;a href="https://issues.apache.org/jira/browse/HBASE-16663"&gt;HBASE-16663&lt;/a&gt;<a name="line.698"></a>
-<span class="sourceLineNo">699</span>   * @return true if bypaas coprocessor execution, false if not.<a name="line.699"></a>
-<span class="sourceLineNo">700</span>   * @throws IOException<a name="line.700"></a>
-<span class="sourceLineNo">701</span>   */<a name="line.701"></a>
-<span class="sourceLineNo">702</span>  protected &lt;O&gt; boolean execShutdown(final ObserverOperation&lt;O&gt; observerOperation)<a name="line.702"></a>
-<span class="sourceLineNo">703</span>      throws IOException {<a name="line.703"></a>
-<span class="sourceLineNo">704</span>    if (observerOperation == null) return false;<a name="line.704"></a>
-<span class="sourceLineNo">705</span>    boolean bypass = false;<a name="line.705"></a>
-<span class="sourceLineNo">706</span>    List&lt;E&gt; envs = coprocEnvironments.get();<a name="line.706"></a>
-<span class="sourceLineNo">707</span>    // Iterate the coprocessors and execute ObserverOperation's call()<a name="line.707"></a>
-<span class="sourceLineNo">708</span>    for (E env : envs) {<a name="line.708"></a>
-<span class="sourceLineNo">709</span>      observerOperation.prepare(env);<a name="line.709"></a>
-<span class="sourceLineNo">710</span>      Thread currentThread = Thread.currentThread();<a name="line.710"></a>
-<span class="sourceLineNo">711</span>      ClassLoader cl = currentThread.getContextClassLoader();<a name="line.711"></a>
-<span class="sourceLineNo">712</span>      try {<a name="line.712"></a>
-<span class="sourceLineNo">713</span>        currentThread.setContextClassLoader(env.getClassLoader());<a name="line.713"></a>
-<span class="sourceLineNo">714</span>        observerOperation.callObserver();<a name="line.714"></a>
-<span class="sourceLineNo">715</span>      } catch (Throwable e) {<a name="line.715"></a>
-<span class="sourceLineNo">716</span>        handleCoprocessorThrowable(env, e);<a name="line.716"></a>
-<span class="sourceLineNo">717</span>      } finally {<a name="line.717"></a>
-<span class="sourceLineNo">718</span>        currentThread.setContextClassLoader(cl);<a name="line.718"></a>
-<span class="sourceLineNo">719</span>      }<a name="line.719"></a>
-<span class="sourceLineNo">720</span>      bypass |= observerOperation.shouldBypass();<a name="line.720"></a>
-<span class="sourceLineNo">721</span>      if (observerOperation.shouldComplete()) {<a name="line.721"></a>
-<span class="sourceLineNo">722</span>        break;<a name="line.722"></a>
-<span class="sourceLineNo">723</span>      }<a name="line.723"></a>
-<span class="sourceLineNo">724</span>    }<a name="line.724"></a>
-<span class="sourceLineNo">725</span><a name="line.725"></a>
-<span class="sourceLineNo">726</span>    // Iterate the coprocessors and execute ObserverOperation's postEnvCall()<a name="line.726"></a>
-<span class="sourceLineNo">727</span>    for (E env : envs) {<a name="line.727"></a>
-<span class="sourceLineNo">728</span>      observerOperation.prepare(env);<a name="line.728"></a>
-<span class="sourceLineNo">729</span>      observerOperation.postEnvCall();<a name="line.729"></a>
-<span class="sourceLineNo">730</span>    }<a name="line.730"></a>
-<span class="sourceLineNo">731</span>    return bypass;<a name="line.731"></a>
-<span class="sourceLineNo">732</span>  }<a name="line.732"></a>
-<span class="sourceLineNo">733</span>}<a name="line.733"></a>
+<span class="sourceLineNo">562</span>      super(user != null? user: RpcServer.getRequestUser().orElse(null), bypassable);<a name="line.562"></a>
+<span class="sourceLineNo">563</span>      this.observerGetter = observerGetter;<a name="line.563"></a>
+<span class="sourceLineNo">564</span>    }<a name="line.564"></a>
+<span class="sourceLineNo">565</span><a name="line.565"></a>
+<span class="sourceLineNo">566</span>    abstract void callObserver() throws IOException;<a name="line.566"></a>
+<span class="sourceLineNo">567</span>    protected void postEnvCall() {}<a name="line.567"></a>
+<span class="sourceLineNo">568</span>  }<a name="line.568"></a>
+<span class="sourceLineNo">569</span><a name="line.569"></a>
+<span class="sourceLineNo">570</span>  // Can't derive ObserverOperation from ObserverOperationWithResult (R = Void) because then all<a name="line.570"></a>
+<span class="sourceLineNo">571</span>  // ObserverCaller implementations will have to have a return statement.<a name="line.571"></a>
+<span class="sourceLineNo">572</span>  // O = observer, E = environment, C = coprocessor, R=result type<a name="line.572"></a>
+<span class="sourceLineNo">573</span>  public abstract class ObserverOperationWithoutResult&lt;O&gt; extends ObserverOperation&lt;O&gt; {<a name="line.573"></a>
+<span class="sourceLineNo">574</span>    protected abstract void call(O observer) throws IOException;<a name="line.574"></a>
+<span class="sourceLineNo">575</span><a name="line.575"></a>
+<span class="sourceLineNo">576</span>    public ObserverOperationWithoutResult(ObserverGetter&lt;C, O&gt; observerGetter) {<a name="line.576"></a>
+<span class="sourceLineNo">577</span>      super(observerGetter);<a name="line.577"></a>
+<span class="sourceLineNo">578</span>    }<a name="line.578"></a>
+<span class="sourceLineNo">579</span><a name="line.579"></a>
+<span class="sourceLineNo">580</span>    public ObserverOperationWithoutResult(ObserverGetter&lt;C, O&gt; observerGetter, User user) {<a name="line.580"></a>
+<span class="sourceLineNo">581</span>      super(observerGetter, user);<a name="line.581"></a>
+<span class="sourceLineNo">582</span>    }<a name="line.582"></a>
+<span class="sourceLineNo">583</span><a name="line.583"></a>
+<span class="sourceLineNo">584</span>    public ObserverOperationWithoutResult(ObserverGetter&lt;C, O&gt; observerGetter, User user,<a name="line.584"></a>
+<span class="sourceLineNo">585</span>        boolean bypassable) {<a name="line.585"></a>
+<span class="sourceLineNo">586</span>      super(observerGetter, user, bypassable);<a name="line.586"></a>
+<span class="sourceLineNo">587</span>    }<a name="line.587"></a>
+<span class="sourceLineNo">588</span><a name="line.588"></a>
+<span class="sourceLineNo">589</span>    /**<a name="line.589"></a>
+<span class="sourceLineNo">590</span>     * In case of coprocessors which have many kinds of observers (for eg, {@link RegionCoprocessor}<a name="line.590"></a>
+<span class="sourceLineNo">591</span>     * has BulkLoadObserver, RegionObserver, etc), some implementations may not need all<a name="line.591"></a>
+<span class="sourceLineNo">592</span>     * observers, in which case they will return null for that observer's getter.<a name="line.592"></a>
+<span class="sourceLineNo">593</span>     * We simply ignore such cases.<a name="line.593"></a>
+<span class="sourceLineNo">594</span>     */<a name="line.594"></a>
+<span class="sourceLineNo">595</span>    @Override<a name="line.595"></a>
+<span class="sourceLineNo">596</span>    void callObserver() throws IOException {<a name="line.596"></a>
+<span class="sourceLineNo">597</span>      Optional&lt;O&gt; observer = observerGetter.apply(getEnvironment().getInstance());<a name="line.597"></a>
+<span class="sourceLineNo">598</span>      if (observer.isPresent()) {<a name="line.598"></a>
+<span class="sourceLineNo">599</span>        call(observer.get());<a name="line.599"></a>
+<span class="sourceLineNo">600</span>      }<a name="line.600"></a>
+<span class="sourceLineNo">601</span>    }<a name="line.601"></a>
+<span class="sourceLineNo">602</span>  }<a name="line.602"></a>
+<span class="sourceLineNo">603</span><a name="line.603"></a>
+<span class="sourceLineNo">604</span>  public abstract class ObserverOperationWithResult&lt;O, R&gt; extends ObserverOperation&lt;O&gt; {<a name="line.604"></a>
+<span class="sourceLineNo">605</span>    protected abstract R call(O observer) throws IOException;<a name="line.605"></a>
+<span class="sourceLineNo">606</span><a name="line.606"></a>
+<span class="sourceLineNo">607</span>    private R result;<a name="line.607"></a>
+<span class="sourceLineNo">608</span><a name="line.608"></a>
+<span class="sourceLineNo">609</span>    public ObserverOperationWithResult(ObserverGetter&lt;C, O&gt; observerGetter, R result) {<a name="line.609"></a>
+<span class="sourceLineNo">610</span>      this(observerGetter, result, false);<a name="line.610"></a>
+<span class="sourceLineNo">611</span>    }<a name="line.611"></a>
+<span class="sourceLineNo">612</span><a name="line.612"></a>
+<span class="sourceLineNo">613</span>    public ObserverOperationWithResult(ObserverGetter&lt;C, O&gt; observerGetter, R result,<a name="line.613"></a>
+<span class="sourceLineNo">614</span>        boolean bypassable) {<a name="line.614"></a>
+<span class="sourceLineNo">615</span>      this(observerGetter, result, null, bypassable);<a name="line.615"></a>
+<span class="sourceLineNo">616</span>    }<a name="line.616"></a>
+<span class="sourceLineNo">617</span><a name="line.617"></a>
+<span class="sourceLineNo">618</span>    public ObserverOperationWithResult(ObserverGetter&lt;C, O&gt; observerGetter, R result,<a name="line.618"></a>
+<span class="sourceLineNo">619</span>        User user) {<a name="line.619"></a>
+<span class="sourceLineNo">620</span>      this(observerGetter, result, user, false);<a name="line.620"></a>
+<span class="sourceLineNo">621</span>    }<a name="line.621"></a>
+<span class="sourceLineNo">622</span><a name="line.622"></a>
+<span class="sourceLineNo">623</span>    private ObserverOperationWithResult(ObserverGetter&lt;C, O&gt; observerGetter, R result, User user,<a name="line.623"></a>
+<span class="sourceLineNo">624</span>        boolean bypassable) {<a name="line.624"></a>
+<span class="sourceLineNo">625</span>      super(observerGetter, user, bypassable);<a name="line.625"></a>
+<span class="sourceLineNo">626</span>      this.result = result;<a name="line.626"></a>
+<span class="sourceLineNo">627</span>    }<a name="line.627"></a>
+<span class="sourceLineNo">628</span><a name="line.628"></a>
+<span class="sourceLineNo">629</span>    protected R getResult() {<a name="line.629"></a>
+<span class="sourceLineNo">630</span>      return this.result;<a name="line.630"></a>
+<span class="sourceLineNo">631</span>    }<a name="line.631"></a>
+<span class="sourceLineNo">632</span><a name="line.632"></a>
+<span class="sourceLineNo">633</span>    void callObserver() throws IOException {<a name="line.633"></a>
+<span class="sourceLineNo">634</span>      Optional&lt;O&gt; observer = observerGetter.apply(getEnvironment().getInstance());<a name="line.634"></a>
+<span class="sourceLineNo">635</span>      if (observer.isPresent()) {<a name="line.635"></a>
+<span class="sourceLineNo">636</span>        result = call(observer.get());<a name="line.636"></a>
+<span class="sourceLineNo">637</span>      }<a name="line.637"></a>
+<span class="sourceLineNo">638</span>    }<a name="line.638"></a>
+<span class="sourceLineNo">639</span>  }<a name="line.639"></a>
+<span class="sourceLineNo">640</span><a name="line.640"></a>
+<span class="sourceLineNo">641</span>  //////////////////////////////////////////////////////////////////////////////////////////<a name="line.641"></a>
+<span class="sourceLineNo">642</span>  // Functions to execute observer hooks and handle results (if any)<a name="line.642"></a>
+<span class="sourceLineNo">643</span>  //////////////////////////////////////////////////////////////////////////////////////////<a name="line.643"></a>
+<span class="sourceLineNo">644</span><a name="line.644"></a>
+<span class="sourceLineNo">645</span>  /**<a name="line.645"></a>
+<span class="sourceLineNo">646</span>   * Do not call with an observerOperation that is null! Have the caller check.<a name="line.646"></a>
+<span class="sourceLineNo">647</span>   */<a name="line.647"></a>
+<span class="sourceLineNo">648</span>  protected &lt;O, R&gt; R execOperationWithResult(<a name="line.648"></a>
+<span class="sourceLineNo">649</span>      final ObserverOperationWithResult&lt;O, R&gt; observerOperation) throws IOException {<a name="line.649"></a>
+<span class="sourceLineNo">650</span>    boolean bypass = execOperation(observerOperation);<a name="line.650"></a>
+<span class="sourceLineNo">651</span>    R result = observerOperation.getResult();<a name="line.651"></a>
+<span class="sourceLineNo">652</span>    return bypass == observerOperation.isBypassable()? result: null;<a name="line.652"></a>
+<span class="sourceLineNo">653</span>  }<a name="line.653"></a>
+<span class="sourceLineNo">654</span><a name="line.654"></a>
+<span class="sourceLineNo">655</span>  /**<a name="line.655"></a>
+<span class="sourceLineNo">656</span>   * @return True if we are to bypass (Can only be &lt;code&gt;true&lt;/code&gt; if<a name="line.656"></a>
+<span class="sourceLineNo">657</span>   * ObserverOperation#isBypassable().<a name="line.657"></a>
+<span class="sourceLineNo">658</span>   */<a name="line.658"></a>
+<span class="sourceLineNo">659</span>  protected &lt;O&gt; boolean execOperation(final ObserverOperation&lt;O&gt; observerOperation)<a name="line.659"></a>
+<span class="sourceLineNo">660</span>      throws IOException {<a name="line.660"></a>
+<span class="sourceLineNo">661</span>    boolean bypass = false;<a name="line.661"></a>
+<span class="sourceLineNo">662</span>    if (observerOperation == null) {<a name="line.662"></a>
+<span class="sourceLineNo">663</span>      return bypass;<a name="line.663"></a>
+<span class="sourceLineNo">664</span>    }<a name="line.664"></a>
+<span class="sourceLineNo">665</span>    List&lt;E&gt; envs = coprocEnvironments.get();<a name="line.665"></a>
+<span class="sourceLineNo">666</span>    for (E env : envs) {<a name="line.666"></a>
+<span class="sourceLineNo">667</span>      observerOperation.prepare(env);<a name="line.667"></a>
+<span class="sourceLineNo">668</span>      Thread currentThread = Thread.currentThread();<a name="line.668"></a>
+<span class="sourceLineNo">669</span>      ClassLoader cl = currentThread.getContextClassLoader();<a name="line.669"></a>
+<span class="sourceLineNo">670</span>      try {<a name="line.670"></a>
+<span class="sourceLineNo">671</span>        currentThread.setContextClassLoader(env.getClassLoader());<a name="line.671"></a>
+<span class="sourceLineNo">672</span>        observerOperation.callObserver();<a name="line.672"></a>
+<span class="sourceLineNo">673</span>      } catch (Throwable e) {<a name="line.673"></a>
+<span class="sourceLineNo">674</span>        handleCoprocessorThrowable(env, e);<a name="line.674"></a>
+<span class="sourceLineNo">675</span>      } finally {<a name="line.675"></a>
+<span class="sourceLineNo">676</span>        currentThread.setContextClassLoader(cl);<a name="line.676"></a>
+<span class="sourceLineNo">677</span>      }<a name="line.677"></a>
+<span class="sourceLineNo">678</span>      // Internal to shouldBypass, it checks if obeserverOperation#isBypassable().<a name="line.678"></a>
+<span class="sourceLineNo">679</span>      bypass |= observerOperation.shouldBypass();<a name="line.679"></a>
+<span class="sourceLineNo">680</span>      observerOperation.postEnvCall();<a name="line.680"></a>
+<span class="sourceLineNo">681</span>    }<a name="line.681"></a>
+<span class="sourceLineNo">682</span>    return bypass;<a name="line.682"></a>
+<span class="sourceLineNo">683</span>  }<a name="line.683"></a>
+<span class="sourceLineNo">684</span><a name="line.684"></a>
+<span class="sourceLineNo">685</span>  /**<a name="line.685"></a>
+<span class="sourceLineNo">686</span>   * Coprocessor classes can be configured in any order, based on that priority is set and<a name="line.686"></a>
+<span class="sourceLineNo">687</span>   * chained in a sorted order. Should be used preStop*() hooks i.e. when master/regionserver is<a name="line.687"></a>
+<span class="sourceLineNo">688</span>   * going down. This function first calls coprocessor methods (using ObserverOperation.call())<a name="line.688"></a>
+<span class="sourceLineNo">689</span>   * and then shutdowns the environment in postEnvCall(). &lt;br&gt;<a name="line.689"></a>
+<span class="sourceLineNo">690</span>   * Need to execute all coprocessor methods first then postEnvCall(), otherwise some coprocessors<a name="line.690"></a>
+<span class="sourceLineNo">691</span>   * may remain shutdown if any exception occurs during next coprocessor execution which prevent<a name="line.691"></a>
+<span class="sourceLineNo">692</span>   * master/regionserver stop or cluster shutdown. (Refer:<a name="line.692"></a>
+<span class="sourceLineNo">693</span>   * &lt;a href="https://issues.apache.org/jira/browse/HBASE-16663"&gt;HBASE-16663&lt;/a&gt;<a name="line.693"></a>
+<span class="sourceLineNo">694</span>   * @return true if bypaas coprocessor execution, false if not.<a name="line.694"></a>
+<span class="sourceLineNo">695</span>   * @throws IOException<a name="line.695"></a>
+<span class="sourceLineNo">696</span>   */<a name="line.696"></a>
+<span class="sourceLineNo">697</span>  protected &lt;O&gt; boolean execShutdown(final ObserverOperation&lt;O&gt; observerOperation)<a name="line.697"></a>
+<span class="sourceLineNo">698</span>      throws IOException {<a name="line.698"></a>
+<span class="sourceLineNo">699</span>    if (observerOperation == null) return false;<a name="line.699"></a>
+<span class="sourceLineNo">700</span>    boolean bypass = false;<a name="line.700"></a>
+<span class="sourceLineNo">701</span>    List&lt;E&gt; envs = coprocEnvironments.get();<a name="line.701"></a>
+<span class="sourceLineNo">702</span>    // Iterate the coprocessors and execute ObserverOperation's call()<a name="line.702"></a>
+<span class="sourceLineNo">703</span>    for (E env : envs) {<a name="line.703"></a>
+<span class="sourceLineNo">704</span>      observerOperation.prepare(env);<a name="line.704"></a>
+<span class="sourceLineNo">705</span>      Thread currentThread = Thread.currentThread();<a name="line.705"></a>
+<span class="sourceLineNo">706</span>      ClassLoader cl = currentThread.getContextClassLoader();<a name="line.706"></a>
+<span class="sourceLineNo">707</span>      try {<a name="line.707"></a>
+<span class="sourceLineNo">708</span>        currentThread.setContextClassLoader(env.getClassLoader());<a name="line.708"></a>
+<span class="sourceLineNo">709</span>        observerOperation.callObserver();<a name="line.709"></a>
+<span class="sourceLineNo">710</span>      } catch (Throwable e) {<a name="line.710"></a>
+<span class="sourceLineNo">711</span>        handleCoprocessorThrowable(env, e);<a name="line.711"></a>
+<span class="sourceLineNo">712</span>      } finally {<a name="line.712"></a>
+<span class="sourceLineNo">713</span>        currentThread.setContextClassLoader(cl);<a name="line.713"></a>
+<span class="sourceLineNo">714</span>      }<a name="line.714"></a>
+<span class="sourceLineNo">715</span>      bypass |= observerOperation.shouldBypass();<a name="line.715"></a>
+<span class="sourceLineNo">716</span>    }<a name="line.716"></a>
+<span class="sourceLineNo">717</span><a name="line.717"></a>
+<span class="sourceLineNo">718</span>    // Iterate the coprocessors and execute ObserverOperation's postEnvCall()<a name="line.718"></a>
+<span class="sourceLineNo">719</span>    for (E env : envs) {<a name="line.719"></a>
+<span class="sourceLineNo">720</span>      observerOperation.prepare(env);<a name="line.720"></a>
+<span class="sourceLineNo">721</span>      observerOperation.postEnvCall();<a name="line.721"></a>
+<span class="sourceLineNo">722</span>    }<a name="line.722"></a>
+<span class="sourceLineNo">723</span>    return bypass;<a name="line.723"></a>
+<span class="sourceLineNo">724</span>  }<a name="line.724"></a>
+<span class="sourceLineNo">725</span>}<a name="line.725"></a>
 
 
 


Mime
View raw message