felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1143664 - in /felix/trunk/webconsole/src/main: java/org/apache/felix/webconsole/internal/system/ native2ascii/OSGI-INF/l10n/ resources/OSGI-INF/l10n/ resources/res/ui/ resources/templates/
Date Thu, 07 Jul 2011 06:21:47 GMT
Author: fmeschbe
Date: Thu Jul  7 06:21:46 2011
New Revision: 1143664

URL: http://svn.apache.org/viewvc?rev=1143664&view=rev
Log:
FERLIX-3022 Add uptime information in addition to the start time.

Modified:
    felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/system/VMStatPlugin.java
    felix/trunk/webconsole/src/main/native2ascii/OSGI-INF/l10n/bundle_de.properties
    felix/trunk/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties
    felix/trunk/webconsole/src/main/resources/res/ui/vmstat.js
    felix/trunk/webconsole/src/main/resources/templates/vmstat.html

Modified: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/system/VMStatPlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/system/VMStatPlugin.java?rev=1143664&r1=1143663&r2=1143664&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/system/VMStatPlugin.java
(original)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/system/VMStatPlugin.java
Thu Jul  7 06:21:46 2011
@@ -20,6 +20,8 @@ package org.apache.felix.webconsole.inte
 
 
 import java.io.IOException;
+import java.text.DateFormat;
+import java.text.MessageFormat;
 import java.util.Date;
 
 import javax.servlet.ServletException;
@@ -55,7 +57,7 @@ public class VMStatPlugin extends Simple
     private static final String PARAM_SHUTDOWN_TYPE_RESTART = "Restart";
     //private static final String PARAM_SHUTDOWN_TYPE_STOP = "Stop";
 
-    private static final long startDate = ( new Date() ).getTime();
+    private static final long startDate = System.currentTimeMillis();
 
     // from BaseWebConsolePlugin
     private static String START_LEVEL_NAME = StartLevel.class.getName();
@@ -195,12 +197,17 @@ public class VMStatPlugin extends Simple
         if ( shutdownType == null )
             shutdownType = "";
 
+        DateFormat format = DateFormat.getDateTimeInstance( DateFormat.LONG, DateFormat.LONG,
request.getLocale() );
+        final String startTime = format.format( new Date( startDate ) );
+        final String upTime = formatPeriod( System.currentTimeMillis() - startDate );
+
         JSONObject json = new JSONObject();
         try
         {
             json.put( "systemStartLevel", getStartLevel().getStartLevel() );
             json.put( "bundleStartLevel", getStartLevel().getInitialBundleStartLevel() );
-            json.put( "lastStarted", startDate );
+            json.put( "lastStarted", startTime );
+            json.put( "upTime", upTime );
             json.put( "runtime", System.getProperty( "java.runtime.name" ) + "(build "
                 + System.getProperty( "java.runtime.version" ) + ")" );
             json.put( "jvm", System.getProperty( "java.vm.name" ) + "(build " + System.getProperty(
"java.vm.version" )
@@ -230,6 +237,20 @@ public class VMStatPlugin extends Simple
     }
 
 
+    private String formatPeriod( final long period )
+    {
+        final Long msecs = new Long( period % 1000 );
+        final Long secs = new Long( period / 1000 % 60 );
+        final Long mins = new Long( period / 1000 / 60 % 60 );
+        final Long hours = new Long( period / 1000 / 60 / 60 % 24 );
+        final Long days = new Long( period / 1000 / 60 / 60 / 24 );
+        return MessageFormat.format(
+            "{0,number} '${vmstat.upTime.format.days}' {1,number,00}:{2,number,00}:{3,number,00}.{4,number,000}",
+            new Object[]
+                { days, hours, mins, secs, msecs } );
+    }
+
+
     private final StartLevel getStartLevel()
     {
         return ( StartLevel ) getService( START_LEVEL_NAME );

Modified: felix/trunk/webconsole/src/main/native2ascii/OSGI-INF/l10n/bundle_de.properties
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/native2ascii/OSGI-INF/l10n/bundle_de.properties?rev=1143664&r1=1143663&r2=1143664&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/native2ascii/OSGI-INF/l10n/bundle_de.properties [UTF-8]
(original)
+++ felix/trunk/webconsole/src/main/native2ascii/OSGI-INF/l10n/bundle_de.properties [UTF-8]
Thu Jul  7 06:21:46 2011
@@ -56,6 +56,8 @@ vmstat.sl.system=System Start Level
 vmstat.sl.bundle=Default Bundle Start Level
 vmstat.info.title=Server Information:
 vmstat.lastStarted=Letzter Start
+vmstat.upTime=Betriebszeit
+vmstat.upTime.format.days=Tage
 vmstat.framework=Framework
 vmstat.shutdown.in=Stoppe in 
 vmstat.java.title=Java Information:

Modified: felix/trunk/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties?rev=1143664&r1=1143663&r2=1143664&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties (original)
+++ felix/trunk/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties Thu Jul  7 06:21:46
2011
@@ -57,6 +57,8 @@ vmstat.sl.system=System Start Level
 vmstat.sl.bundle=Default Bundle Start Level
 vmstat.info.title=Server Information:
 vmstat.lastStarted=Last Started
+vmstat.upTime=Uptime
+vmstat.upTime.format.days=days
 vmstat.framework=Framework
 vmstat.shutdown.in=Shutdown in 
 vmstat.java.title=Java Information:

Modified: felix/trunk/webconsole/src/main/resources/res/ui/vmstat.js
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/resources/res/ui/vmstat.js?rev=1143664&r1=1143663&r2=1143664&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/resources/res/ui/vmstat.js (original)
+++ felix/trunk/webconsole/src/main/resources/res/ui/vmstat.js Thu Jul  7 06:21:46 2011
@@ -34,7 +34,6 @@ $(document).ready(function() {
 			target.text(statData[i]);
 		}
 	}
-	$('#lastStarted').text(localTm(statData.lastStarted));
 	var st = statData.shutdownTimer;
 	$('#shutdownform').css('display', st ? 'none' : 'block');
 	$('#shutdownform2').css('display', st ? 'block' : 'none');

Modified: felix/trunk/webconsole/src/main/resources/templates/vmstat.html
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/resources/templates/vmstat.html?rev=1143664&r1=1143663&r2=1143664&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/resources/templates/vmstat.html [UTF-8] (original)
+++ felix/trunk/webconsole/src/main/resources/templates/vmstat.html [UTF-8] Thu Jul  7 06:21:46
2011
@@ -49,6 +49,10 @@ var statData = ${startData};
 		<td id="lastStarted">---</td>
 	</tr>
 	<tr>
+		<td>${vmstat.upTime}</td>
+		<td id="upTime">---</td>
+	</tr>
+	<tr>
 		<td>${vmstat.framework}</td>
 		<td>
 			<form id="shutdownform" method="post" action="${pluginRoot}">



Mime
View raw message