Oops, DistCp.main(..) calls System.exit(..) at the end.  So it would also 
terminate your Java program.  It probably is not desirable.  You may still use 
similar codes as the ones in DistCp.main(..) as shown below.  However, they are 
not stable APIs.


//DistCp.main
  public static void main(String[] args) throws Exception {
    JobConf job = new JobConf(DistCp.class);
    DistCp distcp = new DistCp(job);
    int res = ToolRunner.run(distcp, args);
    System.exit(res);
  }

Nicholas



----- Original Message ----
> From: "Tsz Wo (Nicholas), Sze" <s29752-hadoopu...@yahoo.com>
> To: common-user@hadoop.apache.org
> Sent: Wed, February 17, 2010 10:58:58 PM
> Subject: Re: JavaDocs for DistCp (or similar)
> 
> Hi Balu,
> 
> Unfortunately, DistCp does not have a public Java API.  One simple way is to 
> invoke DistCp.main(args) in your java program, where args is an array of the 
> string arguments you would pass in the command line.
> 
> Hope this helps.
> Nicholas Sze
> 
> 
> 
> 
> ----- Original Message ----
> > From: Balu Vellanki 
> > To: "common-user@hadoop.apache.org" 
> > Sent: Wed, February 17, 2010 5:43:11 PM
> > Subject: JavaDocs for DistCp (or similar)
> > 
> > Hi Folks
> > 
> > Currently we use distCp to transfer files between two hadoop clusters. I
> > have a perl script which calls a system command “hadoop distcp....” to
> > achieve this.
> > 
> > Is there a Java Api to do distCp, so that we can avoid system calls from our
> > java code?
> > 
> > Thanks
> > Balu


Reply via email to