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

Andrew Purtell commented on HBASE-18898:
----------------------------------------

[~appy] A less ugly way to do what you propose is use annotations, and use the 
Java runtime methods for iterating over annotations, wiring things up as we 
enumerate. We would get away from implementing observer hooks as method 
overrides and instead they would be implemented as annotated methods with 
annotated parameters. During load time we would wire things up. An example of 
an API that works this way which I am familiar with is JAX-RS. I'm not sure if 
Guice or another DI framework could help. The advantage is when wiring things 
up we know there will be a receiver. The disadvantage is it sounds like a fair 
amount of work. 

[~abhishek.chouhan] made a related change on HBASE-18127 which is the inverse: 
providing a way for a CP to know what hooks have invoked by core. We pass a map 
around that coprocessors can use to stuff arbitrary state into. The expected 
use over in Phoenix is to avoid after the per-batch hook upcall in 
doMiniBatchMutation doing the same work again in the per-mutation hooks called 
toward the end of doMiniBatchMutation to emulate what would have happened if 
the batch were submitted as individual ops. 

> Provide way for the core flow to know whether CP implemented each of the hooks
> ------------------------------------------------------------------------------
>
>                 Key: HBASE-18898
>                 URL: https://issues.apache.org/jira/browse/HBASE-18898
>             Project: HBase
>          Issue Type: Improvement
>          Components: Coprocessors, Performance
>            Reporter: Anoop Sam John
>            Assignee: Anoop Sam John
>            Priority: Critical
>
> This came as a discussion topic at the tale of HBASE-17732
> Can we have a way in the code (before trying to call the hook) to know 
> whether the user has implemented one particular hook or not? eg: On write 
> related hooks only prePut() might be what the user CP implemented. All others 
> are just dummy impl from the interface. Can we have a way for the core code 
> to know this and avoid the call to other dummy hooks fully? Some times we do 
> some processing for just calling CP hooks (Say we have to make a POJO out of 
> PB object for calling) and if the user CP not impl this hook, we can avoid 
> this extra work fully. The pain of this will be more when we have to later 
> deprecate one hook and add new. So the dummy impl in new hook has to call the 
> old one and that might be doing some extra work normally.
> If the CP f/w itself is having a way to tell this, the core code can make 
> use. What am expecting is some thing like in PB way where we can call 
> CPObject.hasPreXXXX(), then CPObject. preXXXX ().. Should not like asking 
> users to impl this extra ugly thing. When the CP instance is loaded in the 
> RS/HM, that object will be having this info also. 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to