码迷,mamicode.com
首页 > 编程语言 > 详细

【hadoop】——修改hadoop FileUtil.java,解决权限检查的问题

时间:2015-05-25 18:35:28      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:

    在Hadoop Eclipse开发环境搭建这篇文章中,第15.)中提到权限相关的异常,如下:

技术分享
15/01/30 10:08:17 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
15/01/30 10:08:17 ERROR security.UserGroupInformation: PriviledgedActionException as:zhangchao3 cause:java.io.IOException: Failed to set permissions of path: \tmp\hadoop-zhangchao3\mapred\staging\zhangchao3502228304\.staging to 0700
Exception in thread "main" java.io.IOException: Failed to set permissions of path: \tmp\hadoop-zhangchao3\mapred\staging\zhangchao3502228304\.staging to 0700
    at org.apache.hadoop.fs.FileUtil.checkReturnValue(FileUtil.java:689)
    at org.apache.hadoop.fs.FileUtil.setPermission(FileUtil.java:662)
    at org.apache.hadoop.fs.RawLocalFileSystem.setPermission(RawLocalFileSystem.java:509)
    at org.apache.hadoop.fs.RawLocalFileSystem.mkdirs(RawLocalFileSystem.java:344)
    at org.apache.hadoop.fs.FilterFileSystem.mkdirs(FilterFileSystem.java:189)
    at org.apache.hadoop.mapreduce.JobSubmissionFiles.getStagingDir(JobSubmissionFiles.java:116)
    at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:856)
    at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:850)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:415)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1121)
    at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:850)
    at org.apache.hadoop.mapreduce.Job.submit(Job.java:500)
    at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:530)
    at org.apache.hadoop.examples.WordCount.main(WordCount.java:68)
技术分享

    根据提示信息,可以看到,这个异常是org.apache.hadoop.fs.FileUtil.checkReturnValue(FileUtil.java:689)行抛出来的,把这个位置的源代码贴出来,研究一下:

技术分享
private static void checkReturnValue(boolean rv, File p, 
                                       FsPermission permission
                                       ) throws IOException {
    if (!rv) {
      throw new IOException("Failed to set permissions of path: " + p + 
                            " to " + 
                            String.format("%04o", permission.toShort()));
    }
  }
技术分享

在上面的异常信息中,FileUtil.java:689行是 throw new IOException(“Failed to ….., 我直接将这个函数的if语句去掉,如下:

private static void checkReturnValue(boolean rv, File p, FsPermission permission)
    throws IOException
  {}

    这样,chekReturnValue成为一个空函数,这样就不会对权限进行检查,在/home/hadoop/hadoop-1.0.3/中执行, ant jar进行编译,编译中可能遇到的问题见:编译hadoop遇到maven timeout ,编译好了后,生成如下的文件:

技术分享

    将编译好生成的hadoop-core-1.0.4-SNAPSHOT.jar文件拷贝到windows上,使用Java Decoder可以看到checkReturnValue已经被修改:

技术分享

 

将hadoop-core-1.0.4-SNAPSHOT.jar,修改为hadoop-core-1.0.3.jar文件,覆盖eclipse工程中的hadoop-core-1.0.3.jar文件:

技术分享       ------》    技术分享

 

技术分享

 

重新执行Run on hadoop,就可以成功的运行了。(如何执行Run on hadoop见:Hadoop Eclipse开发环境搭建 11节)

 

 

 

修改后的jar包下载地址:http://download.csdn.net/download/uestczhangchao/8420249 

【hadoop】——修改hadoop FileUtil.java,解决权限检查的问题

标签:

原文地址:http://www.cnblogs.com/zhengrunjian/p/4528422.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!