You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by su...@apache.org on 2018/08/10 23:32:09 UTC
[09/25] hadoop git commit: HDDS-219. Genearate
version-info.properties for hadoop and ozone. Contributed by Sandeep Nemuri.
HDDS-219. Genearate version-info.properties for hadoop and ozone. Contributed by Sandeep Nemuri.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/3d96bc6e
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/3d96bc6e
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/3d96bc6e
Branch: refs/heads/HDFS-12943
Commit: 3d96bc6e5ff098900cf07e4b30c642e961a39427
Parents: 00013d6
Author: Márton Elek <el...@apache.org>
Authored: Thu Aug 9 11:06:03 2018 +0200
Committer: Márton Elek <el...@apache.org>
Committed: Thu Aug 9 11:06:03 2018 +0200
----------------------------------------------------------------------
hadoop-hdds/common/pom.xml | 34 +++
.../apache/hadoop/utils/HddsVersionInfo.java | 182 ++++++++++++++++
.../main/resources/hdds-version-info.properties | 26 +++
hadoop-ozone/common/pom.xml | 35 +++
hadoop-ozone/common/src/main/bin/ozone | 2 +-
.../hadoop/ozone/util/OzoneVersionInfo.java | 213 +++++++++++++++++++
.../resources/ozone-version-info.properties | 27 +++
7 files changed, 518 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3d96bc6e/hadoop-hdds/common/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-hdds/common/pom.xml b/hadoop-hdds/common/pom.xml
index 4068522..ed29d31 100644
--- a/hadoop-hdds/common/pom.xml
+++ b/hadoop-hdds/common/pom.xml
@@ -29,10 +29,12 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
<packaging>jar</packaging>
<properties>
+ <hdds.version>0.2.1-SNAPSHOT</hdds.version>
<hadoop.component>hdds</hadoop.component>
<is.hadoop.component>true</is.hadoop.component>
<log4j2.version>2.11.0</log4j2.version>
<disruptor.version>3.4.2</disruptor.version>
+ <declared.hdds.version>${hdds.version}</declared.hdds.version>
</properties>
<dependencies>
@@ -102,6 +104,22 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
</dependencies>
<build>
+ <resources>
+ <resource>
+ <directory>${basedir}/src/main/resources</directory>
+ <excludes>
+ <exclude>hdds-version-info.properties</exclude>
+ </excludes>
+ <filtering>false</filtering>
+ </resource>
+ <resource>
+ <directory>${basedir}/src/main/resources</directory>
+ <includes>
+ <include>hdds-version-info.properties</include>
+ </includes>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
@@ -170,6 +188,22 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
<artifactId>hadoop-maven-plugins</artifactId>
<executions>
<execution>
+ <id>version-info</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>version-info</goal>
+ </goals>
+ <configuration>
+ <source>
+ <directory>${basedir}/../</directory>
+ <includes>
+ <include>*/src/main/java/**/*.java</include>
+ <include>*/src/main/proto/*.proto</include>
+ </includes>
+ </source>
+ </configuration>
+ </execution>
+ <execution>
<id>compile-protoc</id>
<goals>
<goal>protoc</goal>
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3d96bc6e/hadoop-hdds/common/src/main/java/org/apache/hadoop/utils/HddsVersionInfo.java
----------------------------------------------------------------------
diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/utils/HddsVersionInfo.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/utils/HddsVersionInfo.java
new file mode 100644
index 0000000..59b9de6
--- /dev/null
+++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/utils/HddsVersionInfo.java
@@ -0,0 +1,182 @@
+/*
+ * 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.utils;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+import org.apache.hadoop.io.IOUtils;
+import org.apache.hadoop.util.ClassUtil;
+import org.apache.hadoop.util.ThreadUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * This class returns build information about Hadoop components.
+ */
+@InterfaceAudience.Public
+@InterfaceStability.Stable
+public class HddsVersionInfo {
+ private static final Logger LOG = LoggerFactory.getLogger(HddsVersionInfo.class);
+
+ private Properties info;
+
+ protected HddsVersionInfo(String component) {
+ info = new Properties();
+ String versionInfoFile = component + "-version-info.properties";
+ InputStream is = null;
+ try {
+ is = ThreadUtil.getResourceAsStream(HddsVersionInfo.class.getClassLoader(),
+ versionInfoFile);
+ info.load(is);
+ } catch (IOException ex) {
+ LoggerFactory.getLogger(getClass()).warn("Could not read '" +
+ versionInfoFile + "', " + ex.toString(), ex);
+ } finally {
+ IOUtils.closeStream(is);
+ }
+ }
+
+ protected String _getVersion() {
+ return info.getProperty("version", "Unknown");
+ }
+
+ protected String _getRevision() {
+ return info.getProperty("revision", "Unknown");
+ }
+
+ protected String _getBranch() {
+ return info.getProperty("branch", "Unknown");
+ }
+
+ protected String _getDate() {
+ return info.getProperty("date", "Unknown");
+ }
+
+ protected String _getUser() {
+ return info.getProperty("user", "Unknown");
+ }
+
+ protected String _getUrl() {
+ return info.getProperty("url", "Unknown");
+ }
+
+ protected String _getSrcChecksum() {
+ return info.getProperty("srcChecksum", "Unknown");
+ }
+
+ protected String _getBuildVersion(){
+ return _getVersion() +
+ " from " + _getRevision() +
+ " by " + _getUser() +
+ " source checksum " + _getSrcChecksum();
+ }
+
+ protected String _getProtocVersion() {
+ return info.getProperty("protocVersion", "Unknown");
+ }
+
+ private static HddsVersionInfo HDDS_VERSION_INFO = new HddsVersionInfo("hdds");
+ /**
+ * Get the HDDS version.
+ * @return the Hdds version string, eg. "0.6.3-dev"
+ */
+ public static String getVersion() {
+ return HDDS_VERSION_INFO._getVersion();
+ }
+
+ /**
+ * Get the Git commit hash of the repository when compiled.
+ * @return the commit hash, eg. "18f64065d5db6208daf50b02c1b5ed4ee3ce547a"
+ */
+ public static String getRevision() {
+ return HDDS_VERSION_INFO._getRevision();
+ }
+
+ /**
+ * Get the branch on which this originated.
+ * @return The branch name, e.g. "trunk" or "branches/branch-0.20"
+ */
+ public static String getBranch() {
+ return HDDS_VERSION_INFO._getBranch();
+ }
+
+ /**
+ * The date that HDDS was compiled.
+ * @return the compilation date in unix date format
+ */
+ public static String getDate() {
+ return HDDS_VERSION_INFO._getDate();
+ }
+
+ /**
+ * The user that compiled HDDS.
+ * @return the username of the user
+ */
+ public static String getUser() {
+ return HDDS_VERSION_INFO._getUser();
+ }
+
+ /**
+ * Get the URL for the HDDS repository.
+ * @return the URL of the Hdds repository
+ */
+ public static String getUrl() {
+ return HDDS_VERSION_INFO._getUrl();
+ }
+
+ /**
+ * Get the checksum of the source files from which HDDS was built.
+ * @return the checksum of the source files
+ */
+ public static String getSrcChecksum() {
+ return HDDS_VERSION_INFO._getSrcChecksum();
+ }
+
+ /**
+ * Returns the buildVersion which includes version,
+ * revision, user and date.
+ * @return the buildVersion
+ */
+ public static String getBuildVersion(){
+ return HDDS_VERSION_INFO._getBuildVersion();
+ }
+
+ /**
+ * Returns the protoc version used for the build.
+ * @return the protoc version
+ */
+ public static String getProtocVersion(){
+ return HDDS_VERSION_INFO._getProtocVersion();
+ }
+
+ public static void main(String[] args) {
+ System.out.println("Using HDDS " + getVersion());
+ System.out.println("Source code repository " + getUrl() + " -r " +
+ getRevision());
+ System.out.println("Compiled by " + getUser() + " on " + getDate());
+ System.out.println("Compiled with protoc " + getProtocVersion());
+ System.out.println("From source with checksum " + getSrcChecksum());
+ LOG.debug("This command was run using " +
+ ClassUtil.findContainingJar(HddsVersionInfo.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3d96bc6e/hadoop-hdds/common/src/main/resources/hdds-version-info.properties
----------------------------------------------------------------------
diff --git a/hadoop-hdds/common/src/main/resources/hdds-version-info.properties b/hadoop-hdds/common/src/main/resources/hdds-version-info.properties
new file mode 100644
index 0000000..2cbd817
--- /dev/null
+++ b/hadoop-hdds/common/src/main/resources/hdds-version-info.properties
@@ -0,0 +1,26 @@
+#
+# 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.
+#
+
+version=${declared.hdds.version}
+revision=${version-info.scm.commit}
+branch=${version-info.scm.branch}
+user=${user.name}
+date=${version-info.build.time}
+url=${version-info.scm.uri}
+srcChecksum=${version-info.source.md5}
+protocVersion=${protobuf.version}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3d96bc6e/hadoop-ozone/common/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-ozone/common/pom.xml b/hadoop-ozone/common/pom.xml
index 83d023e..ea5eb46 100644
--- a/hadoop-ozone/common/pom.xml
+++ b/hadoop-ozone/common/pom.xml
@@ -29,8 +29,11 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
<packaging>jar</packaging>
<properties>
+ <ozone.version>0.2.1-SNAPSHOT</ozone.version>
+ <ozone.release>Acadia</ozone.release>
<hadoop.component>ozone</hadoop.component>
<is.hadoop.component>true</is.hadoop.component>
+ <declared.ozone.version>${ozone.version}</declared.ozone.version>
</properties>
<dependencies>
@@ -38,12 +41,44 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
</dependencies>
<build>
+ <resources>
+ <resource>
+ <directory>${basedir}/src/main/resources</directory>
+ <excludes>
+ <exclude>ozone-version-info.properties</exclude>
+ </excludes>
+ <filtering>false</filtering>
+ </resource>
+ <resource>
+ <directory>${basedir}/src/main/resources</directory>
+ <includes>
+ <include>ozone-version-info.properties</include>
+ </includes>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
<plugins>
<plugin>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-maven-plugins</artifactId>
<executions>
<execution>
+ <id>version-info</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>version-info</goal>
+ </goals>
+ <configuration>
+ <source>
+ <directory>${basedir}/../</directory>
+ <includes>
+ <include>*/src/main/java/**/*.java</include>
+ <include>*/src/main/proto/*.proto</include>
+ </includes>
+ </source>
+ </configuration>
+ </execution>
+ <execution>
<id>compile-protoc</id>
<goals>
<goal>protoc</goal>
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3d96bc6e/hadoop-ozone/common/src/main/bin/ozone
----------------------------------------------------------------------
diff --git a/hadoop-ozone/common/src/main/bin/ozone b/hadoop-ozone/common/src/main/bin/ozone
index 5d1b6bc..75ceeb7 100755
--- a/hadoop-ozone/common/src/main/bin/ozone
+++ b/hadoop-ozone/common/src/main/bin/ozone
@@ -117,7 +117,7 @@ function ozonecmd_case
HADOOP_CLASSNAME=org.apache.hadoop.ozone.scm.cli.SCMCLI
;;
version)
- HADOOP_CLASSNAME=org.apache.hadoop.util.VersionInfo
+ HADOOP_CLASSNAME=org.apache.hadoop.ozone.util.OzoneVersionInfo
;;
genconf)
HADOOP_CLASSNAME=org.apache.hadoop.ozone.genconf.GenerateOzoneRequiredConfigurations
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3d96bc6e/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/util/OzoneVersionInfo.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/util/OzoneVersionInfo.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/util/OzoneVersionInfo.java
new file mode 100644
index 0000000..d476748
--- /dev/null
+++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/util/OzoneVersionInfo.java
@@ -0,0 +1,213 @@
+/*
+ * 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.ozone.util;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+import org.apache.hadoop.io.IOUtils;
+import org.apache.hadoop.util.ClassUtil;
+import org.apache.hadoop.util.ThreadUtil;
+import org.apache.hadoop.utils.HddsVersionInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * This class returns build information about Hadoop components.
+ */
+@InterfaceAudience.Public
+@InterfaceStability.Stable
+public class OzoneVersionInfo {
+ private static final Logger LOG = LoggerFactory.getLogger(OzoneVersionInfo.class);
+
+ private Properties info;
+
+ protected OzoneVersionInfo(String component) {
+ info = new Properties();
+ String versionInfoFile = component + "-version-info.properties";
+ InputStream is = null;
+ try {
+ is = ThreadUtil.getResourceAsStream(OzoneVersionInfo.class.getClassLoader(),
+ versionInfoFile);
+ info.load(is);
+ } catch (IOException ex) {
+ LoggerFactory.getLogger(getClass()).warn("Could not read '" +
+ versionInfoFile + "', " + ex.toString(), ex);
+ } finally {
+ IOUtils.closeStream(is);
+ }
+ }
+
+ protected String _getVersion() {
+ return info.getProperty("version", "Unknown");
+ }
+
+ protected String _getRelease() {
+ return info.getProperty("release", "Unknown");
+ }
+
+ protected String _getRevision() {
+ return info.getProperty("revision", "Unknown");
+ }
+
+ protected String _getBranch() {
+ return info.getProperty("branch", "Unknown");
+ }
+
+ protected String _getDate() {
+ return info.getProperty("date", "Unknown");
+ }
+
+ protected String _getUser() {
+ return info.getProperty("user", "Unknown");
+ }
+
+ protected String _getUrl() {
+ return info.getProperty("url", "Unknown");
+ }
+
+ protected String _getSrcChecksum() {
+ return info.getProperty("srcChecksum", "Unknown");
+ }
+
+ protected String _getBuildVersion(){
+ return _getVersion() +
+ " from " + _getRevision() +
+ " by " + _getUser() +
+ " source checksum " + _getSrcChecksum();
+ }
+
+ protected String _getProtocVersion() {
+ return info.getProperty("protocVersion", "Unknown");
+ }
+
+ private static OzoneVersionInfo OZONE_VERSION_INFO = new OzoneVersionInfo("ozone");
+ /**
+ * Get the Ozone version.
+ * @return the Ozone version string, eg. "0.6.3-dev"
+ */
+ public static String getVersion() {
+ return OZONE_VERSION_INFO._getVersion();
+ }
+
+ /**
+ * Get the Ozone release name.
+ * @return the Ozone release string, eg. "Acadia"
+ */
+ public static String getRelease() {
+ return OZONE_VERSION_INFO._getRelease();
+ }
+
+ /**
+ * Get the Git commit hash of the repository when compiled.
+ * @return the commit hash, eg. "18f64065d5db6208daf50b02c1b5ed4ee3ce547a"
+ */
+ public static String getRevision() {
+ return OZONE_VERSION_INFO._getRevision();
+ }
+
+ /**
+ * Get the branch on which this originated.
+ * @return The branch name, e.g. "trunk" or "branches/branch-0.20"
+ */
+ public static String getBranch() {
+ return OZONE_VERSION_INFO._getBranch();
+ }
+
+ /**
+ * The date that Ozone was compiled.
+ * @return the compilation date in unix date format
+ */
+ public static String getDate() {
+ return OZONE_VERSION_INFO._getDate();
+ }
+
+ /**
+ * The user that compiled Ozone.
+ * @return the username of the user
+ */
+ public static String getUser() {
+ return OZONE_VERSION_INFO._getUser();
+ }
+
+ /**
+ * Get the URL for the Ozone repository.
+ * @return the URL of the Ozone repository
+ */
+ public static String getUrl() {
+ return OZONE_VERSION_INFO._getUrl();
+ }
+
+ /**
+ * Get the checksum of the source files from which Ozone was built.
+ * @return the checksum of the source files
+ */
+ public static String getSrcChecksum() {
+ return OZONE_VERSION_INFO._getSrcChecksum();
+ }
+
+ /**
+ * Returns the buildVersion which includes version,
+ * revision, user and date.
+ * @return the buildVersion
+ */
+ public static String getBuildVersion(){
+ return OZONE_VERSION_INFO._getBuildVersion();
+ }
+
+ /**
+ * Returns the protoc version used for the build.
+ * @return the protoc version
+ */
+ public static String getProtocVersion(){
+ return OZONE_VERSION_INFO._getProtocVersion();
+ }
+
+ public static void main(String[] args) {
+ System.out.println(
+ " ////////////// \n" +
+ " //////////////////// \n" +
+ " //////// //////////////// \n" +
+ " ////// //////////////// \n" +
+ " ///// //////////////// / \n" +
+ " ///// //////// /// \n" +
+ " //// //////// ///// \n" +
+ " ///// //////////////// \n" +
+ " ///// //////////////// // \n" +
+ " //// /////////////// ///// \n" +
+ " ///// /////////////// //// \n" +
+ " ///// ////// ///// \n" +
+ " ////// ////// ///// \n" +
+ " /////////// //////// \n" +
+ " ////// //////////// \n" +
+ " /// ////////// \n" +
+ " / "+ getVersion() + "("+ getRelease() +")\n");
+ System.out.println("Source code repository " + getUrl() + " -r " +
+ getRevision());
+ System.out.println("Compiled by " + getUser() + " on " + getDate());
+ System.out.println("Compiled with protoc " + getProtocVersion());
+ System.out.println("From source with checksum " + getSrcChecksum() + "\n");
+ LOG.debug("This command was run using " +
+ ClassUtil.findContainingJar(OzoneVersionInfo.class));
+ HddsVersionInfo.main(args);
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3d96bc6e/hadoop-ozone/common/src/main/resources/ozone-version-info.properties
----------------------------------------------------------------------
diff --git a/hadoop-ozone/common/src/main/resources/ozone-version-info.properties b/hadoop-ozone/common/src/main/resources/ozone-version-info.properties
new file mode 100644
index 0000000..599f14d
--- /dev/null
+++ b/hadoop-ozone/common/src/main/resources/ozone-version-info.properties
@@ -0,0 +1,27 @@
+#
+# 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.
+#
+
+version=${declared.ozone.version}
+release=${ozone.release}
+revision=${version-info.scm.commit}
+branch=${version-info.scm.branch}
+user=${user.name}
+date=${version-info.build.time}
+url=${version-info.scm.uri}
+srcChecksum=${version-info.source.md5}
+protocVersion=${protobuf.version}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org