[ZEPPELIN-715]Provide version information

This commit is contained in:
Minwoo Kang 2016-03-23 10:29:15 +09:00
parent d19575715e
commit f5b2e66e8b
11 changed files with 112 additions and 3 deletions

View file

@ -49,6 +49,12 @@ fi
. "${bin}/common.sh"
ZEPPELIN_COMMANDLINE_MAIN=org.apache.zeppelin.utils.CommandLineUtils
if [ "$1" == "-version" ] || [ "$1" == "-v" ]; then
$ZEPPELIN_RUNNER $ZEPPELIN_COMMANDLINE_MAIN $1
exit 0
fi
ZEPPELIN_CLASSPATH+=":${ZEPPELIN_CONF_DIR}"
# construct classpath

View file

@ -19,7 +19,7 @@
# description: Start and stop daemon script for.
#
USAGE="Usage: zeppelin-daemon.sh [--config <conf-dir>] {start|stop|upstart|restart|reload|status}"
USAGE="Usage: zeppelin-daemon.sh [--config <conf-dir>] {start|stop|upstart|restart|reload|status|version(v)}"
if [[ "$1" == "--config" ]]; then
shift
@ -44,6 +44,12 @@ BIN=$(cd "${BIN}">/dev/null; pwd)
. "${BIN}/common.sh"
. "${BIN}/functions.sh"
ZEPPELIN_COMMANDLINE_MAIN=org.apache.zeppelin.utils.CommandLineUtils
if [ "$1" == "-version" ] || [ "$1" == "-v" ]; then
$ZEPPELIN_RUNNER $ZEPPELIN_COMMANDLINE_MAIN $1
exit 0
fi
HOSTNAME=$(hostname)
ZEPPELIN_NAME="Zeppelin"
ZEPPELIN_LOGFILE="${ZEPPELIN_LOG_DIR}/zeppelin-${ZEPPELIN_IDENT_STRING}-${HOSTNAME}.log"

View file

@ -39,6 +39,12 @@ bin=$(cd "${bin}">/dev/null; pwd)
. "${bin}/common.sh"
ZEPPELIN_COMMANDLINE_MAIN=org.apache.zeppelin.utils.CommandLineUtils
if [ "$1" == "-version" ] || [ "$1" == "-v" ]; then
$ZEPPELIN_RUNNER $ZEPPELIN_COMMANDLINE_MAIN $1
exit 0
fi
HOSTNAME=$(hostname)
ZEPPELIN_LOGFILE="${ZEPPELIN_LOG_DIR}/zeppelin-${ZEPPELIN_IDENT_STRING}-${HOSTNAME}.log"
LOG="${ZEPPELIN_LOG_DIR}/zeppelin-cli-${ZEPPELIN_IDENT_STRING}-${HOSTNAME}.out"

View file

@ -17,6 +17,9 @@
package org.apache.zeppelin.rest;
import org.apache.zeppelin.server.JsonResponse;
import org.apache.zeppelin.util.Util;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
@ -41,4 +44,10 @@ public class ZeppelinRestApi {
public Response getRoot() {
return Response.ok().build();
}
@GET
@Path("version")
public Response getVersion() {
return new JsonResponse<>(Response.Status.OK, "Zeppelin version", Util.getVersion()).build();
}
}

View file

@ -0,0 +1,26 @@
package org.apache.zeppelin.utils;
import org.apache.zeppelin.util.Util;
import java.util.Locale;
/**
* CommandLine Support Class
*/
public class CommandLineUtils {
public static void main(String[] args) {
if (args.length == 0) {
return;
}
String usage = args[0].toLowerCase(Locale.US);
switch (usage) {
case "-version":
case "-v":
System.out.println(Util.getVersion());
break;
default:
}
}
}

View file

@ -13,7 +13,7 @@
*/
'use strict';
angular.module('zeppelinWebApp').controller('HomeCtrl', function($scope, notebookListDataFactory, websocketMsgSrv, $rootScope, arrayOrderingSrv) {
angular.module('zeppelinWebApp').controller('HomeCtrl', function($scope, notebookListDataFactory, websocketMsgSrv, $rootScope, arrayOrderingSrv, $http, baseUrlSrv) {
var vm = this;
vm.notes = notebookListDataFactory;
vm.websocketMsgSrv = websocketMsgSrv;
@ -23,9 +23,20 @@ angular.module('zeppelinWebApp').controller('HomeCtrl', function($scope, noteboo
vm.staticHome = false;
$scope.isReloading = false;
var getZeppelinVersion = function() {
$http.get(baseUrlSrv.getRestApiBase() +'/version').
success(function (data, status, headers, config) {
$scope.zeppelinVersion = data.body;
}).
error(function(data, status, headers, config) {
console.log('Error %o %o', status, data.message);
});
};
var initHome = function() {
websocketMsgSrv.getHomeNotebook();
getZeppelinVersion();
};
initHome();

View file

@ -19,7 +19,7 @@ limitations under the License.
</div>
<div style="margin-top: -380px;">
<h1 class="box-heading" id="welcome">
Welcome to Zeppelin!
Welcome to Zeppelin! <small>({{zeppelinVersion}})</small>
</h1>
Zeppelin is web-based notebook that enables interactive data analytics.<br>
You can make beautiful data-driven, interactive, collaborative document with SQL, code and even more!<br>

View file

@ -222,4 +222,13 @@
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
</project>

View file

@ -17,14 +17,33 @@
package org.apache.zeppelin.util;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
/**
* TODO(moon) : add description.
*/
public class Util {
private static final String PROJECT_PROPERTIES_VERSION_KEY = "version";
static Logger logger = LoggerFactory.getLogger(Util.class);
private static Properties projectProperties;
static {
projectProperties = new Properties();
try {
projectProperties.load(Util.class.getResourceAsStream("/project.properties"));
} catch (IOException e) {
logger.error("Fail to read project.properties");
}
}
public static String[] split(String str, char split) {
return split(str, new String[] {String.valueOf(split)}, false);
@ -181,4 +200,13 @@ public class Util {
return false;
}
}
/**
* Get Zeppelin version
*
* @return Current Zeppelin version
*/
public static String getVersion() {
return StringUtils.defaultIfEmpty(projectProperties.getProperty(PROJECT_PROPERTIES_VERSION_KEY), StringUtils.EMPTY);
}
}

View file

@ -0,0 +1,2 @@
version=${project.version}
artifactId=${project.artifactId}

View file

@ -97,4 +97,10 @@ public class UtilTest extends TestCase {
assertEquals("array <STRUCT<STRING>> tags", t[0]);
assertEquals("aa", t[2]);
}
public void testGetVersion(){
String version = Util.getVersion();
assertNotNull(version);
System.out.println(version);
}
}