ARTEMIS-2610 Improve ActiveMQServer.getConnectionCount()
This commit is contained in:
parent
d1558f172b
commit
cfa11bbadc
|
@ -43,6 +43,17 @@ public interface RemotingService {
|
|||
|
||||
Set<RemotingConnection> getConnections();
|
||||
|
||||
/**
|
||||
* @return the number of clients connected to this server.
|
||||
*/
|
||||
default int getConnectionCount() {
|
||||
final Set<RemotingConnection> connections = getConnections();
|
||||
return connections == null ? 0 : getConnections().size();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of clients which have connected to this server since it was started.
|
||||
*/
|
||||
long getTotalConnectionCount();
|
||||
|
||||
ReusableLatch getConnectionCountLatch();
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
@ -93,7 +94,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif
|
|||
|
||||
private final Map<String, Acceptor> acceptors = new HashMap<>();
|
||||
|
||||
private final Map<Object, ConnectionEntry> connections = new ConcurrentHashMap<>();
|
||||
private final ConcurrentMap<Object, ConnectionEntry> connections = new ConcurrentHashMap<>();
|
||||
|
||||
private final ReusableLatch connectionCountLatch = new ReusableLatch(0);
|
||||
|
||||
|
@ -500,6 +501,11 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif
|
|||
return conns;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getConnectionCount() {
|
||||
return connections.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTotalConnectionCount() {
|
||||
return totalConnectionCount.get();
|
||||
|
|
|
@ -1677,7 +1677,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
|
|||
|
||||
@Override
|
||||
public int getConnectionCount() {
|
||||
return remotingService.getConnections().size();
|
||||
return remotingService.getConnectionCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue