Return-Path: Delivered-To: apmail-hbase-user-archive@www.apache.org Received: (qmail 65233 invoked from network); 17 Jun 2010 18:23:38 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 17 Jun 2010 18:23:38 -0000 Received: (qmail 28830 invoked by uid 500); 17 Jun 2010 18:23:37 -0000 Delivered-To: apmail-hbase-user-archive@hbase.apache.org Received: (qmail 28789 invoked by uid 500); 17 Jun 2010 18:23:36 -0000 Mailing-List: contact user-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hbase.apache.org Delivered-To: mailing list user@hbase.apache.org Received: (qmail 28780 invoked by uid 99); 17 Jun 2010 18:23:36 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Jun 2010 18:23:36 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of yuzhihong@gmail.com designates 209.85.212.41 as permitted sender) Received: from [209.85.212.41] (HELO mail-vw0-f41.google.com) (209.85.212.41) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Jun 2010 18:23:28 +0000 Received: by vws14 with SMTP id 14so1939779vws.14 for ; Thu, 17 Jun 2010 11:23:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=lZBptrC6vOvQZwKM3gWpZyVhuC6p3ts+jaSNyxzlthA=; b=DxwmM4AnX9YuWGUUtmU2cCH/L/aoThc9otH016terxp5Wcqzfh5E62/rbccYxUuNJN kGSIe2MnPFrwVlR6SG7AowUnWlD+YIBXX0T1fS8lBY0klQbR1TmFuhvTDaVNmWl6paJR V4LS70PJu56BmxEr1DaNYhD7n0QChLuNHHnyc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=MsruYfR39V4JaaOf/i+STfSdZsLboAjx156q27zZWWCL8MSCSjxB3ioh3A22+0q/7B +vLUKOOIMevglahZW6jlQH2xQsoQ0Qq1kyn1qoh/nLbdo2kTIjfaP3caAFFaRmrOgZj3 DT34xvi+G8vs7bsUg/kOK/U0UQhiqY1GYRkqc= MIME-Version: 1.0 Received: by 10.224.65.170 with SMTP id j42mr5731919qai.100.1276798987023; Thu, 17 Jun 2010 11:23:07 -0700 (PDT) Received: by 10.229.42.78 with HTTP; Thu, 17 Jun 2010 11:23:03 -0700 (PDT) In-Reply-To: References: <2D6136772A13B84E95DF6DA79E85A9F0011D189817EE@NSPEXMBX-A.the-lab.llnl.gov> Date: Thu, 17 Jun 2010 11:23:03 -0700 Message-ID: Subject: Re: MapReduce job runs fine, but nothing is written to HTable From: Ted Yu To: user@hbase.apache.org Content-Type: multipart/alternative; boundary=000feaf111411237e204893deef5 X-Virus-Checked: Checked by ClamAV on apache.org --000feaf111411237e204893deef5 Content-Type: text/plain; charset=ISO-8859-1 You can override these methods of org.apache.hadoop.mapreduce.Mapper class. /** * Called once at the beginning of the task. */ protected void setup(Context context ) throws IOException, InterruptedException { // NOTHING } /** * Called once at the end of the task. */ protected void cleanup(Context context ) throws IOException, InterruptedException { // NOTHING } On Thu, Jun 17, 2010 at 10:44 AM, Sharma, Avani wrote: > Thanks, Dave. I have only 2 records in my HDFS file for testing. > Could you give an example of which setup and cleanup functions you are > referring to. This is my first MR HBase job using the new api. > The other commented code in the email thread below runs fine, but it is > non-MR. Is there any other setting needed for an MR job to update HBase? > > The MR jobs are run against `hadoop jar > ` > And non-MR hbase jobs simply run against hbase `hbase ` > I am suspecting that I am missing some setting. I made sure that the > CLASSPATHs are all good. > > This is how I configure the MR job - > > public int run(String[] args) throws Exception { > > Configuration conf = new Configuration(); > conf.set(TableOutputFormat.OUTPUT_TABLE, "blogposts"); > > Job job = new Job(conf, NAME); > FileInputFormat.addInputPath(job, new Path(args[0])); > job.setJarByClass(mapRedImport_from_hdfs.class); > job.setMapperClass(myMap.class); > job.setNumReduceTasks(0); > job.setOutputFormatClass(NullOutputFormat.class); > > job.waitForCompletion(true); > > return 0; > } > > public static void main(String[] args) throws Exception { > int errCode = ToolRunner.run(new mapRedImport_from_hdfs(), args); > System.exit(errCode); > } > > -----Original Message----- > From: Buttler, David [mailto:buttler1@llnl.gov] > Sent: Thursday, June 17, 2010 8:06 AM > To: user@hbase.apache.org > Subject: RE: MapReduce job runs fine, but nothing is written to HTable > > It looks to me as if you are not defining your input format correctly. > Notice that you only had two map input records. > Other issues: > You are not flushing > You are creating a new htable on each map. Put that in the setup and put > the flush in the cleanup > Dave > > > -----Original Message----- > From: Sharma, Avani [mailto:agsharma@ebay.com] > Sent: Wednesday, June 16, 2010 7:06 PM > To: user@hbase.apache.org > Subject: MapReduce job runs fine, but nothing is written to HTable > > Hi, > > I am running a job to write some data from a HDFS file to and Hbase table > using the new API. > The job runs fine without any errors, but I do not see the rows added to > the hbase table. > > This is what my code looks like - > I am running this as hadoop jar > > > private HTable table; > protected void map(ImmutableBytesWritable key, Text value, > Context context) > throws IOException, InterruptedException > { > table = new HTable( new HBaseConfiguration(), > "blogposts"); > > // Split input line on tab character > String [] splits = value.toString().split("\t"); > String rowID = splits[0]; > String cellValue = splits[1]; > Put p = new Put(Bytes.toBytes(rowID)); > p.add(Bytes.toBytes("post"), Bytes.toBytes("title"), > Bytes.toBytes(splits[1])); > table.put(p); > table.flushCommits(); > } > /* > This commented code when run seprataely in a main program runs fine > and does update to the table > HTable table = new HTable(new HBaseConfiguration(), "blogposts"); > > Put p = new Put(Bytes.toBytes("post3")); > > p.add(Bytes.toBytes("post"), Bytes.toBytes("title"), > Bytes.toBytes("abx")); > p.add(Bytes.toBytes("post"), Bytes.toBytes("author"), > Bytes.toBytes("hadings")); > p.add(Bytes.toBytes("image"), Bytes.toBytes("body"), > Bytes.toBytes("123.jpg")); > p.add(Bytes.toBytes("image"), Bytes.toBytes("header"), > Bytes.toBytes("7657.jpg")); > > table.put(p); > */ > > Run log > 10/06/16 19:00:35 WARN mapred.JobClient: Use GenericOptionsParser for > parsing the arguments. Applications should implement Tool for the same. > 10/06/16 19:00:35 INFO input.FileInputFormat: Total input paths to process > : 1 > 10/06/16 19:00:36 INFO mapred.JobClient: Running job: job_201003301510_0157 > 10/06/16 19:00:37 INFO mapred.JobClient: map 0% reduce 0% > 10/06/16 19:00:45 INFO mapred.JobClient: map 100% reduce 0% > 10/06/16 19:00:47 INFO mapred.JobClient: Job complete: > job_201003301510_0157 > 10/06/16 19:00:47 INFO mapred.JobClient: Counters: 5 > 10/06/16 19:00:47 INFO mapred.JobClient: Job Counters > 10/06/16 19:00:47 INFO mapred.JobClient: Rack-local map tasks=1 > 10/06/16 19:00:47 INFO mapred.JobClient: Launched map tasks=1 > 10/06/16 19:00:47 INFO mapred.JobClient: FileSystemCounters > 10/06/16 19:00:47 INFO mapred.JobClient: HDFS_BYTES_READ=31 > 10/06/16 19:00:47 INFO mapred.JobClient: Map-Reduce Framework > 10/06/16 19:00:47 INFO mapred.JobClient: Map input records=2 > 10/06/16 19:00:47 INFO mapred.JobClient: Spilled Records=0 > > Thanks, > Avani > > > --000feaf111411237e204893deef5--