[ 
https://issues.apache.org/jira/browse/HADOOP-5640?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12726212#action_12726212
 ] 

Todd Lipcon commented on HADOOP-5640:
-------------------------------------

bq. The plugin design is actually the listener pattern. For API extensibility 
it might be worth considering a ServiceEvent class that is passed to the 
methods of ServicePlugin and subclasses so that extra context information can 
be passed without breaking plugins. Also, ServicePlugin should be an abstract 
class.

The ServicePlugin interface is a holdover from a previous JIRA HADOOP-5257, so 
I didn't want to modify that. Hopefully Carlos can chime in with regard to 
this, since he wrote that original patch. Can you explain more about the 
ServiceEvent idea? I think this is similar to one of the ideas discussed above, 
but I think it's cleaner to use actual methods with full signatures rather than 
exposing a single "handleEvent(ServiceEvent e)" and switching on "e instanceof 
FooEvent" vs "e instanceof BarEvent".

bq. Rename PluginDispatcher to ServicePluginDispatcher. There are other plugins 
(e.g. MemoryCalculatorPlugin) so it's worth being more precise.

Fixed in attached patch.

bq. SingleArgumentRunnable might be named ServicePluginCallback to better 
indicate its use.

I disagree - this is a very generic interface that is quite usable for a lot of 
different things. Since this code is going in util, we might as well make it 
available for other use cases as well rather than proliferating several 
interfaces that have the same use.


The new patch I just attached is for the Common portion. I'll make a new JIRA 
in HDFS for the NameNodePlugin and DataNodePlugin portions of the patch.

> Allow ServicePlugins to hook callbacks into key service events
> --------------------------------------------------------------
>
>                 Key: HADOOP-5640
>                 URL: https://issues.apache.org/jira/browse/HADOOP-5640
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: util
>            Reporter: Todd Lipcon
>            Assignee: Todd Lipcon
>         Attachments: hadoop-5640.txt, hadoop-5640.txt, HADOOP-5640.v2.txt, 
> hadoop-5640.v3.txt
>
>
> HADOOP-5257 added the ability for NameNode and DataNode to start and stop 
> ServicePlugin implementations at NN/DN start/stop. However, this is 
> insufficient integration for some common use cases.
> We should add some functionality for Plugins to subscribe to events generated 
> by the service they're plugging into. Some potential hook points are:
> NameNode:
>   - new datanode registered
>   - datanode has died
>   - exception caught
>   - etc?
> DataNode:
>   - startup
>   - initial registration with NN complete (this is important for HADOOP-4707 
> to sync up datanode.dnRegistration.name with the NN-side registration)
>   - namenode reconnect
>   - some block transfer hooks?
>   - exception caught
> I see two potential routes for implementation:
> 1) We make an enum for the types of hookpoints and have a general function in 
> the ServicePlugin interface. Something like:
> {code:java}
> enum HookPoint {
>   DN_STARTUP,
>   DN_RECEIVED_NEW_BLOCK,
>   DN_CAUGHT_EXCEPTION,
>  ...
> }
> void runHook(HookPoint hp, Object value);
> {code}
> 2) We make classes specific to each "pluggable" as was originally suggested 
> in HADDOP-5257. Something like:
> {code:java}
> class DataNodePlugin {
>   void datanodeStarted() {}
>   void receivedNewBlock(block info, etc) {}
>   void caughtException(Exception e) {}
>   ...
> }
> {code}
> I personally prefer option (2) since we can ensure plugin API compatibility 
> at compile-time, and we avoid an ugly switch statement in a runHook() 
> function.
> Interested to hear what people's thoughts are here.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to