mirror of
https://github.com/apache/activemq.git
synced 2025-02-15 06:26:44 +00:00
[AMQ-9163] Add 'Started' attribute to ConnectorView (#932)
(cherry picked from commit c25975389f031a787414b404c848a4757f7180e5)
This commit is contained in:
parent
e391298b50
commit
d830dc2954
@ -72,4 +72,9 @@ public interface Connector extends Service {
|
||||
* broker names for cluster client updates
|
||||
*/
|
||||
String getUpdateClusterFilter();
|
||||
|
||||
/**
|
||||
* @return true if connector is started
|
||||
*/
|
||||
public boolean isStarted();
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.management.ObjectName;
|
||||
@ -81,6 +82,7 @@ public class TransportConnector implements Connector, BrokerServiceAware {
|
||||
private boolean displayStackTrace = false;
|
||||
|
||||
LinkedList<String> peerBrokers = new LinkedList<String>();
|
||||
private AtomicBoolean started = new AtomicBoolean(false);
|
||||
|
||||
public TransportConnector() {
|
||||
}
|
||||
@ -264,6 +266,7 @@ public class TransportConnector implements Connector, BrokerServiceAware {
|
||||
this.statusDector.start();
|
||||
}
|
||||
|
||||
started.set(true);
|
||||
LOG.info("Connector {} started", getName());
|
||||
}
|
||||
|
||||
@ -308,6 +311,7 @@ public class TransportConnector implements Connector, BrokerServiceAware {
|
||||
ss.stop(connection);
|
||||
}
|
||||
server = null;
|
||||
started.set(false);
|
||||
ss.throwFirstException();
|
||||
LOG.info("Connector {} stopped", getName());
|
||||
}
|
||||
@ -673,4 +677,9 @@ public class TransportConnector implements Connector, BrokerServiceAware {
|
||||
public void setDisplayStackTrace(boolean displayStackTrace) {
|
||||
this.displayStackTrace = displayStackTrace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStarted() {
|
||||
return started.get();
|
||||
}
|
||||
}
|
||||
|
@ -136,4 +136,9 @@ public class ConnectorView implements ConnectorViewMBean {
|
||||
public boolean isAllowLinkStealingEnabled() {
|
||||
return this.connector.isAllowLinkStealing();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStarted() {
|
||||
return this.connector.isStarted();
|
||||
}
|
||||
}
|
||||
|
@ -83,5 +83,9 @@ public interface ConnectorViewMBean extends Service {
|
||||
@MBeanInfo("Comma separated list of regex patterns to match broker names for cluster client updates.")
|
||||
String getUpdateClusterFilter();
|
||||
|
||||
|
||||
/**
|
||||
* @return true if transport connector is started
|
||||
*/
|
||||
@MBeanInfo("Connector started")
|
||||
boolean isStarted();
|
||||
}
|
||||
|
@ -18,10 +18,16 @@ package org.apache.activemq.broker.jmx;
|
||||
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.net.Socket;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.management.JMX;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import org.apache.activemq.ActiveMQConnection;
|
||||
@ -60,6 +66,18 @@ public class TransportConnectorMBeanTest {
|
||||
doVerifyClientIdNetwork(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStartStop() throws Exception {
|
||||
createBroker(true);
|
||||
final ConnectorViewMBean connectorViewMBean = JMX.newMBeanProxy(ManagementFactory.getPlatformMBeanServer(), BrokerMBeanSupport.createConnectorName(BrokerMBeanSupport.createBrokerObjectName("org.apache.activemq", "localhost").toString(), "clientConnectors", broker.getTransportConnectorByScheme("tcp").getPublishableConnectString()), ConnectorViewMBean.class);
|
||||
assertNotNull(connectorViewMBean);
|
||||
assertTrue(connectorViewMBean.isStarted());
|
||||
connectorViewMBean.stop();
|
||||
assertFalse(connectorViewMBean.isStarted());
|
||||
connectorViewMBean.start();
|
||||
assertTrue(connectorViewMBean.isStarted());
|
||||
}
|
||||
|
||||
private void doVerifyClientIdNetwork(boolean duplex) throws Exception {
|
||||
createBroker(true);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user