【问题标题】:MRUnit test case for DriverDriver 的 MRUnit 测试用例
【发布时间】:2015-10-26 17:22:23
【问题描述】:

我用以下代码编写了 MRunit:

          Configuration conf = new Configuration();
          conf.set("fs.defaultFS", "file:///");
          conf.set("fs.default.name", "file:///");
          conf.set("mapreduce.framework.name", "local");
          conf.setInt("mapreduce.task.io.sort.mb", 1);
          Path input = new Path("input/ncdc/micro");
          Path output = new Path("output");
          FileSystem fs = FileSystem.getLocal(conf);
          fs.delete(output, true); // delete old output     

          VisitedItemFlattenDriver driver = new VisitedItemFlattenDriver();
          driver.setConf(conf);

          int exitCode = driver.run(new String[] {
                input.toString(), output.toString(), "false" });

但是当我从 Eclipse 执行 Junit 测试用例时。我遇到如下异常:-

java.lang.NullPointerException
at java.lang.ProcessBuilder.start(ProcessBuilder.java:441)
at org.apache.hadoop.util.Shell.runCommand(Shell.java:404)
at org.apache.hadoop.util.Shell.run(Shell.java:379)
at org.apache.hadoop.util.Shell$ShellCommandExecutor.execute(Shell.java:589)
at org.apache.hadoop.util.Shell.execCommand(Shell.java:678)
at org.apache.hadoop.util.Shell.execCommand(Shell.java:661)
at org.apache.hadoop.fs.RawLocalFileSystem.setPermission(RawLocalFileSystem.java:639)
at org.apache.hadoop.fs.RawLocalFileSystem.mkdirs(RawLocalFileSystem.java:435)
at org.apache.hadoop.fs.FilterFileSystem.mkdirs(FilterFileSystem.java:277)
at org.apache.hadoop.mapreduce.JobSubmissionFiles.getStagingDir(JobSubmissionFiles.java:125)
at org.apache.hadoop.mapreduce.JobSubmitter.submitJobInternal(JobSubmitter.java:344)
at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1268)
at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1265)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:396)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1491)
at org.apache.hadoop.mapreduce.Job.submit(Job.java:1265)
at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:1286)
at biz.ds.www.preprocess.visiteditem.VisitedItemFlattenDriver.run(VisitedItemFlattenDriver.java:69)

我不确定是什么导致了这个错误,因为我只是打算对我的班级进行单元测试:

public class VisitedItemFlattenDriver  extends Configured implements Tool {
...}

如果有人指导如何解决错误,我深表感谢。

【问题讨论】:

    标签: hadoop junit mapreduce hadoop2 mrunit


    【解决方案1】:

    我尝试了几个选项来解决问题并花了很多时间来解决这个问题..

    首先,我搜索了一个选项,发现将winutils.exe和.dll文件添加到hadoop/bin。我尝试了该步骤并设置了 HADOOP_HOME 环境变量。

    不知何故,上面提到的错误得到了解决,然后我陷入了另一个错误,如下所示:

    java.lang.UnsatisfiedLinkError: org.apache.hadoop.io.nativeio.NativeIO$Windows.access0(Ljava/lang/String;I)Z
    

    很明显,错误是由于某些兼容性问题造成的。但是后来我搜索了一下,发现如果我们将JRE从32位升级到64位就可以解决。

    之前我使用的是 JDK 6 32 位,然后我将其更新为 JDK 6 64 位。它没有解决我的问题。我也尝试将 minidfscluster 用于 MR 单元,但这给出了同样的错误。

    但后来我的代码使用了 JDK 7 64 位,问题得到解决,并且运行成功。

    ** 注意:我使用的是 Hadoop 版本 2.2.0

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-09
      • 2014-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多