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

This commit is contained in:
Hadrian Zbarcea 2015-01-05 13:23:19 -05:00
parent aedcae139b
commit 8e0865d5d1
3 changed files with 23 additions and 3 deletions

View File

@ -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;
}

View File

@ -84,6 +84,11 @@ public class BrokerView implements BrokerViewMBean {
return brokerService.getUptime();
}
@Override
public long getUptimeMillis() {
return brokerService.getUptimeMillis();
}
@Override
public int getCurrentConnectionsCount() {
return brokerService.getCurrentConnections();

View File

@ -53,6 +53,12 @@ public interface BrokerViewMBean extends Service {
@MBeanInfo("Uptime of the broker.")
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.
*/