parent
e09c5fd9e5
commit
2294625cf0
|
@ -136,7 +136,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
|
|||
@Nullable
|
||||
private MessageHeaderInitializer headerInitializer;
|
||||
|
||||
private final Stats stats = new Stats();
|
||||
private final DefaultStats stats = new DefaultStats();
|
||||
|
||||
private final Map<String, StompConnectionHandler> connectionHandlers = new ConcurrentHashMap<>();
|
||||
|
||||
|
@ -382,11 +382,21 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
|
|||
|
||||
/**
|
||||
* Return a String describing internal state and counters.
|
||||
* Effectively {@code toString()} on {@link #getStats() getStats()}.
|
||||
*/
|
||||
public String getStatsInfo() {
|
||||
return this.stats.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a structured object with internal state and counters.
|
||||
* @since 5.2
|
||||
*/
|
||||
public Stats getStats() {
|
||||
return this.stats;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the current count of TCP connection to the broker.
|
||||
*/
|
||||
|
@ -1007,7 +1017,35 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
|
|||
}
|
||||
|
||||
|
||||
private class Stats {
|
||||
/**
|
||||
* Contract for access to session counters.
|
||||
* @since 5.2
|
||||
*/
|
||||
public interface Stats {
|
||||
|
||||
/**
|
||||
* The number of connection handlers.
|
||||
*/
|
||||
int getTotalHandlers();
|
||||
|
||||
/**
|
||||
* The number of CONNECT frames processed.
|
||||
*/
|
||||
int getTotalConnect();
|
||||
|
||||
/**
|
||||
* The number of CONNECTED frames processed.
|
||||
*/
|
||||
int getTotalConnected();
|
||||
|
||||
/**
|
||||
* The number of DISCONNECT frames processed.
|
||||
*/
|
||||
int getTotalDisconnect();
|
||||
}
|
||||
|
||||
|
||||
private class DefaultStats implements Stats {
|
||||
|
||||
private final AtomicInteger connect = new AtomicInteger();
|
||||
|
||||
|
@ -1015,6 +1053,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
|
|||
|
||||
private final AtomicInteger disconnect = new AtomicInteger();
|
||||
|
||||
|
||||
public void incrementConnectCount() {
|
||||
this.connect.incrementAndGet();
|
||||
}
|
||||
|
@ -1027,6 +1066,26 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
|
|||
this.disconnect.incrementAndGet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalHandlers() {
|
||||
return connectionHandlers.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalConnect() {
|
||||
return this.connect.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalConnected() {
|
||||
return this.connected.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalDisconnect() {
|
||||
return this.disconnect.get();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return (connectionHandlers.size() + " sessions, " + getTcpClientInfo() +
|
||||
(isBrokerAvailable() ? " (available)" : " (not available)") +
|
||||
|
|
|
@ -114,7 +114,7 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
|
|||
@Nullable
|
||||
private ApplicationEventPublisher eventPublisher;
|
||||
|
||||
private final Stats stats = new Stats();
|
||||
private final DefaultStats stats = new DefaultStats();
|
||||
|
||||
|
||||
/**
|
||||
|
@ -203,11 +203,20 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
|
|||
|
||||
/**
|
||||
* Return a String describing internal state and counters.
|
||||
* Effectively {@code toString()} on {@link #getStats() getStats()}.
|
||||
*/
|
||||
public String getStatsInfo() {
|
||||
return this.stats.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a structured object with internal state and counters.
|
||||
* @since 5.2
|
||||
*/
|
||||
public Stats getStats() {
|
||||
return this.stats;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle incoming WebSocket messages from clients.
|
||||
|
@ -640,7 +649,30 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
|
|||
}
|
||||
|
||||
|
||||
private static class Stats {
|
||||
/**
|
||||
* Contract for access to session counters.
|
||||
* @since 5.2
|
||||
*/
|
||||
public interface Stats {
|
||||
|
||||
/**
|
||||
* The number of CONNECT frames processed.
|
||||
*/
|
||||
int getTotalConnect();
|
||||
|
||||
/**
|
||||
* The number of CONNECTED frames processed.
|
||||
*/
|
||||
int getTotalConnected();
|
||||
|
||||
/**
|
||||
* The number of DISCONNECT frames processed.
|
||||
*/
|
||||
int getTotalDisconnect();
|
||||
}
|
||||
|
||||
|
||||
private static class DefaultStats implements Stats {
|
||||
|
||||
private final AtomicInteger connect = new AtomicInteger();
|
||||
|
||||
|
@ -648,6 +680,7 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
|
|||
|
||||
private final AtomicInteger disconnect = new AtomicInteger();
|
||||
|
||||
|
||||
public void incrementConnectCount() {
|
||||
this.connect.incrementAndGet();
|
||||
}
|
||||
|
@ -660,6 +693,21 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
|
|||
this.disconnect.incrementAndGet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalConnect() {
|
||||
return this.connect.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalConnected() {
|
||||
return this.connected.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalDisconnect() {
|
||||
return this.disconnect.get();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "processed CONNECT(" + this.connect.get() + ")-CONNECTED(" +
|
||||
this.connected.get() + ")-DISCONNECT(" + this.disconnect.get() + ")";
|
||||
|
|
|
@ -248,13 +248,14 @@ public class SubProtocolWebSocketHandler
|
|||
|
||||
/**
|
||||
* Return a String describing internal state and counters.
|
||||
* Effectively {@code toString()} on {@link #getStats() getStats()}.
|
||||
*/
|
||||
public String getStatsInfo() {
|
||||
return this.stats.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a {@link Stats} object that contains various session counters.
|
||||
* Return a structured object with various session counters.
|
||||
* @since 5.2
|
||||
*/
|
||||
public Stats getStats() {
|
||||
|
|
Loading…
Reference in New Issue