incubator-hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardy...@apache.org
Subject svn commit: r1232768 - in /incubator/hama/trunk: ./ core/ core/dev-support/ core/src/main/java/org/apache/hama/ core/src/main/java/org/apache/hama/util/ core/src/main/webapp/bspmaster/
Date Wed, 18 Jan 2012 07:30:06 GMT
Author: edwardyoon
Date: Wed Jan 18 07:30:05 2012
New Revision: 1232768

URL: http://svn.apache.org/viewvc?rev=1232768&view=rev
Log:
HAMA-470: The web UI should display the version of running Hama cluster. (Suraj Menon via
edwardyoon)

Added:
    incubator/hama/trunk/core/dev-support/
    incubator/hama/trunk/core/dev-support/saveVersion.sh
    incubator/hama/trunk/core/src/main/java/org/apache/hama/HamaVersionAnnotation.java
Modified:
    incubator/hama/trunk/CHANGES.txt
    incubator/hama/trunk/core/pom.xml
    incubator/hama/trunk/core/src/main/java/org/apache/hama/util/VersionInfo.java
    incubator/hama/trunk/core/src/main/webapp/bspmaster/bspmaster.jsp
    incubator/hama/trunk/pom.xml

Modified: incubator/hama/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/CHANGES.txt?rev=1232768&r1=1232767&r2=1232768&view=diff
==============================================================================
--- incubator/hama/trunk/CHANGES.txt (original)
+++ incubator/hama/trunk/CHANGES.txt Wed Jan 18 07:30:05 2012
@@ -32,6 +32,7 @@ Release 0.4 - Unreleased
 
   IMPROVEMENTS
   
+    HAMA-470: The web UI should display the version of running Hama cluster. (Suraj Menon
via edwardyoon)
     HAMA-475: Add unit test for SSSP example (edwardyoon)
     HAMA-481: Add reopen to peer (tjungblut) 
     HAMA-471: Peer names should be sorted by task id (tjungblut)

Added: incubator/hama/trunk/core/dev-support/saveVersion.sh
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/core/dev-support/saveVersion.sh?rev=1232768&view=auto
==============================================================================
--- incubator/hama/trunk/core/dev-support/saveVersion.sh (added)
+++ incubator/hama/trunk/core/dev-support/saveVersion.sh Wed Jan 18 07:30:05 2012
@@ -0,0 +1,67 @@
+#!/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 | tr '\n\r' '\n'`
+date=`date`
+cwd=`pwd`
+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
+
+which md5sum > /dev/null
+if [ "$?" = "0" ] ; then
+  srcChecksum=`find src/main/java -name '*.java' | LC_ALL=C sort | xargs md5sum | md5sum
| cut -d ' ' -f 1`
+else
+  srcChecksum="Not Available"
+fi
+
+mkdir -p $build_dir/org/apache/hama
+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/org/apache/hama/package-info.java
+/*
+ * Generated by src/saveVersion.sh
+ */
+@HamaVersionAnnotation(version="VERSION", revision="REV", branch="BRANCH",
+                         user="USER", date="DATE", url="URL",
+                         srcChecksum="SRCCHECKSUM")
+package org.apache.hama;
+EOF

Modified: incubator/hama/trunk/core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/core/pom.xml?rev=1232768&r1=1232767&r2=1232768&view=diff
==============================================================================
--- incubator/hama/trunk/core/pom.xml (original)
+++ incubator/hama/trunk/core/pom.xml Wed Jan 18 07:30:05 2012
@@ -131,6 +131,46 @@
           </execution>
         </executions>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>save-version</id>
+            <phase>generate-sources</phase>
+            <goals>
+              <goal>run</goal>
+            </goals>
+            <configuration>
+              <target>
+                <mkdir dir="${project.build.directory}/generated-sources/java"/>
+                <exec executable="sh">
+                  <arg
+                      line="${basedir}/dev-support/saveVersion.sh ${project.version} ${project.build.directory}/generated-sources/annotations"/>
+                </exec>
+              </target>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>add-source</id>
+            <phase>generate-sources</phase>
+            <goals>
+              <goal>add-source</goal>
+            </goals>
+            <configuration>
+              <sources>
+                <source>${project.build.directory}/generated-sources/annotations</source>
+              </sources>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
     <finalName>hama-core-${project.version}</finalName>
   </build>

Added: incubator/hama/trunk/core/src/main/java/org/apache/hama/HamaVersionAnnotation.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/core/src/main/java/org/apache/hama/HamaVersionAnnotation.java?rev=1232768&view=auto
==============================================================================
--- incubator/hama/trunk/core/src/main/java/org/apache/hama/HamaVersionAnnotation.java (added)
+++ incubator/hama/trunk/core/src/main/java/org/apache/hama/HamaVersionAnnotation.java Wed
Jan 18 07:30:05 2012
@@ -0,0 +1,62 @@
+package org.apache.hama;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * An attribute that 
+ * holds the information on version and build information of a
+ * Hama package that a potential user is working with.
+ */
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.PACKAGE)
+
+public @interface HamaVersionAnnotation {
+
+  /**
+   * Get the Hama version
+   * @return the version string "0.3.3-dev"
+   */
+  String version();
+
+  /**
+   * Get the username that compiled Hama.
+   */
+  String user();
+
+  /**
+   * Get the date when Hama 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
+   * Hama was compiled.
+   * @return a string that uniquely identifies the source
+   **/
+  String srcChecksum(); 	
+
+
+
+}

Modified: incubator/hama/trunk/core/src/main/java/org/apache/hama/util/VersionInfo.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/core/src/main/java/org/apache/hama/util/VersionInfo.java?rev=1232768&r1=1232767&r2=1232768&view=diff
==============================================================================
--- incubator/hama/trunk/core/src/main/java/org/apache/hama/util/VersionInfo.java (original)
+++ incubator/hama/trunk/core/src/main/java/org/apache/hama/util/VersionInfo.java Wed Jan
18 07:30:05 2012
@@ -17,12 +17,106 @@
  */
 package org.apache.hama.util;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hama.HamaVersionAnnotation;
+
+
 /**
- * A version information class.
+ * A version information class. The code is picked from Apache Hadoop and 
+ * adapted for Hama code-base.
  */
 public class VersionInfo {
 
+  private static final Log LOG = LogFactory.getLog(VersionInfo.class);
+
+  private static Package myPackage;
+  private static HamaVersionAnnotation version;
+
+  static {
+    myPackage = HamaVersionAnnotation.class.getPackage();
+    version = myPackage.getAnnotation(HamaVersionAnnotation.class);
+  }
+
+  /**
+   * Get the meta-data for the Hama package.
+   * @return
+   */
+  static Package getPackage() {
+    return myPackage;
+  }
+
+  /**
+   * Get the Hama version.
+   * @return the Hama 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 Hama was compiled.
+   * @return the compilation date in unix date format
+   */
+  public static String getDate() {
+    return version != null ? version.date() : "Unknown";
+  }
+
+  /**
+   * The user that compiled Hama.
+   * @return the username of the user
+   */
+  public static String getUser() {
+    return version != null ? version.user() : "Unknown";
+  }
+
+  /**
+   * Get the subversion URL for the root Hama directory.
+   */
+  public static String getUrl() {
+    return version != null ? version.url() : "Unknown";
+  }
+
+  /**
+   * Get the checksum of the source files from which Hama 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 VersionInfo.getVersion() + 
+        " from " + VersionInfo.getRevision() +
+        " by " + VersionInfo.getUser() + 
+        " source checksum " + VersionInfo.getSrcChecksum();
+  }
+
   public static void main(String[] args) {
-    System.out.println("Apache Hama - 0.4");
+    LOG.debug("Version:" + version);
+    System.out.println("Apache Hama Version: " + getVersion());
+    System.out.println("Subversion: " + getUrl() + " -r " + getRevision());
+    System.out.println("Compiled by: " + getUser() + " on " + getDate());
+    System.out.println("From source with checksum: " + getSrcChecksum());
   }
 }

Modified: incubator/hama/trunk/core/src/main/webapp/bspmaster/bspmaster.jsp
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/core/src/main/webapp/bspmaster/bspmaster.jsp?rev=1232768&r1=1232767&r2=1232768&view=diff
==============================================================================
--- incubator/hama/trunk/core/src/main/webapp/bspmaster/bspmaster.jsp (original)
+++ incubator/hama/trunk/core/src/main/webapp/bspmaster/bspmaster.jsp Wed Jan 18 07:30:05
2012
@@ -61,6 +61,12 @@
 <%=status.getBSPMasterState()%><br>
 <b>Started:</b>
 <%=new Date(tracker.getStartTime())%><br>
+<b>Version:</b>
+<%=VersionInfo.getVersion()%><br>
+<b>Compiled By:</b>
+<%=VersionInfo.getUser()%><br>
+<b>Compiled At Time:</b>
+<%=VersionInfo.getDate()%><br>
 <b>Identifier:</b>
 <%=tracker.getBSPMasterIdentifier()%><br>
 
@@ -79,4 +85,4 @@
           30, 0)%>
 <%
   out.println(BSPServletUtil.htmlFooter());
-%>
\ No newline at end of file
+%>

Modified: incubator/hama/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/pom.xml?rev=1232768&r1=1232767&r2=1232768&view=diff
==============================================================================
--- incubator/hama/trunk/pom.xml (original)
+++ incubator/hama/trunk/pom.xml Wed Jan 18 07:30:05 2012
@@ -223,6 +223,11 @@
         <artifactId>maven-site-plugin</artifactId>
         <version>2.1.1</version>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <version>1.6</version>
+      </plugin>
     </plugins>
   </build>
   



Mime
View raw message