[ 
https://issues.apache.org/jira/browse/HBASE-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13402842#comment-13402842
 ] 

Jonathan Hsieh commented on HBASE-5827:
---------------------------------------

Minor clarification -- what happens if the postXXX method throws an exception?  
What if you want the postXXX method to eat the exception (because it somehow 
handles it)?

Specifically instead of this:
{code}
// Existing code with formatting unchanged

+    } catch (Throwable t) {
+        // failed-get CP hook
+        if (withCoprocessor && (coprocessorHost != null)) {
+          coprocessorHost.postGet(context, t, get, results);
+        }
+        rethrow t;
+    }
    if (withCoprocessor && (coprocessorHost != null)) {
-     coprocessorHost.postGet(context, get, results);
+     coprocessorHost.postGet(context, null, get, results);
    }
{code}

would it make more sense to do this?
{code}
// Existing code with formatting unchanged

+    } catch (Throwable t) {
+        // failed-get CP hook
+        if (withCoprocessor && (coprocessorHost != null)) {
+          coprocessorHost.postGet(context, t, get, results);  // coproc has 
option to rethrow which would percolate out, or eat the exn if it handled it.
+          return; 
+        }
+        rethrow t; // no coproc so just rethrow
+    }
    if (withCoprocessor && (coprocessorHost != null)) {
-     coprocessorHost.postGet(context, get, results);
+     coprocessorHost.postGet(context, null, get, results);  // normal success 
case; coproc can throw exn as well.
    }
{code}

I'd also suggest that the base observer class implementation would check if 
there was a non-null exn argument and rethrow; if there was no exn it would do 
nothing (or maybe just call the original version with no exn argument).
                
> [Coprocessors] Observer notifications on exceptions
> ---------------------------------------------------
>
>                 Key: HBASE-5827
>                 URL: https://issues.apache.org/jira/browse/HBASE-5827
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>            Reporter: Andrew Purtell
>            Assignee: Andrew Purtell
>
> Benjamin Busjaeger wrote on dev@:
> {quote}
> Is there a reason that RegionObservers are not notified when a get/put/delete 
> fails? Suppose I maintain some (transient) state in my Coprocessor that is 
> created during preGet and discarded during postGet. If the get fails, postGet 
> is not invoked, so I cannot remove the state.
> If there is a good reason, is there any other way to achieve the same thing? 
> If not, would  it be possible to add something the snippet below to the code 
> base?
> {code}
>     // pre-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       if (coprocessorHost.preGet(get, results)) {
>         return results;
>       }
>     }
> +    try{
>     ...
> +    } catch (Throwable t) {
> +        // failed-get CP hook
> +        if (withCoprocessor && (coprocessorHost != null)) {
> +          coprocessorHost.failedGet(get, results);
> +        }
> +        rethrow t;
> +    }
>     // post-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       coprocessorHost.postGet(get, results);
>     }
> {code}
> {quote}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to