mirror of https://github.com/apache/activemq.git
[AMQ-9315] Add connectedTimestamp to Connection and JMX view
This commit is contained in:
parent
538b04aa0c
commit
578d86d726
|
@ -121,7 +121,6 @@ public interface Connection extends Service {
|
||||||
|
|
||||||
void updateClient(ConnectionControl control);
|
void updateClient(ConnectionControl control);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of active transactions established on this Connection.
|
* Returns the number of active transactions established on this Connection.
|
||||||
*
|
*
|
||||||
|
@ -136,4 +135,10 @@ public interface Connection extends Service {
|
||||||
*/
|
*/
|
||||||
public Long getOldestActiveTransactionDuration();
|
public Long getOldestActiveTransactionDuration();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the time in ms since epoch when connection was established.
|
||||||
|
*
|
||||||
|
* @return time in ms since epoch when connection was established.
|
||||||
|
*/
|
||||||
|
public Long getConnectedTimestamp();
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,6 +161,7 @@ public class TransportConnection implements Connection, Task, CommandVisitor {
|
||||||
private TransportConnectionStateRegister connectionStateRegister = new SingleTransportConnectionStateRegister();
|
private TransportConnectionStateRegister connectionStateRegister = new SingleTransportConnectionStateRegister();
|
||||||
private final ReentrantReadWriteLock serviceLock = new ReentrantReadWriteLock();
|
private final ReentrantReadWriteLock serviceLock = new ReentrantReadWriteLock();
|
||||||
private String duplexNetworkConnectorId;
|
private String duplexNetworkConnectorId;
|
||||||
|
private final long connectedTimestamp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param taskRunnerFactory - can be null if you want direct dispatch to the transport
|
* @param taskRunnerFactory - can be null if you want direct dispatch to the transport
|
||||||
|
@ -218,6 +219,7 @@ public class TransportConnection implements Connection, Task, CommandVisitor {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connected = true;
|
connected = true;
|
||||||
|
connectedTimestamp = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1724,4 +1726,9 @@ public class TransportConnection implements Connection, Task, CommandVisitor {
|
||||||
public Response processBrokerSubscriptionInfo(BrokerSubscriptionInfo info) throws Exception {
|
public Response processBrokerSubscriptionInfo(BrokerSubscriptionInfo info) throws Exception {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getConnectedTimestamp() {
|
||||||
|
return this.connectedTimestamp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,4 +191,9 @@ public class ConnectionView implements ConnectionViewMBean {
|
||||||
public boolean isNetworkConnection() {
|
public boolean isNetworkConnection() {
|
||||||
return connection.isNetworkConnection();
|
return connection.isNetworkConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getConnectedTimestamp() {
|
||||||
|
return connection.getConnectedTimestamp();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,4 +133,10 @@ public interface ConnectionViewMBean extends Service {
|
||||||
*/
|
*/
|
||||||
@MBeanInfo("Connection is a network connection.")
|
@MBeanInfo("Connection is a network connection.")
|
||||||
boolean isNetworkConnection();
|
boolean isNetworkConnection();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the time in ms since epoch when connection was established
|
||||||
|
*/
|
||||||
|
@MBeanInfo("Time in ms since epoch when connection was established.")
|
||||||
|
long getConnectedTimestamp();
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,9 @@ public class SchedulerBroker extends BrokerFilter implements JobListener {
|
||||||
this.context.setSecurityContext(SecurityContext.BROKER_SECURITY_CONTEXT);
|
this.context.setSecurityContext(SecurityContext.BROKER_SECURITY_CONTEXT);
|
||||||
// we only get response on unexpected error
|
// we only get response on unexpected error
|
||||||
this.context.setConnection(new Connection() {
|
this.context.setConnection(new Connection() {
|
||||||
|
|
||||||
|
private final long connectedTimestamp = System.currentTimeMillis();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Connector getConnector() {
|
public Connector getConnector() {
|
||||||
return null;
|
return null;
|
||||||
|
@ -183,6 +186,12 @@ public class SchedulerBroker extends BrokerFilter implements JobListener {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getConnectedTimestamp() {
|
||||||
|
return connectedTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start() throws Exception {}
|
public void start() throws Exception {}
|
||||||
|
|
||||||
|
|
|
@ -218,6 +218,9 @@ public class DefaultAuthenticationPolicyTest {
|
||||||
|
|
||||||
ConnectionContext ctx = new ConnectionContext();
|
ConnectionContext ctx = new ConnectionContext();
|
||||||
Connection connection = new Connection() {
|
Connection connection = new Connection() {
|
||||||
|
|
||||||
|
private final long connectedTimestamp = System.currentTimeMillis();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Connector getConnector() {
|
public Connector getConnector() {
|
||||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
@ -327,6 +330,12 @@ public class DefaultAuthenticationPolicyTest {
|
||||||
public Long getOldestActiveTransactionDuration() {
|
public Long getOldestActiveTransactionDuration() {
|
||||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getConnectedTimestamp() {
|
||||||
|
return connectedTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ctx.setConnection(connection);
|
ctx.setConnection(connection);
|
||||||
|
|
|
@ -104,6 +104,8 @@ public class QueueOptimizedDispatchExceptionTest {
|
||||||
final ConnectionContext contextNotInTx = new ConnectionContext();
|
final ConnectionContext contextNotInTx = new ConnectionContext();
|
||||||
contextNotInTx.setConnection(new Connection() {
|
contextNotInTx.setConnection(new Connection() {
|
||||||
|
|
||||||
|
private final long connectedTimestamp = System.currentTimeMillis();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop() throws Exception {
|
public void stop() throws Exception {
|
||||||
}
|
}
|
||||||
|
@ -207,6 +209,11 @@ public class QueueOptimizedDispatchExceptionTest {
|
||||||
public Long getOldestActiveTransactionDuration() {
|
public Long getOldestActiveTransactionDuration() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getConnectedTimestamp() {
|
||||||
|
return connectedTimestamp;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final DestinationStatistics destinationStatistics = new DestinationStatistics();
|
final DestinationStatistics destinationStatistics = new DestinationStatistics();
|
||||||
|
|
Loading…
Reference in New Issue