ARTEMIS-2570 Improve performance of ConnectionsView
This commit is contained in:
parent
5d76bcbcb8
commit
3ad8391e9b
|
@ -70,13 +70,11 @@ public class ConnectionView extends ActiveMQAbstractView<RemotingConnection> {
|
||||||
.add("protocol", toString(connection.getProtocolName()))
|
.add("protocol", toString(connection.getProtocolName()))
|
||||||
.add("clientID", toString(connection.getClientID() != null ? connection.getClientID() : jmsSessionClientID))
|
.add("clientID", toString(connection.getClientID() != null ? connection.getClientID() : jmsSessionClientID))
|
||||||
.add("localAddress", toString(connection.getTransportLocalAddress()))
|
.add("localAddress", toString(connection.getTransportLocalAddress()))
|
||||||
.add("sessionCount", server.getSessions(connection.getID().toString()).size());
|
.add("sessionCount", sessions.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getField(RemotingConnection connection, String fieldName) {
|
public Object getField(RemotingConnection connection, String fieldName) {
|
||||||
List<ServerSession> sessions = server.getSessions(connection.getID().toString());
|
|
||||||
|
|
||||||
switch (fieldName) {
|
switch (fieldName) {
|
||||||
case "connectionID":
|
case "connectionID":
|
||||||
return connection.getID();
|
return connection.getID();
|
||||||
|
@ -84,6 +82,7 @@ public class ConnectionView extends ActiveMQAbstractView<RemotingConnection> {
|
||||||
return connection.getRemoteAddress();
|
return connection.getRemoteAddress();
|
||||||
case "users":
|
case "users":
|
||||||
Set<String> users = new TreeSet<>();
|
Set<String> users = new TreeSet<>();
|
||||||
|
List<ServerSession> sessions = server.getSessions(connection.getID().toString());
|
||||||
for (ServerSession session : sessions) {
|
for (ServerSession session : sessions) {
|
||||||
String username = session.getUsername() == null ? "" : session.getUsername();
|
String username = session.getUsername() == null ? "" : session.getUsername();
|
||||||
users.add(username);
|
users.add(username);
|
||||||
|
@ -100,7 +99,7 @@ public class ConnectionView extends ActiveMQAbstractView<RemotingConnection> {
|
||||||
case "localAddress":
|
case "localAddress":
|
||||||
return connection.getTransportLocalAddress();
|
return connection.getTransportLocalAddress();
|
||||||
case "sessionCount":
|
case "sessionCount":
|
||||||
return sessions.size();
|
return server.getSessions(connection.getID().toString()).size();
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Unsupported field, " + fieldName);
|
throw new IllegalArgumentException("Unsupported field, " + fieldName);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue