diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index 5871b73cd06..19413b89f89 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -18,6 +18,9 @@ Trunk (Unreleased) Azure environments. (See breakdown of tasks below for subtasks and contributors) + MAPREDUCE-5232. Add a configuration to be able to log classpath and other + system properties on mapreduce JVMs startup. (Sangjin Lee via vinodkv) + IMPROVEMENTS MAPREDUCE-3481. [Gridmix] Improve Gridmix STRESS mode. (amarrk) diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapred/YarnChild.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapred/YarnChild.java index 6c1382d9e97..e4d0041d211 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapred/YarnChild.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapred/YarnChild.java @@ -142,6 +142,12 @@ class YarnChild { // Create the job-conf and set credentials final JobConf job = configureTask(task, credentials, jt); + // log the system properties + String systemPropsToLog = MRApps.getSystemPropertiesToLog(job); + if (systemPropsToLog != null) { + LOG.info(systemPropsToLog); + } + // Initiate Java VM metrics JvmMetrics.initSingleton(jvmId.toString(), job.getSessionId()); childUGI = UserGroupInformation.createRemoteUser(System diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/MRAppMaster.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/MRAppMaster.java index 4d07698b95d..2a3f9c17986 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/MRAppMaster.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/MRAppMaster.java @@ -1306,6 +1306,13 @@ public class MRAppMaster extends CompositeService { new MRAppMasterShutdownHook(appMaster), SHUTDOWN_HOOK_PRIORITY); JobConf conf = new JobConf(new YarnConfiguration()); conf.addResource(new Path(MRJobConfig.JOB_CONF_FILE)); + + // log the system properties + String systemPropsToLog = MRApps.getSystemPropertiesToLog(conf); + if (systemPropsToLog != null) { + LOG.info(systemPropsToLog); + } + String jobUserName = System .getenv(ApplicationConstants.Environment.USER.name()); conf.set(MRJobConfig.USER_NAME, jobUserName); diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/util/MRApps.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/util/MRApps.java index 975d9f8c010..b8ba561fe46 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/util/MRApps.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/util/MRApps.java @@ -463,4 +463,35 @@ public class MRApps extends Apps { vargs.add("-D" + MRJobConfig.TASK_LOG_SIZE + "=" + logSize); vargs.add("-Dhadoop.root.logger=" + logLevel + ",CLA"); } + + /** + * Return lines for system property keys and values per configuration. + * + * @return the formatted string for the system property lines or null if no + * properties are specified. + */ + public static String getSystemPropertiesToLog(Configuration conf) { + String key = conf.get(MRJobConfig.MAPREDUCE_JVM_SYSTEM_PROPERTIES_TO_LOG, + MRJobConfig.DEFAULT_MAPREDUCE_JVM_SYSTEM_PROPERTIES_TO_LOG); + if (key != null) { + key = key.trim(); // trim leading and trailing whitespace from the config + if (!key.isEmpty()) { + String[] props = key.split(","); + if (props.length > 0) { + StringBuilder sb = new StringBuilder(); + sb.append("\n/************************************************************\n"); + sb.append("[system properties]\n"); + for (String prop: props) { + prop = prop.trim(); // trim leading and trailing whitespace + if (!prop.isEmpty()) { + sb.append(prop).append(": ").append(System.getProperty(prop)).append('\n'); + } + } + sb.append("************************************************************/"); + return sb.toString(); + } + } + } + return null; + } } diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/test/java/org/apache/hadoop/mapreduce/v2/util/TestMRApps.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/test/java/org/apache/hadoop/mapreduce/v2/util/TestMRApps.java index 05497cc0c7c..160da133857 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/test/java/org/apache/hadoop/mapreduce/v2/util/TestMRApps.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/test/java/org/apache/hadoop/mapreduce/v2/util/TestMRApps.java @@ -399,5 +399,24 @@ public class TestMRApps { } public void initialize(URI name, Configuration conf) throws IOException {} } - + + @Test + public void testLogSystemProperties() throws Exception { + Configuration conf = new Configuration(); + // test no logging + conf.set(MRJobConfig.MAPREDUCE_JVM_SYSTEM_PROPERTIES_TO_LOG, " "); + String value = MRApps.getSystemPropertiesToLog(conf); + assertNull(value); + + // test logging of selected keys + String classpath = "java.class.path"; + String os = "os.name"; + String version = "java.version"; + conf.set(MRJobConfig.MAPREDUCE_JVM_SYSTEM_PROPERTIES_TO_LOG, classpath + ", " + os); + value = MRApps.getSystemPropertiesToLog(conf); + assertNotNull(value); + assertTrue(value.contains(classpath)); + assertTrue(value.contains(os)); + assertFalse(value.contains(version)); + } } diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/MRJobConfig.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/MRJobConfig.java index 110b18d5563..81add614e84 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/MRJobConfig.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/MRJobConfig.java @@ -134,6 +134,11 @@ public interface MRJobConfig { public static final String MAPREDUCE_JOB_CLASSLOADER_SYSTEM_CLASSES = "mapreduce.job.classloader.system.classes"; + public static final String MAPREDUCE_JVM_SYSTEM_PROPERTIES_TO_LOG = "mapreduce.jvm.system-properties-to-log"; + public static final String DEFAULT_MAPREDUCE_JVM_SYSTEM_PROPERTIES_TO_LOG = + "os.name,os.version,java.home,java.runtime.version,java.vendor," + + "java.version,java.vm.name,java.class.path,java.io.tmpdir,user.dir,user.name"; + public static final String IO_SORT_FACTOR = "mapreduce.task.io.sort.factor"; public static final String IO_SORT_MB = "mapreduce.task.io.sort.mb"; diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/resources/mapred-default.xml b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/resources/mapred-default.xml index 4135ac072d9..392bf6ddedb 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/resources/mapred-default.xml +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/resources/mapred-default.xml @@ -1014,6 +1014,12 @@ + + mapreduce.jvm.system-properties-to-log + os.name,os.version,java.home,java.runtime.version,java.vendor,java.version,java.vm.name,java.class.path,java.io.tmpdir,user.dir,user.name + Comma-delimited list of system properties to log on mapreduce JVM start + +