Hadoop 驱动程序单元测试用例

Hadoop 驱动程序单元测试用例,hadoop,junit,mapreduce,hadoop2,mrunit,Hadoop,Junit,Mapreduce,Hadoop2,Mrunit,我用以下代码编写了MRunit: Configuration conf = new Configuration(); conf.set("fs.defaultFS", "file:///"); conf.set("fs.default.name", "file:///"); conf.set("mapreduce.framework.name", "local"); conf.setInt("ma

我用以下代码编写了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 {
...}

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

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

首先,我搜索了一个选项,找到了将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位。这并没有解决我的问题。我还尝试对MR单元使用minidfscluster,但这会产生相同的错误

但后来我使用JDK7 64位代码解决了问题,并成功运行

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