我的清单文件中有一个带有预定义入口点的 jar 文件。并且可以成功执行。
hadoop jar hadoop-test-1.0.2.jar -write -nrFiles 1 -fileSize 10
TestDFSIO.0.0.4
12/06/11 21:35:09 INFO fs.TestDFSIO: nrFiles = 1
12/06/11 21:35:09 INFO fs.TestDFSIO: fileSize (MB) = 10
12/06/11 21:35:09 INFO fs.TestDFSIO: bufferSize = 1000000
12/06/11 21:35:09 INFO fs.TestDFSIO: creating control file: 10 mega bytes, 1 files
12/06/11 21:35:09 INFO fs.TestDFSIO: created control files for: 1 files
12/06/11 21:35:10 INFO mapred.FileInputFormat: Total input paths to process : 1
12/06/11 21:35:10 INFO mapred.JobClient: Running job: job_201206110904_0029
12/06/11 21:35:11 INFO mapred.JobClient: map 0% reduce 0%
12/06/11 21:35:25 INFO mapred.JobClient: map 100% reduce 0%
12/06/11 21:35:37 INFO mapred.JobClient: map 100% reduce 100%
...
现在我关心的是如何在没有选项的情况下执行 jar。我的意思是我只想调用:
hadoop jar hadoop-test-1.0.2.jar
我需要以某种方式定义"-write -nrFiles 1 -fileSize 10"
jar 文件中的参数。但是怎么做?
如何在清单文件中定义它?我知道我可以生成自己的类,然后使用这些参数启动测试类。但是还有其他解决方法吗?
令人惊讶的是:定义了一个类,它使用 args 调用所需的类。
执行尝试:
hadoop jar hadoop-test-1.0.2.jar
RunJar jarFile [mainClass] args...
使用类的名称作为 arg,它可以工作!
hadoop jar hadoop-test-1.0.2.jar Start
TestDFSIO.0.0.4
12/06/12 01:05:11 INFO fs.TestDFSIO: nrFiles = 10
12/06/12 01:05:11 INFO fs.TestDFSIO: fileSize (MB) = 1000
12/06/12 01:05:11 INFO fs.TestDFSIO: bufferSize = 1000000
12/06/12 01:05:11 INFO fs.TestDFSIO: creating control file: 1000 mega bytes, 10 files
12/06/12 01:05:11 INFO fs.TestDFSIO: created control files for: 10 files
12/06/12 01:05:11 INFO mapred.FileInputFormat: Total input paths to process : 10
12/06/12 01:05:12 INFO mapred.JobClient: Running job: job_201206110904_0033
...
我的清单内容:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: 20.1-b02 (Sun Microsystems Inc.)
Main-Class: Start
Name: org/apache/hadoop
Implementation-Title: Hadoop
Implementation-Version: 1.0.2
Implementation-Vendor: Apache
Start.java的内容:
import org.apache.hadoop.fs.TestDFSIO;
public class Start {
public static void main(String[] args) throws Exception{
String [] myargs = {"-write","-nrFiles","10","-fileSize","1000"};
TestDFSIO.main(myargs);
}
}
我究竟做错了什么?为什么我无法执行 Start using the jar file without args 来执行原始类TestDFIO?谢谢!