activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject activemq git commit: [AMQ-5505]. Add getUptimeMillis to the BrokerView MBean. This closes #56
Date Mon, 05 Jan 2015 18:23:26 GMT
Repository: activemq
Updated Branches:
  refs/heads/trunk aedcae139 -> 8e0865d5d


[AMQ-5505]. Add getUptimeMillis to the BrokerView MBean. This closes #56


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/8e0865d5
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/8e0865d5
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/8e0865d5

Branch: refs/heads/trunk
Commit: 8e0865d5d115774f2cabd79e3378b9c3730567d3
Parents: aedcae1
Author: Hadrian Zbarcea <hadrian@apache.org>
Authored: Mon Jan 5 13:23:19 2015 -0500
Committer: Hadrian Zbarcea <hadrian@apache.org>
Committed: Mon Jan 5 13:23:19 2015 -0500

----------------------------------------------------------------------
 .../org/apache/activemq/broker/BrokerService.java    | 15 ++++++++++++---
 .../org/apache/activemq/broker/jmx/BrokerView.java   |  5 +++++
 .../apache/activemq/broker/jmx/BrokerViewMBean.java  |  6 ++++++
 3 files changed, 23 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/8e0865d5/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java b/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java
index 3af7075..270aeb5 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java
@@ -489,14 +489,23 @@ public class BrokerService implements Service {
     }
 
     public String getUptime() {
-        // compute and log uptime
-        if (startDate == null) {
+        long delta = getUptimeMillis();
+
+        if (delta == 0) {
             return "not started";
         }
-        long delta = new Date().getTime() - startDate.getTime();
+
         return TimeUtils.printDuration(delta);
     }
 
+    public long getUptimeMillis() {
+        if (startDate == null) {
+            return 0;
+        }
+
+        return new Date().getTime() - startDate.getTime();
+    }
+
     public boolean isStarted() {
         return started.get() && startedLatch.getCount() == 0;
     }

http://git-wip-us.apache.org/repos/asf/activemq/blob/8e0865d5/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
index 3a9d10b..350992c 100755
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
@@ -85,6 +85,11 @@ public class BrokerView implements BrokerViewMBean {
     }
 
     @Override
+    public long getUptimeMillis() {
+        return brokerService.getUptimeMillis();
+    }
+
+    @Override
     public int getCurrentConnectionsCount() {
         return brokerService.getCurrentConnections();
     }

http://git-wip-us.apache.org/repos/asf/activemq/blob/8e0865d5/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/BrokerViewMBean.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/BrokerViewMBean.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/BrokerViewMBean.java
index bfdb3cb..d88bb0c 100755
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/BrokerViewMBean.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/BrokerViewMBean.java
@@ -54,6 +54,12 @@ public interface BrokerViewMBean extends Service {
     String getUptime();
 
     /**
+     * @return Uptime of the broker in milliseconds.
+     */
+    @MBeanInfo("Uptime of the broker in milliseconds.")
+    long getUptimeMillis();
+
+    /**
      * @return The current number of active connections on this Broker.
      */
     int getCurrentConnectionsCount();


Mime
View raw message