Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ public interface Connection extends Service {

void updateClient(ConnectionControl control);


/**
* Returns the number of active transactions established on this Connection.
*
Expand All @@ -136,4 +135,10 @@ public interface Connection extends Service {
*/
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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ public class TransportConnection implements Connection, Task, CommandVisitor {
private TransportConnectionStateRegister connectionStateRegister = new SingleTransportConnectionStateRegister();
private final ReentrantReadWriteLock serviceLock = new ReentrantReadWriteLock();
private String duplexNetworkConnectorId;
private final long connectedTimestamp;

/**
* @param taskRunnerFactory - can be null if you want direct dispatch to the transport
Expand Down Expand Up @@ -218,6 +219,7 @@ public void onException(IOException exception) {
}
});
connected = true;
connectedTimestamp = System.currentTimeMillis();
}

/**
Expand Down Expand Up @@ -1724,4 +1726,9 @@ public WireFormatInfo getRemoteWireFormatInfo() {
public Response processBrokerSubscriptionInfo(BrokerSubscriptionInfo info) throws Exception {
return null;
}

@Override
public Long getConnectedTimestamp() {
return this.connectedTimestamp;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,9 @@ public boolean isManageable() {
public boolean isNetworkConnection() {
return connection.isNetworkConnection();
}

@Override
public long getConnectedTimestamp() {
return connection.getConnectedTimestamp();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,10 @@ public interface ConnectionViewMBean extends Service {
*/
@MBeanInfo("Connection is a network connection.")
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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public SchedulerBroker(BrokerService brokerService, Broker next, JobSchedulerSto
this.context.setSecurityContext(SecurityContext.BROKER_SECURITY_CONTEXT);
// we only get response on unexpected error
this.context.setConnection(new Connection() {

private final long connectedTimestamp = System.currentTimeMillis();

@Override
public Connector getConnector() {
return null;
Expand Down Expand Up @@ -183,6 +186,12 @@ public Long getOldestActiveTransactionDuration() {
return null;
}


@Override
public Long getConnectedTimestamp() {
return connectedTimestamp;
}

@Override
public void start() throws Exception {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ public void testIsAssumeIdentityWithSystemConnection() {

ConnectionContext ctx = new ConnectionContext();
Connection connection = new Connection() {

private final long connectedTimestamp = System.currentTimeMillis();

@Override
public Connector getConnector() {
return null; //To change body of implemented methods use File | Settings | File Templates.
Expand Down Expand Up @@ -327,6 +330,12 @@ public int getActiveTransactionCount() {
public Long getOldestActiveTransactionDuration() {
return null; //To change body of implemented methods use File | Settings | File Templates.
}

@Override
public Long getConnectedTimestamp() {
return connectedTimestamp;
}

};

ctx.setConnection(connection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public void TestOptimizedDispatchCME() throws Exception {
final ConnectionContext contextNotInTx = new ConnectionContext();
contextNotInTx.setConnection(new Connection() {

private final long connectedTimestamp = System.currentTimeMillis();

@Override
public void stop() throws Exception {
}
Expand Down Expand Up @@ -207,6 +209,11 @@ public int getActiveTransactionCount() {
public Long getOldestActiveTransactionDuration() {
return null;
}

@Override
public Long getConnectedTimestamp() {
return connectedTimestamp;
}
});

final DestinationStatistics destinationStatistics = new DestinationStatistics();
Expand Down