Return-Path: Delivered-To: apmail-hadoop-mapreduce-commits-archive@minotaur.apache.org Received: (qmail 3263 invoked from network); 1 Nov 2010 22:54:42 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 1 Nov 2010 22:54:42 -0000 Received: (qmail 15881 invoked by uid 500); 1 Nov 2010 22:55:13 -0000 Delivered-To: apmail-hadoop-mapreduce-commits-archive@hadoop.apache.org Received: (qmail 15489 invoked by uid 500); 1 Nov 2010 22:55:13 -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 15470 invoked by uid 99); 1 Nov 2010 22:55:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Nov 2010 22:55:12 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.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, 01 Nov 2010 22:55:12 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E5DCF23888EA; Mon, 1 Nov 2010 22:53:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1029877 - in /hadoop/mapreduce/trunk: CHANGES.txt src/contrib/fairscheduler/src/test/org/apache/hadoop/mapred/TestFairSchedulerSystem.java Date: Mon, 01 Nov 2010 22:53:58 -0000 To: mapreduce-commits@hadoop.apache.org From: tomwhite@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101101225358.E5DCF23888EA@eris.apache.org> Author: tomwhite Date: Mon Nov 1 22:53:58 2010 New Revision: 1029877 URL: http://svn.apache.org/viewvc?rev=1029877&view=rev Log: MAPREDUCE-2051. Contribute a fair scheduler preemption system test. Contributed by Todd Lipcon. Added: hadoop/mapreduce/trunk/src/contrib/fairscheduler/src/test/org/apache/hadoop/mapred/TestFairSchedulerSystem.java (with props) Modified: hadoop/mapreduce/trunk/CHANGES.txt Modified: hadoop/mapreduce/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/CHANGES.txt?rev=1029877&r1=1029876&r2=1029877&view=diff ============================================================================== --- hadoop/mapreduce/trunk/CHANGES.txt (original) +++ hadoop/mapreduce/trunk/CHANGES.txt Mon Nov 1 22:53:58 2010 @@ -152,6 +152,9 @@ Trunk (unreleased changes) MAPREDUCE-1818. RaidNode can specify scheduling parameters. (Ramkumar Vadali via schen) + MAPREDUCE-2051. Contribute a fair scheduler preemption system test. + (Todd Lipcon via tomwhite) + OPTIMIZATIONS MAPREDUCE-1354. Enhancements to JobTracker for better performance and Added: hadoop/mapreduce/trunk/src/contrib/fairscheduler/src/test/org/apache/hadoop/mapred/TestFairSchedulerSystem.java URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/contrib/fairscheduler/src/test/org/apache/hadoop/mapred/TestFairSchedulerSystem.java?rev=1029877&view=auto ============================================================================== --- hadoop/mapreduce/trunk/src/contrib/fairscheduler/src/test/org/apache/hadoop/mapred/TestFairSchedulerSystem.java (added) +++ hadoop/mapreduce/trunk/src/contrib/fairscheduler/src/test/org/apache/hadoop/mapred/TestFairSchedulerSystem.java Mon Nov 1 22:53:58 2010 @@ -0,0 +1,88 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.mapred; + +import org.apache.hadoop.mapreduce.server.jobtracker.JTConfig; +import org.apache.hadoop.mapreduce.SleepJob; +import org.apache.hadoop.util.ToolRunner; +import org.apache.hadoop.conf.Configuration; +import java.util.concurrent.Callable; +import java.util.concurrent.Executors; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * System tests for the fair scheduler. These run slower than the + * mock-based tests in TestFairScheduler but have a better chance + * of catching synchronization bugs with the real JT. + */ +public class TestFairSchedulerSystem { + static final int NUM_THREADS=5; + + private void runSleepJob(JobConf conf) throws Exception { + String[] args = { "-m", "1", "-r", "1", "-mt", "1", "-rt", "1" }; + ToolRunner.run(conf, new SleepJob(), args); + } + + /** + * Bump up the frequency of preemption updates to test against + * deadlocks, etc. + */ + @Test + public void testPreemptionUpdates() throws Exception { + MiniMRCluster mr = null; + try { + final int taskTrackers = 1; + + JobConf conf = new JobConf(); + conf.set("mapred.jobtracker.taskScheduler", FairScheduler.class.getCanonicalName()); + conf.set("mapred.fairscheduler.update.interval", "0"); + conf.set("mapred.fairscheduler.preemption.interval", "0"); + conf.set("mapred.fairscheduler.preemption", "true"); + conf.set("mapred.fairscheduler.eventlog.enabled", "true"); + conf.set(JTConfig.JT_PERSIST_JOBSTATUS, "false"); + + mr = new MiniMRCluster(taskTrackers, "file:///", 1, null, null, conf); + final MiniMRCluster finalMR = mr; + ExecutorService exec = Executors.newFixedThreadPool(NUM_THREADS); + List> futures = new ArrayList>(NUM_THREADS); + for (int i = 0; i < NUM_THREADS; i++) { + futures.add(exec.submit(new Callable() { + public Void call() throws Exception { + JobConf jobConf = finalMR.createJobConf(); + runSleepJob(jobConf); + return null; + } + })); + } + + for (Future future : futures) { + future.get(); + } + } finally { + if (mr != null) { mr.shutdown(); + } + } + + } +} Propchange: hadoop/mapreduce/trunk/src/contrib/fairscheduler/src/test/org/apache/hadoop/mapred/TestFairSchedulerSystem.java ------------------------------------------------------------------------------ svn:eol-style = native