|
[
Permlink
| « Hide
]
Tom White added a comment - 16/Sep/08 12:56 PM
This is only needed for the existing mapred package. The new mapreduce package does everything in terms of Configuration (there's no JobConf), so the existing ReflectionUtils in core should suffice.
Just to be clear, the problem is that core/*/utils/ReflectionUtils references mapred/*/mapred/JobConf and JobConfigurable. Clearly before the subprojects split, this needs to be removed. We need a solution for 0.20, so we can't just ignore the problem, unfortunately. I'd suggest that:
1. We make a package private mapred.ReflectionUtils that uses JobConf and JobConfigurable. 2. Make the callers in mapred call it.
sigh! the problem with package private is that it won't be visible to mapred.* packages. if (conf instanceof JobConf && theObject instanceof JobConfigurable) { ((JobConfigurable)theObject).configure((JobConf) conf); } Option 2: add a public static method to an existing public class in mapred where it may make sense. eg. in JobConf On side note, one thing which might already be taken into account but I am bringing it up to be sure. This change would have potential to break user applications.
To deal with this we could use reflection to do JobConfigurable configuration if the classes are present at runtime. This will break the compile-time dependency, which I think is sufficient for 0.20. Something like Class<?> jobConfClass = Class.forName("org.apache.hadoop.mapred.JobConf"); Class<?> jobConfigurableClass = Class.forName("org.apache.hadoop.mapred.JobConfigurable"); if (conf.getClass().isAssignableFrom(jobConfClass) && theObject.getClass().isAssignableFrom(jobConfigurableClass)) { Method configureMethod = jobConfigurableClass.getMethod("configure", jobConfClass); configureMethod.invoke(theObject, conf); } We would need to be careful with classloading here. The alternative is to make an incompatible change in 0.20. In this case I think it is OK to make mapred.ReflectionUtils public, since it will be deprecated (along with the whole mapred package) once
Sharad Agarwal made changes - 21/Oct/08 11:50 AM
Alternatives suggested by Tom make sense. What others think ?
+1 for Tom's proposal to use runtime class lookups.
Do we expect to complete patch for runtime class lookup.
Sharad Agarwal made changes - 22/Oct/08 10:48 AM
The current patch includes a test for this in util.TestReflectionUtils which I realize may not be the ideal place. At some point, the tests will also be split between core, hdfs and mapred. So perhaps this testcase should be added to mapred in a new class mapred.TestReflectionUtils. This way it automatically gets deprecated along with the mapred package.
I think we should use Configuration#getClassByName instead of Class#forName.
I don't think we normally deprecate tests, since they aren't part of the public API. So I think what you've done is fine. When JobConf is finally removed then the test won't compile so it will be removed too. I hope that we remember to remove the code it tests too - perhaps a comment in the code would help? Incorporated Tom's comments. Using Configuration#getClassByName instead of Class.forName.
Sharad Agarwal made changes - 23/Oct/08 05:37 AM
Sharad Agarwal made changes - 23/Oct/08 05:40 AM
Cancelling it to try hudson again
Devaraj Das made changes - 29/Oct/08 08:41 AM
Devaraj Das made changes - 29/Oct/08 08:41 AM
Sharad Agarwal made changes - 05/Nov/08 08:08 AM
Sharad Agarwal made changes - 05/Nov/08 08:08 AM
+1 overall. Here are the results of testing the latest attachment
http://issues.apache.org/jira/secure/attachment/12392698/4187_v2.patch against trunk revision 711734. +1 @author. The patch does not contain any @author tags. +1 tests included. The patch appears to include 3 new or modified tests. +1 javadoc. The javadoc tool did not generate any warning messages. +1 javac. The applied patch does not increase the total number of javac compiler warnings. +1 findbugs. The patch does not introduce any new Findbugs warnings. +1 Eclipse classpath. The patch retains Eclipse classpath integrity. +1 core tests. The patch passed core unit tests. +1 contrib tests. The patch passed contrib unit tests. Test results: http://hudson.zones.apache.org/hudson/job/Hadoop-Patch/3541/testReport/ This message is automatically generated.
I just committed this. Thanks, Sharad!
Devaraj Das made changes - 07/Nov/08 10:12 AM
Integrated in Hadoop-trunk #654 (See http://hudson.zones.apache.org/hudson/job/Hadoop-trunk/654/
. Does a runtime lookup for JobConf/JobConfigurable, and if found, invokes the appropriate configure method. Contributed by Sharad Agarwal.
Nigel Daley made changes - 23/Apr/09 07:17 PM
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||