You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by lh...@apache.org on 2008/10/10 11:02:09 UTC
svn commit: r703359 - /servicemix/scripts/builds/webapps/builds/status.jsp
Author: lhein
Date: Fri Oct 10 02:02:08 2008
New Revision: 703359
URL: http://svn.apache.org/viewvc?rev=703359&view=rev
Log:
performance tuning
Modified:
servicemix/scripts/builds/webapps/builds/status.jsp
Modified: servicemix/scripts/builds/webapps/builds/status.jsp
URL: http://svn.apache.org/viewvc/servicemix/scripts/builds/webapps/builds/status.jsp?rev=703359&r1=703358&r2=703359&view=diff
==============================================================================
--- servicemix/scripts/builds/webapps/builds/status.jsp (original)
+++ servicemix/scripts/builds/webapps/builds/status.jsp Fri Oct 10 02:02:08 2008
@@ -25,6 +25,12 @@
padding-left: 8px;
padding-right: 8px;
}
+ .unavailable {
+ background-color: darkgray;
+ color: white;
+ padding-left: 8px;
+ padding-right: 8px;
+ }
.success {
background-color: green;
color: white;
@@ -51,19 +57,25 @@
<hr /><br />
<%!
-
String dir = "/mnt/builds/logs/";
String failedTestsCheck = "[ERROR] There are test failures.";
+ String key_projectMap = "projects";
+ String key_timestamps = "timestamps";
+ String key_lastresults= "lastResults";
+
TreeMap prjMap = null;
+ TreeMap tsMap = null;
+ TreeMap lastResultMap = null;
- void setupProjectMap() {
- if (prjMap == null) {
+ void setupMaps() {
+ // first setup the projects map
+ if (session.getAttribute(key_projectMap) != null) {
+ prjMap = (TreeMap)session.getAttribute(key_projectMap);
+ } else {
prjMap = new TreeMap();
// now add all projects
prjMap.put("ActiveMQ trunk deploy", "activemq-deploy.log");
prjMap.put("Camel trunk deploy", "camel-deploy.log");
- prjMap.put("ServiceMix 3.2 deploy 1", "servicemix-3.2-deploy.log");
- prjMap.put("ServiceMix 3.2 deploy 2", "servicemix-3.2-deploy-2.log");
prjMap.put("ServiceMix 3.3 deploy", "smx-3.3-trunk-deploy.log");
prjMap.put("ServiceMix 4 legal deploy", "smx4-legal-deploy.log");
prjMap.put("ServiceMix 4 bundles deploy", "smx4-bundles-deploy.log");
@@ -76,7 +88,28 @@
prjMap.put("ServiceMix Maven Plugins POM", "smx-mvn-plugins-pom-deploy.log");
prjMap.put("ServiceMix Utils", "smx-utils-trunk-deploy.log");
// add more projects here
+// prjMap.put("ServiceMix 3.2 deploy 1", "servicemix-3.2-deploy.log");
+// prjMap.put("ServiceMix 3.2 deploy 2", "servicemix-3.2-deploy-2.log");
+
+ // register to session
+ session.setAttribute(key_projectMap, prjMap);
}
+
+ // then setup the timestamp map
+ if (session.getAttribute(key_timestamps) != null) {
+ tsMap = (TreeMap)session.getAttribute(key_timestamps);
+ } else {
+ tsMap = new TreeMap();
+ session.setAttribute(key_timestamps, tsMap);
+ }
+
+ // then setup the lastResult map
+ if (session.getAttribute(key_lastresults) != null) {
+ lastResultMap = (TreeMap)session.getAttribute(key_lastresults);
+ } else {
+ lastResultMap = new TreeMap();
+ session.setAttribute(key_lastresults, lastResultMap);
+ }
}
String processBuildFile(String uri) {
@@ -89,7 +122,7 @@
if (!f.exists() || !f.isFile()) {
// log file is missing
- return "<td class='error' width='60%'><a href='http://projects.open.iona.com/builds/status' class='error'>UNAVAILABLE</a></td>";
+ return "<td class='unavailable' width='60%'><a href='http://projects.open.iona.com/builds/status' class='unavailable'>UNAVAILABLE</a></td>";
}
String durationText = convertToDuration(System.currentTimeMillis() - f.lastModified());
@@ -98,6 +131,17 @@
if (f.lastModified() + 80000 >= System.currentTimeMillis()) {
return "<td class='building' width='60%'><a href='logs/" + uri + "' class='building'>BUILDING</a></td>";
}
+
+ // speed up processing of page - if no change was made to the
+ // file, then we do not need to read it again
+ if (lastResultMap != null &&
+ lastResultMap.containsKey(uri) &&
+ tsMap != null &&
+ tsMap.containsKey(uri) &&
+ f.lastModified() == ((Long)tsMap.get(uri)).longValue()) {
+ return (String)lastResultMap.get(uri);
+ }
+
reader = new BufferedReader(new FileReader(file));
while (true) {
String line = reader.readLine();
@@ -108,9 +152,13 @@
failedTests = true;
} else if (line.contains("BUILD SUCCESSFUL")) {
if (failedTests) {
- return "<td class='success_with_failed_tests' width='60%'><a href='logs/" + uri + "' class='success_with_failed_tests'>SUCCESS (with failures) " + durationText + "</a></td>";
+ String result = "<td class='success_with_failed_tests' width='60%'><a href='logs/" + uri + "' class='success_with_failed_tests'>SUCCESS (with failures) " + durationText + "</a></td>";
+ saveResult(f.lastModified(), uri, result);
+ return result;
} else {
- return "<td class='success' width='60%'><a href='logs/" + uri + "' class='success'>SUCCESS " + durationText + "</a></td>";
+ String result = "<td class='success' width='60%'><a href='logs/" + uri + "' class='success'>SUCCESS " + durationText + "</a></td>";
+ saveResult(f.lastModified(), uri, result);
+ return result;
}
}
}
@@ -127,9 +175,19 @@
}
}
}
- return "<td class='failure' width='60%'><a href='logs/" + uri + "' class='failure'>FAILURE " + durationText + "</a></td>";
+ String result = "<td class='failure' width='60%'><a href='logs/" + uri + "' class='failure'>FAILURE " + durationText + "</a></td>";
+ saveResult(f.lastModified(), uri, result);
+ return result;
+ }
+
+ void saveResult(long ts, String uri, String result) {
+ // remember the last time we accessed the file
+ tsMap.put(uri, new Long(f.lastModified()));
+ // remember the result
+ lastResultMap.put(uri, result);
}
+
String convertToDuration(long millis) {
StringBuffer buffer = new StringBuffer();
double minutes = millis / (60 * 1000);
@@ -174,7 +232,7 @@
<table width='80%' cellpadding='0' cellspacing='0'>
<%
// ensure the map is filled
- setupProjectMap();
+ setupMaps();
Iterator it = prjMap.keySet().iterator();
int cnt = 0;