[
https://issues.apache.org/jira/browse/HBASE-18898?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16206459#comment-16206459
]
Appy commented on HBASE-18898:
------------------------------
Thinking about it more:
By annotated methods, i assume you mean something like this
{noformat}
@ObserverHook(Master.PRE_DELETE_TABLE)
boolean myPreDeleteHook(...) {
...
}
{noformat}
where we'll expose a set of enums which can be passed as a parameter to the
annotation to denote which type of observer hook that function is.
Then, using reflection, we can get all methods marked @ObserverHook.
But we'll still have to 1) Expose reference method signatures somewhere 2)
Verify that the annotated methods have correct signature. So that, if someone
annotates {{void foo()}} by mistake (note that all observer hooks at least take
one param - environment), we can report failure.
Maybe our current *Observer interfaces will become reference for the method
signatures?
But then, why not let implementations use method override?
That'll at least give power of compile time checks. Checking correctness for
arguments, return types, exceptions, etc of an impl should not require running
a cluster and loading the coprocessor.
And if we have method overrides, having an extra annotation in implementations
is completely redundant. (is it not?)
The one +ve i see with annotated methods is, we can support say multiple hooks
of one type in single implementation i.e. multiple fns can be annotated
PRE_DELETE. But is it worth that effort?
> 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)