hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cdoug...@apache.org
Subject svn commit: r632411 - in /hadoop/core/trunk: CHANGES.txt src/java/org/apache/hadoop/mapred/JobConf.java src/java/org/apache/hadoop/mapred/TaskRunner.java src/test/org/apache/hadoop/conf/TestJobConf.java
Date Fri, 29 Feb 2008 19:11:56 GMT
Author: cdouglas
Date: Fri Feb 29 11:11:52 2008
New Revision: 632411

URL: http://svn.apache.org/viewvc?rev=632411&view=rev
Log:
HADOOP-2895. Let the profiling string be configurable.
Contributed by Martin Traverso



Added:
    hadoop/core/trunk/src/test/org/apache/hadoop/conf/TestJobConf.java
Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/java/org/apache/hadoop/mapred/JobConf.java
    hadoop/core/trunk/src/java/org/apache/hadoop/mapred/TaskRunner.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=632411&r1=632410&r2=632411&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Fri Feb 29 11:11:52 2008
@@ -47,6 +47,9 @@
     methods for fs.default.name, and check for null authority in HDFS.
     (cutting)
 
+    HADOOP-2895. Let the profiling string be configurable.
+    (Martin Traverso via cdouglas)
+
   OPTIMIZATIONS
 
   BUG FIXES

Modified: hadoop/core/trunk/src/java/org/apache/hadoop/mapred/JobConf.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/java/org/apache/hadoop/mapred/JobConf.java?rev=632411&r1=632410&r2=632411&view=diff
==============================================================================
--- hadoop/core/trunk/src/java/org/apache/hadoop/mapred/JobConf.java (original)
+++ hadoop/core/trunk/src/java/org/apache/hadoop/mapred/JobConf.java Fri Feb 29 11:11:52 2008
@@ -1205,6 +1205,33 @@
   }
 
   /**
+   * Get the profiler configuration arguments.
+   *
+   * The default value for this property is
+   * "-agentlib:hprof=cpu=samples,heap=sites,force=n,thread=y,verbose=n,file=%s"
+   * 
+   * @return the parameters to pass to the task child to configure profiling
+   */
+  public String getProfileParams() {
+    return get("mapred.task.profile.params",
+               "-agentlib:hprof=cpu=samples,heap=sites,force=n,thread=y," +
+                 "verbose=n,file=%s");
+  }
+
+  /**
+   * Set the profiler configuration arguments. If the string contains a '%s' it
+   * will be replaced with the name of the profiling output file when the task
+   * runs.
+   *
+   * This value is passed to the task child JVM on the command line.
+   *
+   * @param value the configuration string
+   */
+  public void setProfileParams(String value) {
+    set("mapred.task.profile.params", value);
+  }
+
+  /**
    * Get the range of maps or reduces to profile.
    * @param isMap is the task a map?
    * @return the task ranges

Modified: hadoop/core/trunk/src/java/org/apache/hadoop/mapred/TaskRunner.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/java/org/apache/hadoop/mapred/TaskRunner.java?rev=632411&r1=632410&r2=632411&view=diff
==============================================================================
--- hadoop/core/trunk/src/java/org/apache/hadoop/mapred/TaskRunner.java (original)
+++ hadoop/core/trunk/src/java/org/apache/hadoop/mapred/TaskRunner.java Fri Feb 29 11:11:52
2008
@@ -355,8 +355,7 @@
         if (conf.getProfileTaskRange(t.isMapTask()
                                      ).isIncluded(t.getPartition())) {
           File prof = TaskLog.getTaskLogFile(taskid, TaskLog.LogName.PROFILE);
-          vargs.add("-agentlib:hprof=cpu=samples,heap=sites,force=n,thread=y,"
-                     + "verbose=n,file=" + prof.toString());
+          vargs.add(String.format(conf.getProfileParams(), prof.toString()));
         }
       }
 

Added: hadoop/core/trunk/src/test/org/apache/hadoop/conf/TestJobConf.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/conf/TestJobConf.java?rev=632411&view=auto
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/conf/TestJobConf.java (added)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/conf/TestJobConf.java Fri Feb 29 11:11:52
2008
@@ -0,0 +1,53 @@
+/**
+ * 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.conf;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.hadoop.mapred.JobConf;
+
+public class TestJobConf extends TestCase {
+
+  public void testProfileParamsDefaults() {
+    JobConf configuration = new JobConf();
+
+    Assert.assertNull(configuration.get("mapred.task.profile.params"));
+
+    String result = configuration.getProfileParams();
+
+    Assert.assertNotNull(result);
+    Assert.assertTrue(result.contains("file=%s"));
+    Assert.assertTrue(result.startsWith("-agentlib:hprof"));
+  }
+
+  public void testProfileParamsSetter() {
+    JobConf configuration = new JobConf();
+
+    configuration.setProfileParams("test");
+    Assert.assertEquals("test", configuration.get("mapred.task.profile.params"));
+  }
+
+  public void testProfileParamsGetter() {
+    JobConf configuration = new JobConf();
+
+    configuration.set("mapred.task.profile.params", "test");
+    Assert.assertEquals("test", configuration.getProfileParams());
+  }
+
+
+}



Mime
View raw message