This is an automated email from the ASF dual-hosted git repository.

jgus pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 440445e  KAFKA-2061; Offer a --version flag to print the kafka version 
[KIP-278] (#639)
440445e is described below

commit 440445e7c58508413006d37a475d642283ef984b
Author: Sasaki Toru <sasaki...@users.noreply.github.com>
AuthorDate: Fri May 25 16:47:54 2018 +0900

    KAFKA-2061; Offer a --version flag to print the kafka version [KIP-278] 
(#639)
    
    Reviewers: Andy Lindeman, Jeremy Donahue, Jason Gustafson 
<ja...@confluent.io>
---
 bin/kafka-run-class.sh                            |  6 +++++
 core/src/main/scala/kafka/utils/VersionInfo.scala | 30 +++++++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/bin/kafka-run-class.sh b/bin/kafka-run-class.sh
index 7a0a92a..0ea8b83 100755
--- a/bin/kafka-run-class.sh
+++ b/bin/kafka-run-class.sh
@@ -238,6 +238,12 @@ if [ -z "$KAFKA_JVM_PERFORMANCE_OPTS" ]; then
   KAFKA_JVM_PERFORMANCE_OPTS="-server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 
-XX:InitiatingHeapOccupancyPercent=35 -XX:+ExplicitGCInvokesConcurrent 
-Djava.awt.headless=true"
 fi
 
+# version option
+for args in "$@" ; do
+  if [ "$args" = "--version" ]; then
+    exec $JAVA $KAFKA_HEAP_OPTS $KAFKA_JVM_PERFORMANCE_OPTS $KAFKA_GC_LOG_OPTS 
$KAFKA_JMX_OPTS $KAFKA_LOG4J_OPTS -cp $CLASSPATH $KAFKA_OPTS 
"kafka.utils.VersionInfo"
+  fi
+done
 
 while [ $# -gt 0 ]; do
   COMMAND=$1
diff --git a/core/src/main/scala/kafka/utils/VersionInfo.scala 
b/core/src/main/scala/kafka/utils/VersionInfo.scala
new file mode 100644
index 0000000..3d42d4d
--- /dev/null
+++ b/core/src/main/scala/kafka/utils/VersionInfo.scala
@@ -0,0 +1,30 @@
+/**
+ * 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 kafka.utils
+
+import org.apache.kafka.common.utils.AppInfoParser
+
+object VersionInfo {
+
+  def main(args: Array[String]) {
+    val version = AppInfoParser.getVersion
+    val commitId = AppInfoParser.getCommitId
+    System.out.println(s"${version} (Commit:${commitId})")
+    System.exit(0)
+  }
+}

-- 
To stop receiving notification emails like this one, please contact
j...@apache.org.

Reply via email to