mirror of https://github.com/apache/activemq.git
[AMQ-5505]. Add getUptimeMillis to the BrokerView MBean. This closes #56
This commit is contained in:
parent
aedcae139b
commit
8e0865d5d1
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue