【问题标题】:Hadoop MapReduce NoSuchElementExceptionHadoop MapReduce NoSuchElementException
【发布时间】:2014-10-11 10:54:58
【问题描述】:

我想在具有两个节点的 FreeBSD-Cluster 上运行 MapReduce-Job,但出现以下异常

14/08/27 14:23:04 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
14/08/27 14:23:04 INFO Configuration.deprecation: session.id is deprecated. Instead, use dfs.metrics.session-id
14/08/27 14:23:04 INFO jvm.JvmMetrics: Initializing JVM Metrics with processName=JobTracker, sessionId=
14/08/27 14:23:04 WARN mapreduce.JobSubmitter: Hadoop command-line option parsing not performed. Implement the Tool interface and execute your application with ToolRunner to remedy this.
14/08/27 14:23:04 WARN mapreduce.JobSubmitter: No job jar file set.  User classes may not be found. See Job or Job#setJar(String).
14/08/27 14:23:04 INFO mapreduce.JobSubmitter: Cleaning up the staging area file:/tmp/hadoop-otlam/mapred/staging/otlam968414084/.staging/job_local968414084_0001
Exception in thread "main" java.util.NoSuchElementException
at java.util.StringTokenizer.nextToken(StringTokenizer.java:349)
at org.apache.hadoop.fs.RawLocalFileSystem$DeprecatedRawLocalFileStatus.loadPermissionInfo(RawLocalFileSystem.java:565)
at org.apache.hadoop.fs.RawLocalFileSystem$DeprecatedRawLocalFileStatus.getPermission(RawLocalFileSystem.java:534)
at org.apache.hadoop.mapreduce.filecache.ClientDistributedCacheManager.checkPermissionOfOther(ClientDistributedCacheManager.java:276)
at org.apache.hadoop.mapreduce.filecache.ClientDistributedCacheManager.isPublic(ClientDistributedCacheManager.java:240)
at org.apache.hadoop.mapreduce.filecache.ClientDistributedCacheManager.determineCacheVisibilities(ClientDistributedCacheManager.java:162)
at org.apache.hadoop.mapreduce.filecache.ClientDistributedCacheManager.determineTimestampsAndCacheVisibilities(ClientDistributedCacheManager.java:58)
at org.apache.hadoop.mapreduce.JobSubmitter.copyAndConfigureFiles(JobSubmitter.java:265)
at org.apache.hadoop.mapreduce.JobSubmitter.copyAndConfigureFiles(JobSubmitter.java:301)
at org.apache.hadoop.mapreduce.JobSubmitter.submitJobInternal(JobSubmitter.java:389)
at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1285)
at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1282)
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:1556)
at org.apache.hadoop.mapreduce.Job.submit(Job.java:1282)
at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:1303)
...

当我尝试在新的 MapReduce 作业上运行 job.watForCompletion(true); 时会发生这种情况。应该抛出 NoSuchElementException,因为在 StringTokenizer 中没有更多的 Elements 并且在其上调用了 next()。 我查看了源代码并在 RawLocalFileSystem.java 中找到了以下代码部分:

/// loads permissions, owner, and group from `ls -ld`
private void loadPermissionInfo() {
  IOException e = null;
  try {
    String output = FileUtil.execCommand(new File(getPath().toUri()), 
        Shell.getGetPermissionCommand());
    StringTokenizer t =
        new StringTokenizer(output, Shell.TOKEN_SEPARATOR_REGEX);
    //expected format
    //-rw-------    1 username groupname ...
    String permission = t.nextToken();

据我所见,Hadoop 尝试使用ls -ld 找出特定文件的一些权限,如果我在控制台中使用它,它会完美运行。不幸的是,我还没有找到它在寻找哪些文件权限。

Hadoop 版本是 2.4.1,HBase 版本是 0.98.4,我使用的是 Java-API。其他操作(例如创建表)工作正常。有没有人遇到过类似的问题或知道该怎么做?

编辑: 我刚刚发现这是一个与 hadoop 相关的问题。即使不使用 HDFS 进行最简单的 MapReduce-Operation 也会给我同样的异常。

【问题讨论】:

    标签: java hadoop mapreduce hbase nosuchelementexception


    【解决方案1】:

    您能否检查一下这是否可以解决您的问题。

    如果您的问题是权限问题,那么这可行。

    public static void main(String[] args) {
         //set user group information       
         UserGroupInformation ugi = UserGroupInformation.createRemoteUser("hdfs");
         //set privilege exception
         ugi.doAs(new PrivilegedExceptionAction<Void>() {
         public Void run() throws Exception {
                    //create configuration object
                     Configuration config = new Configuration();
                     config.set("fs.defaultFS", "hdfs://ip:port/");
                     config.set("hadoop.job.ugi", "hdfs");
                     FileSystem dfs = FileSystem.get(config);
                     .
                     .
    

    【讨论】:

    • 感谢您的回答。我已经解决了这个问题:原来,我使用了错误的依赖,所以我开始使用 maven 进行依赖管理,现在一切正常。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多