Return-Path: X-Original-To: apmail-accumulo-commits-archive@www.apache.org Delivered-To: apmail-accumulo-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E81EFD666 for ; Tue, 21 May 2013 19:14:10 +0000 (UTC) Received: (qmail 39690 invoked by uid 500); 21 May 2013 19:14:10 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 39619 invoked by uid 500); 21 May 2013 19:14:09 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 39592 invoked by uid 99); 21 May 2013 19:14:08 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 May 2013 19:14:08 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 May 2013 19:14:03 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 90CFE23888E7; Tue, 21 May 2013 19:13:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1484908 - /accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/continuous/ContinuousVerify.java Date: Tue, 21 May 2013 19:13:43 -0000 To: commits@accumulo.apache.org From: ecn@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130521191343.90CFE23888E7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ecn Date: Tue May 21 19:13:43 2013 New Revision: 1484908 URL: http://svn.apache.org/r1484908 Log: ACCUMULO-1421 use reflection to work around class/interface change in Counter Modified: accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/continuous/ContinuousVerify.java Modified: accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/continuous/ContinuousVerify.java URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/continuous/ContinuousVerify.java?rev=1484908&r1=1484907&r2=1484908&view=diff ============================================================================== --- accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/continuous/ContinuousVerify.java (original) +++ accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/continuous/ContinuousVerify.java Tue May 21 19:13:43 2013 @@ -17,6 +17,7 @@ package org.apache.accumulo.test.continuous; import java.io.IOException; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -36,6 +37,7 @@ import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.io.VLongWritable; +import org.apache.hadoop.mapred.Counters.Counter; import org.apache.hadoop.mapreduce.Job; import org.apache.hadoop.mapreduce.Mapper; import org.apache.hadoop.mapreduce.Reducer; @@ -52,6 +54,24 @@ import com.beust.jcommander.validators.P public class ContinuousVerify extends Configured implements Tool { + // work around hadoop-1/hadoop-2 runtime incompatibility + static private Method INCREMENT; + static { + try { + INCREMENT = Counter.class.getMethod("increment", Long.TYPE); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + + private static void increment(Object obj) { + try { + INCREMENT.invoke(obj, 1L); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + public static final VLongWritable DEF = new VLongWritable(-1); public static class CMapper extends Mapper { @@ -59,7 +79,7 @@ public class ContinuousVerify extends Co private LongWritable row = new LongWritable(); private LongWritable ref = new LongWritable(); private VLongWritable vrow = new VLongWritable(); - + private long corrupt = 0; @Override @@ -71,7 +91,7 @@ public class ContinuousVerify extends Co try { ContinuousWalk.validate(key, data); } catch (BadChecksumException bce) { - context.getCounter(Counts.CORRUPT).increment(1); + increment(context.getCounter(Counts.CORRUPT)); if (corrupt < 1000) { System.out.println("ERROR Bad checksum : " + key); } else if (corrupt == 1000) { @@ -126,12 +146,12 @@ public class ContinuousVerify extends Co } context.write(new Text(ContinuousIngest.genRow(key.get())), new Text(sb.toString())); - context.getCounter(Counts.UNDEFINED).increment(1); + increment(context.getCounter(Counts.UNDEFINED)); } else if (defCount > 0 && refs.size() == 0) { - context.getCounter(Counts.UNREFERENCED).increment(1); + increment(context.getCounter(Counts.UNREFERENCED)); } else { - context.getCounter(Counts.REFERENCED).increment(1); + increment(context.getCounter(Counts.REFERENCED)); } }