You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/07/07 14:42:00 UTC

[jira] [Commented] (FLINK-7118) Remove hadoop1.x code in HadoopUtils

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

ASF GitHub Bot commented on FLINK-7118:
---------------------------------------

GitHub user zhangminglei opened a pull request:

    https://github.com/apache/flink/pull/4285

    [FLINK-7118] [hadoop] Remove hadoop1.x code in HadoopUtils

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/zhangminglei/flink flink-7118

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/flink/pull/4285.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #4285
    
----
commit cf9e267c99361fe4c69fff824e3a0eb11b62d32a
Author: zhangminglei <zm...@163.com>
Date:   2017-07-07T14:40:09Z

    [FLINK-7118] [hadoop] Remove hadoop1.x code in HadoopUtils

----


> Remove hadoop1.x code in HadoopUtils
> ------------------------------------
>
>                 Key: FLINK-7118
>                 URL: https://issues.apache.org/jira/browse/FLINK-7118
>             Project: Flink
>          Issue Type: Improvement
>          Components: Java API
>            Reporter: mingleizhang
>            Assignee: mingleizhang
>
> Since flink no longer support hadoop 1.x version, we should remove it. Below code reside in {{org.apache.flink.api.java.hadoop.mapred.utils.HadoopUtils}}
> 	
> {code:java}
> public static JobContext instantiateJobContext(Configuration configuration, JobID jobId) throws Exception {
> 		try {
> 			Class<?> clazz;
> 			// for Hadoop 1.xx
> 			if(JobContext.class.isInterface()) {
> 				clazz = Class.forName("org.apache.hadoop.mapreduce.task.JobContextImpl", true, Thread.currentThread().getContextClassLoader());
> 			}
> 			// for Hadoop 2.xx
> 			else {
> 				clazz = Class.forName("org.apache.hadoop.mapreduce.JobContext", true, Thread.currentThread().getContextClassLoader());
> 			}
> 			Constructor<?> constructor = clazz.getConstructor(Configuration.class, JobID.class);
> 			JobContext context = (JobContext) constructor.newInstance(configuration, jobId);
> 			
> 			return context;
> 		} catch(Exception e) {
> 			throw new Exception("Could not create instance of JobContext.");
> 		}
> 	}
> {code}
> And 
> {code:java}
> 	public static TaskAttemptContext instantiateTaskAttemptContext(Configuration configuration,  TaskAttemptID taskAttemptID) throws Exception {
> 		try {
> 			Class<?> clazz;
> 			// for Hadoop 1.xx
> 			if(JobContext.class.isInterface()) {
> 				clazz = Class.forName("org.apache.hadoop.mapreduce.task.TaskAttemptContextImpl");
> 			}
> 			// for Hadoop 2.xx
> 			else {
> 				clazz = Class.forName("org.apache.hadoop.mapreduce.TaskAttemptContext");
> 			}
> 			Constructor<?> constructor = clazz.getConstructor(Configuration.class, TaskAttemptID.class);
> 			TaskAttemptContext context = (TaskAttemptContext) constructor.newInstance(configuration, taskAttemptID);
> 			
> 			return context;
> 		} catch(Exception e) {
> 			throw new Exception("Could not create instance of TaskAttemptContext.");
> 		}
> 	}
> {code}



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