Search in sources :

Example 31 with Notification

use of org.apache.activemq.artemis.core.server.management.Notification in project activemq-artemis by apache.

the class RemoteGroupingHandler method receive.

@Override
public Response receive(final Proposal proposal, final int distance) throws Exception {
    TypedProperties props = new TypedProperties();
    props.putSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_GROUP_ID, proposal.getGroupId());
    props.putSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_VALUE, proposal.getClusterName());
    props.putIntProperty(ManagementHelper.HDR_BINDING_TYPE, BindingType.LOCAL_QUEUE_INDEX);
    props.putSimpleStringProperty(ManagementHelper.HDR_ADDRESS, address);
    props.putIntProperty(ManagementHelper.HDR_DISTANCE, distance);
    Notification notification = new Notification(null, CoreNotificationType.PROPOSAL, props);
    managementService.sendNotification(notification);
    return null;
}
Also used : TypedProperties(org.apache.activemq.artemis.utils.collections.TypedProperties) Notification(org.apache.activemq.artemis.core.server.management.Notification)

Example 32 with Notification

use of org.apache.activemq.artemis.core.server.management.Notification in project activemq-artemis by apache.

the class AcceptorControlTest method testNotifications.

@Test
public void testNotifications() throws Exception {
    TransportConfiguration acceptorConfig = new TransportConfiguration(InVMAcceptorFactory.class.getName(), new HashMap<String, Object>(), RandomUtil.randomString());
    TransportConfiguration acceptorConfig2 = new TransportConfiguration(NettyAcceptorFactory.class.getName(), new HashMap<String, Object>(), RandomUtil.randomString());
    Configuration config = createBasicConfig().addAcceptorConfiguration(acceptorConfig).addAcceptorConfiguration(acceptorConfig2);
    ActiveMQServer service = createServer(false, config);
    service.setMBeanServer(mbeanServer);
    service.start();
    AcceptorControl acceptorControl = createManagementControl(acceptorConfig2.getName());
    SimpleNotificationService.Listener notifListener = new SimpleNotificationService.Listener();
    service.getManagementService().addNotificationListener(notifListener);
    Assert.assertEquals(0, notifListener.getNotifications().size());
    acceptorControl.stop();
    Assert.assertEquals(usingCore() ? 5 : 1, notifListener.getNotifications().size());
    Notification notif = notifListener.getNotifications().get(usingCore() ? 2 : 0);
    Assert.assertEquals(CoreNotificationType.ACCEPTOR_STOPPED, notif.getType());
    Assert.assertEquals(NettyAcceptorFactory.class.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("factory")).toString());
    acceptorControl.start();
    Assert.assertEquals(usingCore() ? 10 : 2, notifListener.getNotifications().size());
    notif = notifListener.getNotifications().get(usingCore() ? 7 : 1);
    Assert.assertEquals(CoreNotificationType.ACCEPTOR_STARTED, notif.getType());
    Assert.assertEquals(NettyAcceptorFactory.class.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("factory")).toString());
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) AcceptorControl(org.apache.activemq.artemis.api.core.management.AcceptorControl) NettyAcceptorFactory(org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) Notification(org.apache.activemq.artemis.core.server.management.Notification) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) SimpleNotificationService(org.apache.activemq.artemis.tests.integration.SimpleNotificationService) InVMAcceptorFactory(org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory) Test(org.junit.Test)

Example 33 with Notification

use of org.apache.activemq.artemis.core.server.management.Notification in project activemq-artemis by apache.

the class ClusterConnectionControlTest method getFirstNotificationOfType.

private Notification getFirstNotificationOfType(List<Notification> notifications, CoreNotificationType type) {
    Notification result = null;
    // the notifications can change while we're looping
    List<Notification> notificationsClone = new ArrayList<>(notifications);
    for (Notification notification : notificationsClone) {
        if (notification.getType().equals(type)) {
            result = notification;
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) Notification(org.apache.activemq.artemis.core.server.management.Notification)

Example 34 with Notification

use of org.apache.activemq.artemis.core.server.management.Notification in project activemq-artemis by apache.

the class BridgeControlTest method testNotifications.

@Test
public void testNotifications() throws Exception {
    SimpleNotificationService.Listener notifListener = new SimpleNotificationService.Listener();
    BridgeControl bridgeControl = createBridgeControl(bridgeConfig.getName(), mbeanServer);
    server_0.getManagementService().addNotificationListener(notifListener);
    Assert.assertEquals(0, notifListener.getNotifications().size());
    bridgeControl.stop();
    Assert.assertEquals(1, notifListener.getNotifications().size());
    Notification notif = notifListener.getNotifications().get(0);
    Assert.assertEquals(CoreNotificationType.BRIDGE_STOPPED, notif.getType());
    Assert.assertEquals(bridgeControl.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("name")).toString());
    bridgeControl.start();
    Assert.assertEquals(2, notifListener.getNotifications().size());
    notif = notifListener.getNotifications().get(1);
    Assert.assertEquals(CoreNotificationType.BRIDGE_STARTED, notif.getType());
    Assert.assertEquals(bridgeControl.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("name")).toString());
}
Also used : BridgeControl(org.apache.activemq.artemis.api.core.management.BridgeControl) SimpleNotificationService(org.apache.activemq.artemis.tests.integration.SimpleNotificationService) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) Notification(org.apache.activemq.artemis.core.server.management.Notification) Test(org.junit.Test)

Example 35 with Notification

use of org.apache.activemq.artemis.core.server.management.Notification in project activemq-artemis by apache.

the class DiscoveryTest method testDiscoveryGroupNotifications.

@Test
public void testDiscoveryGroupNotifications() throws Exception {
    SimpleNotificationService notifService = new SimpleNotificationService();
    SimpleNotificationService.Listener notifListener = new SimpleNotificationService.Listener();
    notifService.addNotificationListener(notifListener);
    final InetAddress groupAddress = InetAddress.getByName(address1);
    final int groupPort = getUDPDiscoveryPort();
    final int timeout = 500;
    dg = newDiscoveryGroup(RandomUtil.randomString(), RandomUtil.randomString(), null, groupAddress, groupPort, timeout, notifService);
    Assert.assertEquals(0, notifListener.getNotifications().size());
    dg.start();
    Assert.assertEquals(1, notifListener.getNotifications().size());
    Notification notif = notifListener.getNotifications().get(0);
    Assert.assertEquals(CoreNotificationType.DISCOVERY_GROUP_STARTED, notif.getType());
    Assert.assertEquals(dg.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("name")).toString());
    dg.stop();
    Assert.assertEquals(2, notifListener.getNotifications().size());
    notif = notifListener.getNotifications().get(1);
    Assert.assertEquals(CoreNotificationType.DISCOVERY_GROUP_STOPPED, notif.getType());
    Assert.assertEquals(dg.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("name")).toString());
}
Also used : SimpleNotificationService(org.apache.activemq.artemis.tests.integration.SimpleNotificationService) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) InetAddress(java.net.InetAddress) BroadcastEndpoint(org.apache.activemq.artemis.api.core.BroadcastEndpoint) Notification(org.apache.activemq.artemis.core.server.management.Notification) Test(org.junit.Test)

Aggregations

Notification (org.apache.activemq.artemis.core.server.management.Notification)35 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)26 TypedProperties (org.apache.activemq.artemis.utils.collections.TypedProperties)24 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)9 Test (org.junit.Test)9 SimpleNotificationService (org.apache.activemq.artemis.tests.integration.SimpleNotificationService)5 CountDownLatch (java.util.concurrent.CountDownLatch)3 ActiveMQInterruptedException (org.apache.activemq.artemis.api.core.ActiveMQInterruptedException)3 Channel (io.netty.channel.Channel)2 ServerChannel (io.netty.channel.ServerChannel)2 EpollServerSocketChannel (io.netty.channel.epoll.EpollServerSocketChannel)2 KQueueServerSocketChannel (io.netty.channel.kqueue.KQueueServerSocketChannel)2 LocalServerChannel (io.netty.channel.local.LocalServerChannel)2 NioServerSocketChannel (io.netty.channel.socket.nio.NioServerSocketChannel)2 InetAddress (java.net.InetAddress)2 ActiveMQIllegalStateException (org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException)2 ActiveMQNonExistentQueueException (org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException)2 BroadcastEndpoint (org.apache.activemq.artemis.api.core.BroadcastEndpoint)2 CoreNotificationType (org.apache.activemq.artemis.api.core.management.CoreNotificationType)2 ClusterConnection (org.apache.activemq.artemis.core.server.cluster.ClusterConnection)2