add main to Driver


git-svn-id: https://hyracks.googlecode.com/svn/branches/fullstack_genomix@2868 123451ca-8445-de46-9d55-352943316053
diff --git a/genomix/genomix-core/src/main/java/edu/uci/ics/genomix/driver/Driver.java b/genomix/genomix-core/src/main/java/edu/uci/ics/genomix/driver/Driver.java
index 93137d7..6d0585e 100644
--- a/genomix/genomix-core/src/main/java/edu/uci/ics/genomix/driver/Driver.java
+++ b/genomix/genomix-core/src/main/java/edu/uci/ics/genomix/driver/Driver.java
@@ -1,5 +1,6 @@
 package edu.uci.ics.genomix.driver;
 
+import java.io.IOException;
 import java.net.URL;
 import java.util.EnumSet;
 import java.util.Map;
@@ -7,7 +8,10 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.mapreduce.Job;
 import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
+import org.apache.hadoop.util.GenericOptionsParser;
+import org.kohsuke.args4j.Option;
 
 import edu.uci.ics.genomix.job.GenomixJob;
 import edu.uci.ics.genomix.job.JobGen;
@@ -29,7 +33,9 @@
         CONTIGS_GENERATION,
     }
    
-   	private static final String applicationName = "genomix";
+   	private static final String IS_PROFILING = "genomix.driver.profiling";
+   	private static final String CPARTITION_PER_MACHINE = "genomix.driver.duplicate.num";
+   	private static final String applicationName = GenomixJob.JOB_NAME;
    	private static final Log LOG = LogFactory.getLog(Driver.class);
     private JobGen jobGen;
     private boolean profiling;
@@ -108,4 +114,20 @@
                 profiling ? EnumSet.of(JobFlag.PROFILE_RUNTIME) : EnumSet.noneOf(JobFlag.class));
         hcc.waitForCompletion(jobId);
     }
+    
+    public static void main(String [] args) throws Exception{
+    	GenomixJob job = new GenomixJob();
+    	String[] otherArgs = new GenericOptionsParser(job.getConfiguration(), args).getRemainingArgs();
+    	if ( otherArgs.length < 2){
+    		System.err.println("Need <serverIP> <port>");
+    		System.exit(-1);
+    	}
+    	String ipAddress = otherArgs[0];
+    	int port = Integer.parseInt(otherArgs[1]);
+    	int numOfDuplicate = job.getConfiguration().getInt(CPARTITION_PER_MACHINE, 2);
+    	boolean bProfiling = job.getConfiguration().getBoolean(IS_PROFILING, true);
+    	
+    	Driver driver = new Driver(ipAddress, port, numOfDuplicate);
+    	driver.runJob(job, Plan.BUILD_DEBRUJIN_GRAPH, bProfiling);
+    }
 }
diff --git a/genomix/genomix-core/src/main/java/edu/uci/ics/genomix/job/GenomixJob.java b/genomix/genomix-core/src/main/java/edu/uci/ics/genomix/job/GenomixJob.java
index 24a7561..67527a7 100644
--- a/genomix/genomix-core/src/main/java/edu/uci/ics/genomix/job/GenomixJob.java
+++ b/genomix/genomix-core/src/main/java/edu/uci/ics/genomix/job/GenomixJob.java
@@ -6,6 +6,8 @@
 import org.apache.hadoop.mapreduce.Job;
 
 public class GenomixJob extends Job {
+	
+	public static final String JOB_NAME = "genomix";
 
 	/** Kmers length */
 	public static final String KMER_LENGTH = "genomix.kmer";
@@ -26,12 +28,12 @@
 	public static final String GROUPBY_HYBRID_RECORDSIZE_CROSS = "genomix.graph.groupby.hybrid.recordsize.cross";
 	public static final String GROUPBY_HYBRID_HASHLEVEL = "genomix.graph.groupby.hybrid.hashlevel";
 
-	public GenomixJob(String jobname) throws IOException {
-		super(new Configuration(), jobname);
+	public GenomixJob() throws IOException {
+		super(new Configuration(), JOB_NAME);
 	}
 
-	public GenomixJob(Configuration conf, String jobName) throws IOException {
-		super(conf, jobName);
+	public GenomixJob(Configuration conf) throws IOException {
+		super(conf, JOB_NAME);
 	}
 
 	/**