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 AB7C81086D for ; Mon, 31 Mar 2014 18:48:59 +0000 (UTC) Received: (qmail 85559 invoked by uid 500); 31 Mar 2014 18:48:59 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 85456 invoked by uid 500); 31 Mar 2014 18:48:57 -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 85274 invoked by uid 99); 31 Mar 2014 18:48:55 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 31 Mar 2014 18:48:54 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id A576B908B97; Mon, 31 Mar 2014 18:48:54 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ctubbsii@apache.org To: commits@accumulo.apache.org Date: Mon, 31 Mar 2014 18:48:54 -0000 Message-Id: <7f5f6a820a68408ca9ef8d99b28a8786@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/6] git commit: ACCUMULO-2566 Fix botched merge Repository: accumulo Updated Branches: refs/heads/master 51761404c -> 2256227b1 ACCUMULO-2566 Fix botched merge Fixing a bad merge for TeraSortIngest using reflection to get hadoop configuration objects. Copied the code from InputFormatBase because the method we need is not visible and adding it to the public API would be a terrible, terrible thing to do. Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/34a44e70 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/34a44e70 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/34a44e70 Branch: refs/heads/master Commit: 34a44e700312a01822e046c89dd892616ef92e42 Parents: 0d2cd1c Author: Mike Drob Authored: Sat Mar 29 00:48:19 2014 -0400 Committer: Mike Drob Committed: Sat Mar 29 00:48:19 2014 -0400 ---------------------------------------------------------------------- .../simple/mapreduce/TeraSortIngest.java | 27 ++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/34a44e70/examples/simple/src/main/java/org/apache/accumulo/examples/simple/mapreduce/TeraSortIngest.java ---------------------------------------------------------------------- diff --git a/examples/simple/src/main/java/org/apache/accumulo/examples/simple/mapreduce/TeraSortIngest.java b/examples/simple/src/main/java/org/apache/accumulo/examples/simple/mapreduce/TeraSortIngest.java index f131e6c..bdcf943 100644 --- a/examples/simple/src/main/java/org/apache/accumulo/examples/simple/mapreduce/TeraSortIngest.java +++ b/examples/simple/src/main/java/org/apache/accumulo/examples/simple/mapreduce/TeraSortIngest.java @@ -21,6 +21,7 @@ package org.apache.accumulo.examples.simple.mapreduce; import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; import java.util.Random; @@ -166,8 +167,8 @@ public class TeraSortIngest extends Configured implements Tool { */ @Override public List getSplits(JobContext job) { - long totalRows = InputFormatBase.getConfiguration(job).getLong(NUMROWS, 0); - int numSplits = InputFormatBase.getConfiguration(job).getInt(NUMSPLITS, 1); + long totalRows = getConfiguration(job).getLong(NUMROWS, 0); + int numSplits = getConfiguration(job).getInt(NUMSPLITS, 1); long rowsPerSplit = totalRows / numSplits; System.out.println("Generating " + totalRows + " using " + numSplits + " maps with step of " + rowsPerSplit); ArrayList splits = new ArrayList(numSplits); @@ -181,6 +182,28 @@ public class TeraSortIngest extends Configured implements Tool { return splits; } + // TODO kill this when we drop Hadoop 1 support. + private static final Method GET_CONFIGURATION; + static { + try { + GET_CONFIGURATION = Class.forName("org.apache.hadoop.mapreduce.JobContext").getMethod("getConfiguration"); + } catch (SecurityException e) { + throw new RuntimeException("Could not get method.", e); + } catch (NoSuchMethodException e) { + throw new RuntimeException("Could not get method.", e); + } catch (ClassNotFoundException e) { + throw new RuntimeException("Could not get JobContext declaration.", e); + } + } + + // This is copied from InputFormatBase because the implementation there is not public and we don not really want cruft like this in the public API. + private static Configuration getConfiguration(JobContext job) { + try { + return (Configuration) GET_CONFIGURATION.invoke(job, new Object[0]); + } catch (Exception e) { + throw new RuntimeException(e); + } + } } private static String NUMSPLITS = "terasort.overridesplits";