You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2011/01/04 03:24:15 UTC

svn commit: r1054864 - in /activemq/activemq-apollo/trunk/apollo-web/src/main: scala/org/apache/activemq/apollo/web/resources/ webapp/WEB-INF/org/apache/activemq/apollo/dto/

Author: chirino
Date: Tue Jan  4 02:24:15 2011
New Revision: 1054864

URL: http://svn.apache.org/viewvc?rev=1054864&view=rev
Log:
Used friendlier uptime formatting.

Modified:
    activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/RootResource.scala
    activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/BrokerStatusDTO.jade
    activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/ConnectionStatusDTO.jade
    activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/ConnectorStatusDTO.jade
    activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/StompConnectionStatusDTO.jade
    activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/VirtualHostStatusDTO.jade

Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/RootResource.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/RootResource.scala?rev=1054864&r1=1054863&r2=1054864&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/RootResource.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/RootResource.scala Tue Jan  4 02:24:15 2011
@@ -73,9 +73,9 @@ object ViewHelper {
   val TB: Long = GB * 1024
 
   val SECONDS: Long = TimeUnit.SECONDS.toMillis(1)
-  val MINUTES: Long = TimeUnit.SECONDS.toMillis(60)
-  val HOURS: Long = TimeUnit.SECONDS.toMillis(3600)
-  val DAYS: Long = TimeUnit.SECONDS.toMillis(216000)
+  val MINUTES: Long = TimeUnit.MINUTES.toMillis(1)
+  val HOURS: Long = TimeUnit.HOURS.toMillis(1)
+  val DAYS: Long = TimeUnit.DAYS.toMillis(1)
   val YEARS: Long = DAYS * 365
 
 
@@ -118,20 +118,23 @@ class ViewHelper {
   }
 
   def uptime(value:Long):String = {
-    val duration = System.currentTimeMillis - value
-    if( duration < SECONDS ) {
-      "%d ms".format(duration)
-    } else if (duration < MINUTES) {
-      "%,.2f seconds".format(duration.toFloat / SECONDS)
-    } else if (duration < HOURS) {
-      "%,.2f minutes".format(duration.toFloat / MINUTES)
-    } else if (duration < DAYS) {
-      "%,.2f hours".format(duration.toFloat / HOURS)
-    } else if (duration < YEARS) {
-      "%,.2f days".format(duration.toDouble / DAYS)
-    } else {
-      "%,.2f years".format(duration.toDouble / YEARS)
+    def friendly(duration:Long):String = {
+      if( duration < SECONDS ) {
+        "%d ms".format(duration)
+      } else if (duration < MINUTES) {
+        "%d seconds".format(duration / SECONDS)
+      } else if (duration < HOURS) {
+        "%d minutes".format(duration / MINUTES)
+      } else if (duration < DAYS) {
+        println("<")
+        "%d hours %s".format(duration / HOURS, friendly(duration%HOURS))
+      } else if (duration < YEARS) {
+        "%d days %s".format(duration / DAYS, friendly(duration%DAYS))
+      } else {
+        "%,d years %s".format(duration / YEARS, friendly(duration%YEARS))
+      }
     }
+    friendly(System.currentTimeMillis - value)
   }
 }
 

Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/BrokerStatusDTO.jade
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/BrokerStatusDTO.jade?rev=1054864&r1=1054863&r2=1054864&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/BrokerStatusDTO.jade (original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/BrokerStatusDTO.jade Tue Jan  4 02:24:15 2011
@@ -21,7 +21,7 @@
   a(href={strip_resolve(".")}) Back
 
 
-p state: #{state} for #{ uptime(state_since) }
+p state: #{state} #{ uptime(state_since) } ago
 
 h2 Virtual Hosts
 ul

Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/ConnectionStatusDTO.jade
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/ConnectionStatusDTO.jade?rev=1054864&r1=1054863&r2=1054864&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/ConnectionStatusDTO.jade (original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/ConnectionStatusDTO.jade Tue Jan  4 02:24:15 2011
@@ -19,8 +19,8 @@
 
 .breadcumbs
   a(href={strip_resolve(".")}) Back
+p state: #{state} #{ uptime(state_since) } ago
 
-p state: #{state} for #{ uptime(state_since) }
 p remote address: #{remote_address}
 p protocol: #{protocol}
 p transport: #{transport}

Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/ConnectorStatusDTO.jade
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/ConnectorStatusDTO.jade?rev=1054864&r1=1054863&r2=1054864&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/ConnectorStatusDTO.jade (original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/ConnectorStatusDTO.jade Tue Jan  4 02:24:15 2011
@@ -20,7 +20,7 @@
 
 h1 Connector: #{config.id}
 
-p state: #{state} for #{ uptime(state_since) }
+p state: #{state} #{ uptime(state_since) } ago
 
 p accepted connections: #{accepted}
 

Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/StompConnectionStatusDTO.jade
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/StompConnectionStatusDTO.jade?rev=1054864&r1=1054863&r2=1054864&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/StompConnectionStatusDTO.jade (original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/StompConnectionStatusDTO.jade Tue Jan  4 02:24:15 2011
@@ -19,8 +19,8 @@
 
 .breadcumbs
   a(href={strip_resolve(".")}) Back
+p state: #{state} #{ uptime(state_since) } ago
 
-p state: #{state} for #{ uptime(state_since) }
 p remote address: #{remote_address}
 p protocol: #{protocol}
 p transport: #{transport}

Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/VirtualHostStatusDTO.jade
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/VirtualHostStatusDTO.jade?rev=1054864&r1=1054863&r2=1054864&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/VirtualHostStatusDTO.jade (original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/VirtualHostStatusDTO.jade Tue Jan  4 02:24:15 2011
@@ -22,7 +22,7 @@
 
 h1 Virtual Host: #{config.id}
 
-p state: #{state} for #{ uptime(state_since) }
+p state: #{state} #{ uptime(state_since) } ago
 
 - if ( store !=null )
   p