Skip to content

Commit 1336063

Browse files
committed
[AMQ-9815] Add additional attributes to ConnectorView (#1556)
(cherry picked from commit 2790ac2)
1 parent 120aa34 commit 1336063

File tree

4 files changed

+164
-2
lines changed

4 files changed

+164
-2
lines changed

activemq-broker/src/main/java/org/apache/activemq/broker/Connector.java

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
import org.apache.activemq.broker.region.ConnectorStatistics;
2121
import org.apache.activemq.command.BrokerInfo;
2222

23+
import java.io.IOException;
24+
import java.net.URI;
25+
import java.net.URISyntaxException;
26+
2327
/**
2428
* A connector creates and manages client connections that talk to the Broker.
2529
*
@@ -62,18 +66,20 @@ public interface Connector extends Service {
6266
* @return true if clients should be updated when
6367
* a broker is removed from a broker
6468
*/
65-
public boolean isUpdateClusterClientsOnRemove();
69+
public boolean isUpdateClusterClientsOnRemove();
6670

71+
@Deprecated(forRemoval = true)
6772
int connectionCount();
6873

6974
/**
7075
* If enabled, older connections with the same clientID are stopped
76+
*
7177
* @return true/false if link stealing is enabled
7278
*/
7379
boolean isAllowLinkStealing();
7480

7581
/**
76-
* @return The comma separated string of regex patterns to match
82+
* @return The comma separated string of regex patterns to match
7783
* broker names for cluster client updates
7884
*/
7985
String getUpdateClusterFilter();
@@ -86,4 +92,23 @@ public interface Connector extends Service {
8692
* @return true if connector is started
8793
*/
8894
public boolean isStarted();
95+
96+
public URI getConnectUri() throws IOException, URISyntaxException;
97+
98+
public URI getPublishableConnectURI() throws Exception;
99+
100+
public boolean isEnableStatusMonitor();
101+
102+
public URI getUri();
103+
104+
public URI getDiscoveryUri();
105+
106+
public boolean isAuditNetworkProducers();
107+
108+
public int getMaximumProducersAllowedPerConnection();
109+
110+
public int getMaximumConsumersAllowedPerConnection();
111+
112+
public int getConnectionCount();
113+
89114
}

activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnector.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ public void setServer(TransportServer server) {
156156
this.server = server;
157157
}
158158

159+
@Override
159160
public URI getUri() {
160161
if (uri == null) {
161162
try {
@@ -301,6 +302,7 @@ public String getPublishableConnectString() throws Exception {
301302
return publishableConnectString;
302303
}
303304

305+
@Override
304306
public URI getPublishableConnectURI() throws Exception {
305307
return publishedAddressPolicy.getPublishableConnectURI(this);
306308
}
@@ -375,6 +377,7 @@ public void setDiscoveryAgent(DiscoveryAgent discoveryAgent) {
375377
this.discoveryAgent = discoveryAgent;
376378
}
377379

380+
@Override
378381
public URI getDiscoveryUri() {
379382
return discoveryUri;
380383
}
@@ -383,6 +386,7 @@ public void setDiscoveryUri(URI discoveryUri) {
383386
this.discoveryUri = discoveryUri;
384387
}
385388

389+
@Override
386390
public URI getConnectUri() throws IOException, URISyntaxException {
387391
if (server != null) {
388392
return server.getConnectURI();
@@ -519,6 +523,7 @@ public void setDisableAsyncDispatch(boolean disableAsyncDispatch) {
519523
/**
520524
* @return the enableStatusMonitor
521525
*/
526+
@Override
522527
public boolean isEnableStatusMonitor() {
523528
return enableStatusMonitor;
524529
}
@@ -610,6 +615,7 @@ public void setUpdateClusterFilter(String updateClusterFilter) {
610615
this.updateClusterFilter = updateClusterFilter;
611616
}
612617

618+
@Deprecated(forRemoval = true)
613619
@Override
614620
public int connectionCount() {
615621
return connections.size();
@@ -624,6 +630,7 @@ public void setAllowLinkStealing(boolean allowLinkStealing) {
624630
this.allowLinkStealing = allowLinkStealing;
625631
}
626632

633+
@Override
627634
public boolean isAuditNetworkProducers() {
628635
return auditNetworkProducers;
629636
}
@@ -637,6 +644,7 @@ public void setAuditNetworkProducers(boolean auditNetworkProducers) {
637644
this.auditNetworkProducers = auditNetworkProducers;
638645
}
639646

647+
@Override
640648
public int getMaximumProducersAllowedPerConnection() {
641649
return maximumProducersAllowedPerConnection;
642650
}
@@ -645,6 +653,7 @@ public void setMaximumProducersAllowedPerConnection(int maximumProducersAllowedP
645653
this.maximumProducersAllowedPerConnection = maximumProducersAllowedPerConnection;
646654
}
647655

656+
@Override
648657
public int getMaximumConsumersAllowedPerConnection() {
649658
return maximumConsumersAllowedPerConnection;
650659
}
@@ -707,4 +716,9 @@ public void setAutoStart(boolean autoStart) {
707716
public boolean isAutoStart() {
708717
return autoStart;
709718
}
719+
720+
@Override
721+
public int getConnectionCount() {
722+
return connections.size();
723+
}
710724
}

activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectorView.java

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import org.apache.activemq.broker.Connector;
2020
import org.apache.activemq.command.BrokerInfo;
2121

22+
import java.net.URI;
23+
2224
public class ConnectorView implements ConnectorViewMBean {
2325

2426
private final Connector connector;
@@ -32,6 +34,7 @@ public void start() throws Exception {
3234
connector.start();
3335
}
3436

37+
@Override
3538
public String getBrokerName() {
3639
return getBrokerInfo().getBrokerName();
3740
}
@@ -151,4 +154,80 @@ public boolean isAutoStart() {
151154
public boolean isStarted() {
152155
return this.connector.isStarted();
153156
}
157+
158+
@Override
159+
public String getConnectURI() {
160+
URI tmpConnectUri = null;
161+
try {
162+
tmpConnectUri = this.connector.getConnectUri();
163+
} catch (Exception e) {}
164+
return (tmpConnectUri != null ? tmpConnectUri.toString() : null);
165+
}
166+
167+
@Override
168+
public String getPublishableConnectURI() {
169+
URI publishableConnectURI = null;
170+
try {
171+
publishableConnectURI = this.connector.getPublishableConnectURI();
172+
} catch (Exception e) {}
173+
174+
return (publishableConnectURI != null ? publishableConnectURI.toString() : null);
175+
}
176+
177+
@Override
178+
public String getBrokerInfoString() {
179+
return getBrokerInfo().toString();
180+
}
181+
182+
/**
183+
* Returns true the status monitor is enabled
184+
*
185+
* @return true if status monitor is enabled
186+
*/
187+
@Override
188+
public boolean isEnableStatusMonitor() {
189+
return this.connector.isEnableStatusMonitor();
190+
}
191+
192+
@Override
193+
public String getURI() {
194+
URI tmpURI = this.connector.getUri();
195+
return (tmpURI != null ? tmpURI.toString() : null);
196+
}
197+
198+
@Override
199+
public String getDiscoveryURI() {
200+
URI tmpDiscoveryURI = this.connector.getDiscoveryUri();
201+
return (tmpDiscoveryURI != null ? tmpDiscoveryURI.toString() : null);
202+
}
203+
204+
@Override
205+
public boolean isAuditNetworkProducers() {
206+
return this.connector.isAuditNetworkProducers();
207+
}
208+
209+
/**
210+
* Returns the number of maximum producers allowed per-connection
211+
*/
212+
@Override
213+
public int getMaximumProducersAllowedPerConnection() {
214+
return this.connector.getMaximumProducersAllowedPerConnection();
215+
}
216+
217+
/**
218+
* Returns the number of maximum consumers allowed per-connection
219+
*/
220+
@Override
221+
public int getMaximumConsumersAllowedPerConnection() {
222+
return this.connector.getMaximumConsumersAllowedPerConnection();
223+
}
224+
225+
/**
226+
* Returns the number of current connections
227+
*/
228+
@Override
229+
public int getConnectionCount() {
230+
return this.connector.connectionCount();
231+
}
232+
154233
}

activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectorViewMBean.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@
1818

1919
import org.apache.activemq.Service;
2020

21+
import java.net.URI;
22+
2123
public interface ConnectorViewMBean extends Service {
2224

25+
// [AMQ-9815] Non-getter makes this a JMX operation v attribute
26+
// TODO: Remove for 7.0
27+
@Deprecated(forRemoval = true)
2328
@MBeanInfo("Connection count")
2429
int connectionCount();
2530

@@ -101,4 +106,43 @@ public interface ConnectorViewMBean extends Service {
101106
*/
102107
@MBeanInfo("Connector started")
103108
boolean isStarted();
109+
110+
/**
111+
* @return The direct connect uri
112+
*/
113+
@MBeanInfo("Direct connect uri")
114+
public String getConnectURI();
115+
116+
/**
117+
* @return The publishable connect uri
118+
*/
119+
@MBeanInfo("Publishable connect uri")
120+
public String getPublishableConnectURI();
121+
122+
@MBeanInfo("Broker name")
123+
public String getBrokerName();
124+
125+
@MBeanInfo("String of the BrokerInfo data")
126+
public String getBrokerInfoString();
127+
128+
@MBeanInfo("StatusMonitor enabled")
129+
public boolean isEnableStatusMonitor();
130+
131+
@MBeanInfo("Connector URI")
132+
public String getURI();
133+
134+
@MBeanInfo("DiscoveryURI")
135+
public String getDiscoveryURI();
136+
137+
@MBeanInfo("AuditNetworkProducers enabled")
138+
public boolean isAuditNetworkProducers();
139+
140+
@MBeanInfo("Maximum number of producers allowed per-connection")
141+
public int getMaximumProducersAllowedPerConnection();
142+
143+
@MBeanInfo("Maximum number of consumers allowed per-connection")
144+
public int getMaximumConsumersAllowedPerConnection();
145+
146+
@MBeanInfo("Connection count")
147+
public int getConnectionCount();
104148
}

0 commit comments

Comments
 (0)