I have a jar file with predefined entry point in its manifest file. And it can successfully be executed.
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%
...
Now my concern is how to execute the jar without the options.
I mean I just want to invoke:
hadoop jar hadoop-test-1.0.2.jar
I need to somehow define the arguments like "-write -nrFiles 1 -fileSize 10" inside the jar file. But how?
How can I define it in the manifest file? I know that I can generate a class of my own which then initiates the test class with these parameters. But is there any other workaround?
Surprisingly: Defined a class which calls the required class with the args.
Execution try:
hadoop jar hadoop-test-1.0.2.jar
RunJar jarFile [mainClass] args...
With the name of the class as arg, it works!
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
...
Content of my Manifest:
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
The content of the 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);
}
}
What am I doing wrong? Why am I not able to execute Start using the jar file without args to execute the original class TestDFIO? Thx!
Nope. You can either create a new
mainmethod or get the arguments from somewhere else, for example, a config file, environment variables, etc.You could also just write a wrapping shell script that does that part.
Without knowing why you need to do this it’s more difficult to provide actionable ideas.