Return-Path: Delivered-To: apmail-hadoop-mapreduce-user-archive@minotaur.apache.org Received: (qmail 88795 invoked from network); 24 Sep 2010 15:30:15 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 24 Sep 2010 15:30:15 -0000 Received: (qmail 29545 invoked by uid 500); 24 Sep 2010 15:30:14 -0000 Delivered-To: apmail-hadoop-mapreduce-user-archive@hadoop.apache.org Received: (qmail 29497 invoked by uid 500); 24 Sep 2010 15:30:13 -0000 Mailing-List: contact mapreduce-user-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: mapreduce-user@hadoop.apache.org Delivered-To: mailing list mapreduce-user@hadoop.apache.org Received: (qmail 29485 invoked by uid 99); 24 Sep 2010 15:30:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Sep 2010 15:30:12 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [208.97.132.83] (HELO homiemail-a6.g.dreamhost.com) (208.97.132.83) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Sep 2010 15:30:06 +0000 Received: from homiemail-a6.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a6.g.dreamhost.com (Postfix) with ESMTP id 0FC3059806C for ; Fri, 24 Sep 2010 08:29:46 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=darose.net; h=message-id:date :from:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; q=dns; s=darose.net; b= Kg94wKpiBnKqLFautEbxxJZnYPqv3CUvyWKhoYDBWJtbvnam65TUp2CHLUBr1uIV ONRE4Nloq+S+y8HgaiZzL5TQ1eqbIrgdvG5ANCV86CuysGOK/3qVfmH6wZkrLFrM 7jb7M4C6dDZGSUKEuwFo9RMuHStrvSFQH6A8hywJNH0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=darose.net; h=message-id :date:from:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; s=darose.net; bh=ez1dpV Y/+7AVsFYo0+QtmCTBrVY=; b=AfwHOI51wHVjxerRRJ85TYUwxZ3Qfiu9CqsM6U yrniu+nYT+5mOCZO+d5KJsvpLRUUymG2mkzi6xMet2eky4cJSh5Q2SqQqmd1axt9 u1WFXmWoQ7YbmFM1iF1E+xBNvjKNqiiLqRXtLmmWP8hP5nt5chL0kyK53bjGd1ZR AJY2g= Received: from darsys12 (cpe-66-108-142-190.nyc.res.rr.com [66.108.142.190]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: darose@darose.net) by homiemail-a6.g.dreamhost.com (Postfix) with ESMTPSA id EA06959806B for ; Fri, 24 Sep 2010 08:29:45 -0700 (PDT) Received: from [10.1.0.2] by darsys12 with esmtp (Exim 4.72) (envelope-from ) id 1OzADY-0006gj-4B for mapreduce-user@hadoop.apache.org; Fri, 24 Sep 2010 11:29:44 -0400 Message-ID: <4C9CC3E7.1040001@darose.net> Date: Fri, 24 Sep 2010 11:29:43 -0400 From: David Rosenstrauch User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100916 Lanikai/3.1.4 MIME-Version: 1.0 To: mapreduce-user@hadoop.apache.org Subject: Re: JobClient using deprecated JobConf References: <4C99CE4F.9040305@web.de> <4C9B0EC2.50906@web.de> <4C9B8CB9.7050008@web.de> <4C9CBFDB.5060208@web.de> In-Reply-To: <4C9CBFDB.5060208@web.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 09/24/2010 11:12 AM, Martin Becker wrote: > Hi James, > > I am trying to avoid to call any command line command. I want to submit > a job from within a java application. If possible without packing any > jar file at all. But I guess that will be necessary to allow Hadoop to > load the specific classes. The tutorial definitely does not contain any > explicit java code how to do this. Sorry, for not stating my problem > clearly: > > Right now I want to use Eclipse to submit my job by doing using the "Run > as..." dialog. Later I want to embed that part in a java application > submitting configured jobs to a remote Hadoop system/cluster. > > Regards, > Martin This is very do-able. (I do this now.) Here is a skeleton for how it can be done: public class JobSubmitter implements Tool { public static void main(String[] args) throws Exception { ToolRunner.run(new Configuration(), new JobSubmitter(), args); } public JobSubmitter() { } public Configuration getConf() { return appConf; } public void setConf(Configuration conf) { this.appConf = conf; } public int run(String[] args) throws Exception { Job job = new Job(appConf); Configuration jobConf = job.getConfiguration(); jobConf.set(); job.submit(); } } re: "without packing any jar file at all": If you use Tool/ToolRunner (as we are doing above), that lets your Hadoop app automatically handle some key command line args. One them that you will use here is the -libjars argument. If you use -libjars and specify a list of jars that contain your code, then ToolRunner will automatically take those jars and put them in the Distributed Cache on each task node, where they will get added to the classpath of every map/reduce task. HTH, DR