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

Alex Baranau commented on HBASE-4050:
-------------------------------------

So, about the shim. Haven't done that kind of thing before, so please correct 
me where/if I'm wrong.

Background:
There are quite a lot (>10) classes we want to use in HBase code which are 
different in Hadoop 1.0+ and 2.0+ from metrics2 framework.

There are two options basically.

*1. Create shim classes for every class we want to use from Hadoop metrics2* 
and which are different in Hadoop 1.0+ and 2.0+ codebase. 

Shim class is basically consists of:
* interface (may be abstract class) similar (or exact same, depending on which 
methods we want to use from it)
* multiple implementations of this interface, each uses reflection to 
dynamically load the class from hadoop (based on which hadoop version we should 
use) and propagate methods invocation to it

_Pros_: no extra/external jars to be loaded, all code is in main HBase maven 
module
_Cons_: a lot of code which uses reflection (i.e. ugly code, hard to maintain, 
+ bad performance)

*2. Create shim classes for "central/factory" classes*, *add only interfaces 
for classes which we want to use from Hadoop metrics2* and which are different 
in Hadoop 1.0+ and 2.0+ codebase, *extract actual implementation of these 
interfaces into shim jars* and load them depending on which Hadoop version we 
need to use.

In other words:
* add _only_ interfaces in HBase codebase (in new metrics2 package) for classes 
of metrics2 framework we want to use
* create shim classes for "central/factory" classes, such as MetricsRegistry: 
interface + code to load the actual implementation by classname
* create two shim jars (e.g. "metrics2-hadoop-1.0-shim.jar" and 
"metrics2-hadoop-2.0-shim.jar") each with implementation of the interfaces 
above using classes from the corresponded hadoop version
* add ShimLoader class which, at runtime finds out which hadoop version is used 
and which shim jar should be loaded, and loads the correspondent jar

_Pros_: minimum reflection (just for initializing "central/factory" classes, 
once)
_Cons_: needs loading jars (not sure this is a con), probably we'll have to add 
separate maven modules to develop two shim jars
                
> Update HBase metrics framework to metrics2 framework
> ----------------------------------------------------
>
>                 Key: HBASE-4050
>                 URL: https://issues.apache.org/jira/browse/HBASE-4050
>             Project: HBase
>          Issue Type: New Feature
>          Components: metrics
>    Affects Versions: 0.90.4
>         Environment: Java 6
>            Reporter: Eric Yang
>            Assignee: Alex Baranau
>            Priority: Critical
>             Fix For: 0.96.0
>
>         Attachments: 4050-metrics-v2.patch, 4050-metrics-v3.patch, 
> HBASE-4050.patch
>
>
> Metrics Framework has been marked deprecated in Hadoop 0.20.203+ and 0.22+, 
> and it might get removed in future Hadoop release.  Hence, HBase needs to 
> revise the dependency of MetricsContext to use Metrics2 framework.

--
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