Return-Path: X-Original-To: apmail-hadoop-mapreduce-commits-archive@minotaur.apache.org Delivered-To: apmail-hadoop-mapreduce-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 00FD3D404 for ; Mon, 24 Sep 2012 21:18:18 +0000 (UTC) Received: (qmail 2213 invoked by uid 500); 24 Sep 2012 21:18:17 -0000 Delivered-To: apmail-hadoop-mapreduce-commits-archive@hadoop.apache.org Received: (qmail 2157 invoked by uid 500); 24 Sep 2012 21:18:17 -0000 Mailing-List: contact mapreduce-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: mapreduce-dev@hadoop.apache.org Delivered-To: mailing list mapreduce-commits@hadoop.apache.org Received: (qmail 2149 invoked by uid 99); 24 Sep 2012 21:18:17 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Sep 2012 21:18:17 +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; Mon, 24 Sep 2012 21:18:14 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id A6F5E23888E4; Mon, 24 Sep 2012 21:17:30 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1389595 - in /hadoop/common/branches/branch-2/hadoop-mapreduce-project: ./ hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/fs/slive/ Date: Mon, 24 Sep 2012 21:17:30 -0000 To: mapreduce-commits@hadoop.apache.org From: shv@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120924211730.A6F5E23888E4@eris.apache.org> Author: shv Date: Mon Sep 24 21:17:29 2012 New Revision: 1389595 URL: http://svn.apache.org/viewvc?rev=1389595&view=rev Log: MAPREDUCE-4645. Provide a random seed to Slive to make the sequence of file names deterministic. Contributed by Ravi Prakash. Modified: hadoop/common/branches/branch-2/hadoop-mapreduce-project/CHANGES.txt hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/fs/slive/Operation.java hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/fs/slive/SliveMapper.java Modified: hadoop/common/branches/branch-2/hadoop-mapreduce-project/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-mapreduce-project/CHANGES.txt?rev=1389595&r1=1389594&r2=1389595&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-mapreduce-project/CHANGES.txt (original) +++ hadoop/common/branches/branch-2/hadoop-mapreduce-project/CHANGES.txt Mon Sep 24 21:17:29 2012 @@ -409,6 +409,9 @@ Release 0.23.4 - UNRELEASED IMPROVEMENTS + MAPREDUCE-4645. Provide a random seed to Slive to make the sequence + of file names deterministic. (Ravi Prakash via shv) + OPTIMIZATIONS BUG FIXES Modified: hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/fs/slive/Operation.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/fs/slive/Operation.java?rev=1389595&r1=1389594&r2=1389595&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/fs/slive/Operation.java (original) +++ hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/fs/slive/Operation.java Mon Sep 24 21:17:29 2012 @@ -41,7 +41,9 @@ abstract class Operation { this.config = cfg; this.type = type; this.rnd = rnd; - this.finder = new PathFinder(cfg, rnd); + // Use a new Random instance so that the sequence of file names produced is + // the same even in case of unsuccessful operations + this.finder = new PathFinder(cfg, new Random(rnd.nextInt())); } /** Modified: hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/fs/slive/SliveMapper.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/fs/slive/SliveMapper.java?rev=1389595&r1=1389594&r2=1389595&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/fs/slive/SliveMapper.java (original) +++ hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/fs/slive/SliveMapper.java Mon Sep 24 21:17:29 2012 @@ -32,6 +32,8 @@ import org.apache.hadoop.mapred.MapReduc import org.apache.hadoop.mapred.Mapper; import org.apache.hadoop.mapred.OutputCollector; import org.apache.hadoop.mapred.Reporter; +import org.apache.hadoop.mapreduce.MRJobConfig; +import org.apache.hadoop.mapreduce.TaskAttemptID; import org.apache.hadoop.util.StringUtils; /** @@ -50,8 +52,7 @@ public class SliveMapper extends MapRedu private FileSystem filesystem; private ConfigExtractor config; - private WeightSelector selector; - private Random rnd; + private int taskId; /* * (non-Javadoc) @@ -70,19 +71,19 @@ public class SliveMapper extends MapRedu } try { config = new ConfigExtractor(conf); - Long rndSeed = config.getRandomSeed(); - if (rndSeed != null) { - rnd = new Random(rndSeed); - } else { - rnd = new Random(); - } - selector = new WeightSelector(config, rnd); ConfigExtractor.dumpOptions(config); } catch (Exception e) { LOG.error("Unable to setup slive " + StringUtils.stringifyException(e)); throw new RuntimeException("Unable to setup slive configuration", e); } - + if(conf.get(MRJobConfig.TASK_ATTEMPT_ID) != null ) { + this.taskId = TaskAttemptID.forName(conf.get(MRJobConfig.TASK_ATTEMPT_ID)) + .getTaskID().getId(); + } else { + // So that branch-1/0.20 can run this same code as well + this.taskId = TaskAttemptID.forName(conf.get("mapred.task.id")) + .getTaskID().getId(); + } } /** @@ -95,15 +96,6 @@ public class SliveMapper extends MapRedu } /** - * Gets the operation selector to use for this object - * - * @return WeightSelector - */ - private WeightSelector getSelector() { - return selector; - } - - /** * Logs to the given reporter and logs to the internal logger at info level * * @param r @@ -154,6 +146,10 @@ public class SliveMapper extends MapRedu Reporter reporter) throws IOException { logAndSetStatus(reporter, "Running slive mapper for dummy key " + key + " and dummy value " + value); + //Add taskID to randomSeed to deterministically seed rnd. + Random rnd = config.getRandomSeed() != null ? + new Random(this.taskId + config.getRandomSeed()) : new Random(); + WeightSelector selector = new WeightSelector(config, rnd); long startTime = Timer.now(); long opAm = 0; long sleepOps = 0; @@ -163,7 +159,6 @@ public class SliveMapper extends MapRedu if (sleepRange != null) { sleeper = new SleepOp(getConfig(), rnd); } - WeightSelector selector = getSelector(); while (Timer.elapsed(startTime) < duration) { try { logAndSetStatus(reporter, "Attempting to select operation #"