Skip to content
Open
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 @@ -20,6 +20,10 @@
import org.apache.activemq.broker.region.ConnectorStatistics;
import org.apache.activemq.command.BrokerInfo;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

/**
* A connector creates and manages client connections that talk to the Broker.
*
Expand Down Expand Up @@ -62,18 +66,20 @@ public interface Connector extends Service {
* @return true if clients should be updated when
* a broker is removed from a broker
*/
public boolean isUpdateClusterClientsOnRemove();
public boolean isUpdateClusterClientsOnRemove();

@Deprecated(forRemoval = true)
int connectionCount();

/**
* If enabled, older connections with the same clientID are stopped
*
* @return true/false if link stealing is enabled
*/
boolean isAllowLinkStealing();

/**
* @return The comma separated string of regex patterns to match
* @return The comma separated string of regex patterns to match
* broker names for cluster client updates
*/
String getUpdateClusterFilter();
Expand All @@ -86,4 +92,23 @@ public interface Connector extends Service {
* @return true if connector is started
*/
public boolean isStarted();

public URI getConnectUri() throws IOException, URISyntaxException;

public URI getPublishableConnectURI() throws Exception;

public boolean isEnableStatusMonitor();

public URI getUri();

public URI getDiscoveryUri();

public boolean isAuditNetworkProducers();

public int getMaximumProducersAllowedPerConnection();

public int getMaximumConsumersAllowedPerConnection();

public int getConnectionCount();

}
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public void setServer(TransportServer server) {
this.server = server;
}

@Override
public URI getUri() {
if (uri == null) {
try {
Expand Down Expand Up @@ -301,6 +302,7 @@ public String getPublishableConnectString() throws Exception {
return publishableConnectString;
}

@Override
public URI getPublishableConnectURI() throws Exception {
return publishedAddressPolicy.getPublishableConnectURI(this);
}
Expand Down Expand Up @@ -375,6 +377,7 @@ public void setDiscoveryAgent(DiscoveryAgent discoveryAgent) {
this.discoveryAgent = discoveryAgent;
}

@Override
public URI getDiscoveryUri() {
return discoveryUri;
}
Expand All @@ -383,6 +386,7 @@ public void setDiscoveryUri(URI discoveryUri) {
this.discoveryUri = discoveryUri;
}

@Override
public URI getConnectUri() throws IOException, URISyntaxException {
if (server != null) {
return server.getConnectURI();
Expand Down Expand Up @@ -519,6 +523,7 @@ public void setDisableAsyncDispatch(boolean disableAsyncDispatch) {
/**
* @return the enableStatusMonitor
*/
@Override
public boolean isEnableStatusMonitor() {
return enableStatusMonitor;
}
Expand Down Expand Up @@ -610,6 +615,7 @@ public void setUpdateClusterFilter(String updateClusterFilter) {
this.updateClusterFilter = updateClusterFilter;
}

@Deprecated(forRemoval = true)
@Override
public int connectionCount() {
return connections.size();
Expand All @@ -624,6 +630,7 @@ public void setAllowLinkStealing(boolean allowLinkStealing) {
this.allowLinkStealing = allowLinkStealing;
}

@Override
public boolean isAuditNetworkProducers() {
return auditNetworkProducers;
}
Expand All @@ -637,6 +644,7 @@ public void setAuditNetworkProducers(boolean auditNetworkProducers) {
this.auditNetworkProducers = auditNetworkProducers;
}

@Override
public int getMaximumProducersAllowedPerConnection() {
return maximumProducersAllowedPerConnection;
}
Expand All @@ -645,6 +653,7 @@ public void setMaximumProducersAllowedPerConnection(int maximumProducersAllowedP
this.maximumProducersAllowedPerConnection = maximumProducersAllowedPerConnection;
}

@Override
public int getMaximumConsumersAllowedPerConnection() {
return maximumConsumersAllowedPerConnection;
}
Expand Down Expand Up @@ -707,4 +716,9 @@ public void setAutoStart(boolean autoStart) {
public boolean isAutoStart() {
return autoStart;
}

@Override
public int getConnectionCount() {
return connections.size();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import org.apache.activemq.broker.Connector;
import org.apache.activemq.command.BrokerInfo;

import java.net.URI;

public class ConnectorView implements ConnectorViewMBean {

private final Connector connector;
Expand Down Expand Up @@ -151,4 +153,82 @@ public boolean isAutoStart() {
public boolean isStarted() {
return this.connector.isStarted();
}

@Override
public String getConnectURI() {
URI tmpConnectUri = null;
try {
tmpConnectUri = this.connector.getConnectUri();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it more readable to do a return this.connector.getConnectUri() and return null in the catch block.

} catch (Exception e) {}
return (tmpConnectUri != null ? tmpConnectUri.toString() : null);
}

@Override
public String getPublishableConnectURI() {
URI publishableConnectURI = null;
try {
publishableConnectURI = this.connector.getPublishableConnectURI();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as previous

} catch (Exception e) {}

return (publishableConnectURI != null ? publishableConnectURI.toString() : null);
}

@Override
public String getBrokerInfoString() {
var tmpBrokerInfo = this.connector.getBrokerInfo();
return (tmpBrokerInfo != null ? tmpBrokerInfo.toString() : null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if getBrokerInfo() can really return null, you probably could add a null check above in other methods.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a getBrokerInfo() method already available


}

/**
* Returns true the status monitor is enabled
*
* @return true if status monitor is enabled
*/
@Override
public boolean isEnableStatusMonitor() {
return this.connector.isEnableStatusMonitor();
}

@Override
public String getURI() {
URI tmpURI = this.connector.getUri();
return (tmpURI != null ? tmpURI.toString() : null);
}

@Override
public String getDiscoveryURI() {
URI tmpDiscoveryURI = this.connector.getDiscoveryUri();
return (tmpDiscoveryURI != null ? tmpDiscoveryURI.toString() : null);
}

@Override
public boolean isAuditNetworkProducers() {
return this.connector.isAuditNetworkProducers();
}

/**
* Returns the number of maximum producers allowed per-connection
*/
@Override
public int getMaximumProducersAllowedPerConnection() {
return this.connector.getMaximumProducersAllowedPerConnection();
}

/**
* Returns the number of maximum consumers allowed per-connection
*/
@Override
public int getMaximumConsumersAllowedPerConnection() {
return this.connector.getMaximumConsumersAllowedPerConnection();
}

/**
* Returns the number of current connections
*/
@Override
public int getConnectionCount() {
return this.connector.connectionCount();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@

import org.apache.activemq.Service;

import java.net.URI;

public interface ConnectorViewMBean extends Service {

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

Expand Down Expand Up @@ -101,4 +106,40 @@ public interface ConnectorViewMBean extends Service {
*/
@MBeanInfo("Connector started")
boolean isStarted();

/**
* @return The direct connect uri
*/
@MBeanInfo("Direct connect uri")
public String getConnectURI();

/**
* @return The publishable connect uri
*/
@MBeanInfo("Publishable connect uri")
public String getPublishableConnectURI();

@MBeanInfo("String of the BrokerInfo data")
public String getBrokerInfoString();

@MBeanInfo("StatusMonitor enabled")
public boolean isEnableStatusMonitor();

@MBeanInfo("Connector URI")
public String getURI();

@MBeanInfo("DiscoveryURI")
public String getDiscoveryURI();

@MBeanInfo("AuditNetworkProducers enabled")
public boolean isAuditNetworkProducers();

@MBeanInfo("Maximum number of producers allowed per-connection")
public int getMaximumProducersAllowedPerConnection();

@MBeanInfo("Maximum number of consumers allowed per-connection")
public int getMaximumConsumersAllowedPerConnection();

@MBeanInfo("Connection count")
public int getConnectionCount();
}