Skip to content

Commit

Permalink
Added Version and Revision of Stratosphere in Webinterface
Browse files Browse the repository at this point in the history
https://issues.apache.org/jira/browse/FLINK-946

![bildschirmfoto 2014-06-20 um 14 43 26](https://cloud.githubusercontent.com/assets/5738978/3340103/82d0485e-f878-11e3-9d15-617102ea40a3.png)

Author: Jonathan <[email protected]>

Closes apache#30 from JonathanH5/wi_version and squashes the following commits:

f29180a [Jonathan] Added Version and Revision of Stratosphere in Webinterface
  • Loading branch information
MoeweX authored and rmetzger committed Jun 20, 2014
1 parent cd665b9 commit 191dd1d
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 19 deletions.
22 changes: 19 additions & 3 deletions stratosphere-runtime/resources/web-docs-infoserver/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,22 @@
<script type="text/javascript" src="js/jquery.flot.min.js"></script>
<script type="text/javascript" src="js/helpers.js"></script>
<script type="text/javascript" src="js/jobmanagerFrontend.js"></script>
<script type="text/javascript" src="js/jcanvas.min.js"></script>
<script type="text/javascript" src="js/jcanvas.min.js"></script>

<!-- Insert Version -->
<script type="text/javascript">
$(document).ready(function() {
$.ajax({ url : "jobsInfo?get=version", type : "GET", cache: false, success : function(json) {
$("#version").empty();
if (json.version.indexOf("SNAPSHOT") > -1) {
$("#version").append(" " + json.version + " - " + json.revision);
} else {
$("#version").append(" " + json.version);
}
}, dataType : "json",
});
});
</script>
</head>

<body>
Expand Down Expand Up @@ -68,7 +83,7 @@

<div class="row">
<div class="col-lg-12">
<h1>Dashboard <small>Statistics Overview</small></h1>
<h1>Dashboard Stratosphere<small id="version"></small></h1>
<ol class="breadcrumb">
<li class="active"><i class="fa fa-dashboard"></i> Dashboard</li>
</ol>
Expand Down Expand Up @@ -155,5 +170,6 @@ <h3 class="panel-title"><i class="fa fa-play"></i> Running Jobs</h3>
</div><!-- /#page-wrapper -->

</div><!-- /#wrapper -->
</body>
</body>

</html>
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
Expand Down Expand Up @@ -304,20 +302,7 @@ public void shutdown() {
* Log Stratosphere version information.
*/
private static void logVersionInformation() {
String version = JobManager.class.getPackage().getImplementationVersion();
// if version == null, then the JobManager runs from inside the IDE (or somehow not from the maven build jar)
String revision = "<unknown>";
try {
Properties properties = new Properties();
InputStream propFile = JobManager.class.getClassLoader().getResourceAsStream(".version.properties");
if (propFile != null) {
properties.load(propFile);
revision = properties.getProperty("git.commit.id.abbrev");
}
} catch (IOException e) {
LOG.info("Cannot determine code revision. Unable ro read version property file.");
}
LOG.info("Starting Stratosphere JobManager (Version: " + version + ", Rev:" + revision + ")");
LOG.info("Starting Stratosphere JobManager (Version: " + JobManagerUtils.getVersion() + ", Rev:" + JobManagerUtils.getRevision() + ")");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@

package eu.stratosphere.nephele.jobmanager;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Properties;

import eu.stratosphere.nephele.ExecutionMode;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

Expand Down Expand Up @@ -183,4 +187,33 @@ static String getInstanceManagerClassName(ExecutionMode executionMode) {
// final String instanceManagerClassNameKey = "jobmanager.instancemanager." + modeClass + ".classname";
// return GlobalConfiguration.getString(instanceManagerClassNameKey, null);
}

/**
* Returns the version of Stratosphere as String.
* If version == null, then the JobManager runs from inside the IDE (or somehow not from the maven build jar)
* @return String
*/
public static String getVersion() {
String version = JobManagerUtils.class.getPackage().getImplementationVersion();
return version;
}

/**
* Returns the revision of Stratosphere as String.
* @return String
*/
public static String getRevision() {
String revision = "<unknown>";
try {
Properties properties = new Properties();
InputStream propFile = JobManagerUtils.class.getClassLoader().getResourceAsStream(".version.properties");
if (propFile != null) {
properties.load(propFile);
revision = properties.getProperty("git.commit.id.abbrev");
}
} catch (IOException e) {
LOG.info("Cannot determine code revision. Unable ro read version property file.");
}
return revision;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import eu.stratosphere.nephele.jobgraph.JobID;
import eu.stratosphere.nephele.jobgraph.JobStatus;
import eu.stratosphere.nephele.jobmanager.JobManager;
import eu.stratosphere.nephele.jobmanager.JobManagerUtils;
import eu.stratosphere.nephele.managementgraph.ManagementGraph;
import eu.stratosphere.nephele.managementgraph.ManagementGraphIterator;
import eu.stratosphere.nephele.managementgraph.ManagementGroupVertex;
Expand Down Expand Up @@ -96,6 +97,8 @@ else if("cancel".equals(req.getParameter("get"))) {
else if("updates".equals(req.getParameter("get"))) {
String jobId = req.getParameter("job");
writeJsonUpdatesForJob(resp.getWriter(), JobID.fromHexString(jobId));
} else if ("version".equals(req.getParameter("get"))) {
writeJsonForVersion(resp.getWriter());
}
else{
writeJsonForJobs(resp.getWriter(), jobmanager.getRecentJobs());
Expand Down Expand Up @@ -505,4 +508,16 @@ private void writeJsonForArchivedJobGroupvertex(PrintWriter wrt, RecentJobEvent
}

}

/**
* Writes the version and the revision of Stratosphere.
*
* @param wrt
*/
private void writeJsonForVersion(PrintWriter wrt) {
wrt.write("{");
wrt.write("\"version\": \"" + JobManagerUtils.getVersion() + "\",");
wrt.write("\"revision\": \"" + JobManagerUtils.getRevision() + "\"");
wrt.write("}");
}
}

0 comments on commit 191dd1d

Please sign in to comment.