Skip to content

Commit

Permalink
Merge pull request #2087 from wso2/master.2023
Browse files Browse the repository at this point in the history
Introducing a new synapse property to initialize the endpoint view MBeans
  • Loading branch information
HiranyaKavishani authored May 29, 2024
2 parents 9bfe72e + 23d1543 commit 31cae45
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,7 @@ public class JmxConfigurationConstants {
public static final String PROP_REMOTE_SSL = "remote.ssl";

public static final String PROP_THREAD_JMX_ENABLE = "synapse.jmx.thread.view.enabled";

public static final String PROP_ENDPOINT_VIEW_JMX_ENABLE = "synapse.jmx.endpoint.view.enabled";

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import org.apache.axis2.deployment.DeploymentException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.commons.jmx.JmxConfigurationConstants;
import org.apache.synapse.commons.util.MiscellaneousUtil;
import org.apache.synapse.config.SynapsePropertiesLoader;
import org.apache.synapse.transport.customlogsetter.CustomLogSetter;
import org.apache.synapse.commons.jmx.MBeanRegistrar;
import org.apache.synapse.config.xml.MultiXMLConfigurationBuilder;
Expand All @@ -42,6 +45,10 @@ public class EndpointDeployer extends AbstractSynapseArtifactDeployer {

private static Log log = LogFactory.getLog(EndpointDeployer.class);

private static final boolean jmxEnabled = Boolean.parseBoolean(
MiscellaneousUtil.getProperty(SynapsePropertiesLoader.loadSynapseProperties(),
JmxConfigurationConstants.PROP_ENDPOINT_VIEW_JMX_ENABLE, "true"));

@Override
public String deploySynapseArtifact(OMElement artifactConfig, String fileName,
Properties properties) {
Expand Down Expand Up @@ -126,7 +133,7 @@ public String updateSynapseArtifact(OMElement artifactConfig, String fileName,

waitForCompletion();
existingEp.destroy();
if (existingArtifactName.equals(ep.getName())) {
if (existingArtifactName.equals(ep.getName()) && jmxEnabled) {
// If the endpoint name was same as the old one, above method call (destroy)
// will unregister the endpoint MBean - So we should register it again.
MBeanRegistrar.getInstance().registerMBean(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@
import org.apache.synapse.aspects.flow.statistics.collectors.OpenEventCollector;
import org.apache.synapse.aspects.flow.statistics.collectors.RuntimeStatisticCollector;
import org.apache.synapse.aspects.flow.statistics.data.artifact.ArtifactHolder;
import org.apache.synapse.commons.jmx.JmxConfigurationConstants;
import org.apache.synapse.commons.throttle.core.ConcurrentAccessController;
import org.apache.synapse.commons.throttle.core.ConcurrentAccessReplicator;
import org.apache.synapse.commons.util.MiscellaneousUtil;
import org.apache.synapse.config.SynapsePropertiesLoader;
import org.apache.synapse.transport.util.MessageHandlerProvider;
import org.apache.synapse.transport.customlogsetter.CustomLogSetter;
import org.apache.synapse.aspects.AspectConfiguration;
Expand Down Expand Up @@ -71,6 +74,10 @@ public abstract class AbstractEndpoint extends FaultHandler implements Endpoint,
protected Log log;
protected static final Log trace = LogFactory.getLog(SynapseConstants.TRACE_LOGGER);

private static final boolean jmxEnabled = Boolean.parseBoolean(MiscellaneousUtil.getProperty(
SynapsePropertiesLoader.loadSynapseProperties(),
JmxConfigurationConstants.PROP_ENDPOINT_VIEW_JMX_ENABLE, "true"));

/** Hold the logical name of an endpoint */
private String endpointName = null;

Expand Down Expand Up @@ -217,7 +224,7 @@ public String toString() {

public void setName(String endpointName) {
this.endpointName = endpointName;
if (enableMBeanStats) {
if (enableMBeanStats && jmxEnabled) {
/*if (endpointName != null && !"".equals(endpointName.trim())){
//we skip stat collection for endpoints with no defined name
log.warn("Endpoint Name not found. Skipped JMX statistics collection for this endpoint");
Expand Down

0 comments on commit 31cae45

Please sign in to comment.