You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mapreduce-commits@hadoop.apache.org by ll...@apache.org on 2011/06/15 18:31:01 UTC
svn commit: r1136110 - in /hadoop/common/branches/MR-279/mapreduce: ./
assembly/ yarn/yarn-common/ yarn/yarn-common/scripts/
yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/
yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/util/ yarn/yarn-co...
Author: llu
Date: Wed Jun 15 16:31:00 2011
New Revision: 1136110
URL: http://svn.apache.org/viewvc?rev=1136110&view=rev
Log:
MAPREDUCE-2587. Generate yarn version for UI. (Thomas Graves via llu)
Added:
hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/scripts/
hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/scripts/saveVersion.sh (with props)
hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/YarnVersionAnnotation.java
hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/util/YarnVersionInfo.java
hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestYarnVersionInfo.java
Modified:
hadoop/common/branches/MR-279/mapreduce/CHANGES.txt
hadoop/common/branches/MR-279/mapreduce/assembly/all.xml
hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/pom.xml
hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RmController.java
Modified: hadoop/common/branches/MR-279/mapreduce/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/CHANGES.txt?rev=1136110&r1=1136109&r2=1136110&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/CHANGES.txt (original)
+++ hadoop/common/branches/MR-279/mapreduce/CHANGES.txt Wed Jun 15 16:31:00 2011
@@ -5,6 +5,8 @@ Trunk (unreleased changes)
MAPREDUCE-279
+ MAPREDUCE-2587. Generate yarn version for UI. (Thomas Graves via llu)
+
Fix stopContainer for setsid challenged platforms. (llu)
Fix concurrent modification exception in the Capacity Scheduler (mahadev)
Modified: hadoop/common/branches/MR-279/mapreduce/assembly/all.xml
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/assembly/all.xml?rev=1136110&r1=1136109&r2=1136110&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/assembly/all.xml (original)
+++ hadoop/common/branches/MR-279/mapreduce/assembly/all.xml Wed Jun 15 16:31:00 2011
@@ -1,7 +1,7 @@
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
- <id>bin</id>
+ <id>all</id>
<formats>
<format>tar.gz</format>
</formats>
@@ -44,6 +44,9 @@
<excludes>
<exclude>**/*.jar</exclude>
<exclude>**/target/**</exclude>
+ <!-- scripts to include later for setting fileMode -->
+ <exclude>**/bin/*</exclude>
+ <exclude>**/scripts/*</exclude>
<!-- images that we don't need (and cause problems for our tools) -->
<exclude>**/dt-*/images/**</exclude>
<!-- until the code that does this is fixed -->
@@ -63,6 +66,14 @@
<include>src/**</include>
</includes>
</fileSet>
+ <fileSet>
+ <outputDirectory>sources</outputDirectory>
+ <includes>
+ <include>**/bin/*</include>
+ <include>**/scripts/*</include>
+ </includes>
+ <fileMode>0755</fileMode>
+ </fileSet>
</fileSets>
<moduleSets>
<moduleSet>
Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/pom.xml
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/pom.xml?rev=1136110&r1=1136109&r2=1136110&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/pom.xml (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/pom.xml Wed Jun 15 16:31:00 2011
@@ -73,6 +73,20 @@
<goal>exec</goal>
</goals>
</execution>
+ <execution>
+ <id>generate-version</id>
+ <phase>generate-sources</phase>
+ <configuration>
+ <executable>scripts/saveVersion.sh</executable>
+ <arguments>
+ <argument>${yarn.version}</argument>
+ <argument>${project.build.directory}</argument>
+ </arguments>
+ </configuration>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ </execution>
</executions>
</plugin>
@@ -89,6 +103,7 @@
<configuration>
<sources>
<source>target/generated-sources/proto</source>
+ <source>target/generated-sources/version</source>
</sources>
</configuration>
</execution>
Added: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/scripts/saveVersion.sh
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/scripts/saveVersion.sh?rev=1136110&view=auto
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/scripts/saveVersion.sh (added)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/scripts/saveVersion.sh Wed Jun 15 16:31:00 2011
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+# 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.
+
+
+# This file is used to generate the package-info.java class that
+# records the version, revision, branch, user, timestamp, and url
+unset LANG
+unset LC_CTYPE
+unset LC_TIME
+version=$1
+build_dir=$2
+user=`whoami`
+date=`date`
+dir=`pwd`
+cwd=`dirname $dir`
+if git rev-parse HEAD 2>/dev/null > /dev/null ; then
+ revision=`git log -1 --pretty=format:"%H" ../`
+ hostname=`hostname`
+ branch=`git branch | sed -n -e 's/^* //p'`
+ url="git://${hostname}${cwd}"
+elif [ -d .svn ]; then
+ revision=`svn info ../ | sed -n -e 's/Last Changed Rev: \(.*\)/\1/p'`
+ url=`svn info ../ | sed -n -e 's/URL: \(.*\)/\1/p'`
+ # Get canonical branch (branches/X, tags/X, or trunk)
+ branch=`echo $url | sed -n -e 's,.*\(branches/.*\)$,\1,p' \
+ -e 's,.*\(tags/.*\)$,\1,p' \
+ -e 's,.*trunk$,trunk,p'`
+else
+ revision="Unknown"
+ branch="Unknown"
+ url="file://$cwd"
+fi
+srcChecksum=`find ../ -name '*.java' | grep -v generated-sources | LC_ALL=C sort | xargs md5sum | md5sum | cut -d ' ' -f 1`
+
+mkdir -p $build_dir/generated-sources/version/org/apache/hadoop/yarn/
+cat << EOF | \
+ sed -e "s/VERSION/$version/" -e "s/USER/$user/" -e "s/DATE/$date/" \
+ -e "s|URL|$url|" -e "s/REV/$revision/" \
+ -e "s|BRANCH|$branch|" -e "s/SRCCHECKSUM/$srcChecksum/" \
+ > $build_dir/generated-sources/version/org/apache/hadoop/yarn/package-info.java
+/*
+ * Generated by saveVersion.sh
+ */
+@YarnVersionAnnotation(version="VERSION", revision="REV", branch="BRANCH",
+ user="USER", date="DATE", url="URL",
+ srcChecksum="SRCCHECKSUM")
+package org.apache.hadoop.yarn;
+EOF
Propchange: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/scripts/saveVersion.sh
------------------------------------------------------------------------------
svn:executable = *
Added: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/YarnVersionAnnotation.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/YarnVersionAnnotation.java?rev=1136110&view=auto
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/YarnVersionAnnotation.java (added)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/YarnVersionAnnotation.java Wed Jun 15 16:31:00 2011
@@ -0,0 +1,74 @@
+/*
+ * 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.yarn;
+
+import java.lang.annotation.*;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+
+/**
+ * A package attribute that captures the version of Yarn that was compiled.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.PACKAGE)
+@InterfaceAudience.LimitedPrivate({"MapReduce", "yarn"})
+@InterfaceStability.Unstable
+public @interface YarnVersionAnnotation {
+
+ /**
+ * Get the Yarn version
+ * @return the version string "0.6.3-dev"
+ */
+ String version();
+
+ /**
+ * Get the username that compiled Yarn.
+ */
+ String user();
+
+ /**
+ * Get the date when Yarn was compiled.
+ * @return the date in unix 'date' format
+ */
+ String date();
+
+ /**
+ * Get the url for the subversion repository.
+ */
+ String url();
+
+ /**
+ * Get the subversion revision.
+ * @return the revision number as a string (eg. "451451")
+ */
+ String revision();
+
+ /**
+ * Get the branch from which this was compiled.
+ * @return The branch name, e.g. "trunk" or "branches/branch-0.20"
+ */
+ String branch();
+
+ /**
+ * Get a checksum of the source files from which
+ * Yarn was compiled.
+ * @return a string that uniquely identifies the source
+ **/
+ String srcChecksum();
+}
Added: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/util/YarnVersionInfo.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/util/YarnVersionInfo.java?rev=1136110&view=auto
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/util/YarnVersionInfo.java (added)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/util/YarnVersionInfo.java Wed Jun 15 16:31:00 2011
@@ -0,0 +1,125 @@
+/*
+ * 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.yarn.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.yarn.YarnVersionAnnotation;
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+
+/**
+ * This class finds the package info for Yarn and the YarnVersionAnnotation
+ * information.
+ */
+@InterfaceAudience.Private
+@InterfaceStability.Unstable
+public class YarnVersionInfo {
+ private static final Log LOG = LogFactory.getLog(YarnVersionInfo.class);
+
+ private static Package myPackage;
+ private static YarnVersionAnnotation version;
+
+ static {
+ myPackage = YarnVersionAnnotation.class.getPackage();
+ version = myPackage.getAnnotation(YarnVersionAnnotation.class);
+ }
+
+ /**
+ * Get the meta-data for the Yarn package.
+ * @return
+ */
+ static Package getPackage() {
+ return myPackage;
+ }
+
+ /**
+ * Get the Yarn version.
+ * @return the Yarn version string, eg. "0.6.3-dev"
+ */
+ public static String getVersion() {
+ return version != null ? version.version() : "Unknown";
+ }
+
+ /**
+ * Get the subversion revision number for the root directory
+ * @return the revision number, eg. "451451"
+ */
+ public static String getRevision() {
+ return version != null ? version.revision() : "Unknown";
+ }
+
+ /**
+ * Get the branch on which this originated.
+ * @return The branch name, e.g. "trunk" or "branches/branch-0.20"
+ */
+ public static String getBranch() {
+ return version != null ? version.branch() : "Unknown";
+ }
+
+ /**
+ * The date that Yarn was compiled.
+ * @return the compilation date in unix date format
+ */
+ public static String getDate() {
+ return version != null ? version.date() : "Unknown";
+ }
+
+ /**
+ * The user that compiled Yarn.
+ * @return the username of the user
+ */
+ public static String getUser() {
+ return version != null ? version.user() : "Unknown";
+ }
+
+ /**
+ * Get the subversion URL for the root Yarn directory.
+ */
+ public static String getUrl() {
+ return version != null ? version.url() : "Unknown";
+ }
+
+ /**
+ * Get the checksum of the source files from which Yarn was
+ * built.
+ **/
+ public static String getSrcChecksum() {
+ return version != null ? version.srcChecksum() : "Unknown";
+ }
+
+ /**
+ * Returns the buildVersion which includes version,
+ * revision, user and date.
+ */
+ public static String getBuildVersion(){
+ return YarnVersionInfo.getVersion() +
+ " from " + YarnVersionInfo.getRevision() +
+ " by " + YarnVersionInfo.getUser() +
+ " source checksum " + YarnVersionInfo.getSrcChecksum();
+ }
+
+ public static void main(String[] args) {
+ LOG.debug("version: "+ version);
+ System.out.println("Yarn " + getVersion());
+ System.out.println("Subversion " + getUrl() + " -r " + getRevision());
+ System.out.println("Compiled by " + getUser() + " on " + getDate());
+ System.out.println("From source with checksum " + getSrcChecksum());
+ }
+}
Added: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestYarnVersionInfo.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestYarnVersionInfo.java?rev=1136110&view=auto
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestYarnVersionInfo.java (added)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestYarnVersionInfo.java Wed Jun 15 16:31:00 2011
@@ -0,0 +1,55 @@
+/**
+ * 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.yarn.util;
+
+import junit.framework.TestCase;
+import java.io.IOException;
+
+import org.apache.hadoop.yarn.util.YarnVersionInfo;
+import org.junit.Test;
+
+/**
+ * A JUnit test to test {@link YarnVersionInfo}
+ */
+public class TestYarnVersionInfo extends TestCase {
+
+ /**
+ * Test the yarn version info routines.
+ * @throws IOException
+ */
+ @Test
+ public void testVersionInfoGenerated() throws IOException {
+
+ // can't easily know what the correct values are going to be so just
+ // make sure they aren't Unknown
+ assertTrue("getVersion returned Unknown", !YarnVersionInfo.getVersion().equals("Unknown"));
+ assertTrue("getUser returned Unknown", !YarnVersionInfo.getUser().equals("Unknown"));
+ assertTrue("getUrl returned Unknown", !YarnVersionInfo.getUrl().equals("Unknown"));
+ assertTrue("getSrcChecksum returned Unknown", !YarnVersionInfo.getSrcChecksum().equals("Unknown"));
+
+ // these could be Unknown if the VersionInfo generated from code not in svn or git
+ // so just check that they return something
+ assertNotNull("getRevision returned null", YarnVersionInfo.getRevision());
+ assertNotNull("getBranch returned null", YarnVersionInfo.getBranch());
+
+ assertTrue("getBuildVersion check doesn't contain: source checksum",
+ YarnVersionInfo.getBuildVersion().contains("source checksum"));
+
+ }
+}
Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RmController.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RmController.java?rev=1136110&r1=1136109&r2=1136110&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RmController.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RmController.java Wed Jun 15 16:31:00 2011
@@ -23,6 +23,7 @@ import static org.apache.hadoop.yarn.ser
import static org.apache.hadoop.yarn.util.StringHelper.join;
import org.apache.hadoop.util.VersionInfo;
+import org.apache.hadoop.yarn.util.YarnVersionInfo;
import org.apache.hadoop.yarn.api.records.Application;
import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
@@ -54,7 +55,7 @@ public class RmController extends Contro
_("Cluster ID:", ts).
_("ResourceManager state:", rm.getServiceState()).
_("ResourceManager started on:", Times.format(ts)).
- _("ResourceManager version:", "1.0-SNAPSHOT").
+ _("ResourceManager version:", YarnVersionInfo.getBuildVersion()).
_("Hadoop version:", VersionInfo.getBuildVersion());
render(InfoPage.class);
}