Search in sources :

Example 6 with Notification

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

the class NettyAcceptor method stop.

@Override
public synchronized void stop() {
    if (channelClazz == null) {
        return;
    }
    if (protocolHandler != null) {
        protocolHandler.close();
    }
    if (batchFlusherFuture != null) {
        batchFlusherFuture.cancel(false);
        flusher.cancel();
        flusher = null;
        batchFlusherFuture = null;
    }
    // serverChannelGroup has been unbound in pause()
    if (serverChannelGroup != null) {
        serverChannelGroup.close().awaitUninterruptibly();
    }
    if (channelGroup != null) {
        ChannelGroupFuture future = channelGroup.close().awaitUninterruptibly();
        if (!future.isSuccess()) {
            ActiveMQServerLogger.LOGGER.nettyChannelGroupError();
            for (Channel channel : future.group()) {
                if (channel.isActive()) {
                    ActiveMQServerLogger.LOGGER.nettyChannelStillOpen(channel, channel.remoteAddress());
                }
            }
        }
    }
    // Shutdown the EventLoopGroup if no new task was added for 100ms or if
    // 3000ms elapsed.
    eventLoopGroup.shutdownGracefully(100, 3000, TimeUnit.MILLISECONDS);
    eventLoopGroup = null;
    channelClazz = null;
    for (Connection connection : connections.values()) {
        listener.connectionDestroyed(connection.getID());
    }
    connections.clear();
    if (notificationService != null) {
        TypedProperties props = new TypedProperties();
        props.putSimpleStringProperty(new SimpleString("factory"), new SimpleString(NettyAcceptorFactory.class.getName()));
        props.putSimpleStringProperty(new SimpleString("host"), new SimpleString(host));
        props.putIntProperty(new SimpleString("port"), port);
        Notification notification = new Notification(null, CoreNotificationType.ACCEPTOR_STOPPED, props);
        try {
            notificationService.sendNotification(notification);
        } catch (Exception e) {
            ActiveMQServerLogger.LOGGER.failedToSendNotification(e);
        }
    }
    paused = false;
}
Also used : ChannelGroupFuture(io.netty.channel.group.ChannelGroupFuture) LocalServerChannel(io.netty.channel.local.LocalServerChannel) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) ServerChannel(io.netty.channel.ServerChannel) KQueueServerSocketChannel(io.netty.channel.kqueue.KQueueServerSocketChannel) EpollServerSocketChannel(io.netty.channel.epoll.EpollServerSocketChannel) Channel(io.netty.channel.Channel) ClusterConnection(org.apache.activemq.artemis.core.server.cluster.ClusterConnection) Connection(org.apache.activemq.artemis.spi.core.remoting.Connection) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) TypedProperties(org.apache.activemq.artemis.utils.collections.TypedProperties) Notification(org.apache.activemq.artemis.core.server.management.Notification) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) SSLHandshakeException(javax.net.ssl.SSLHandshakeException)

Example 7 with Notification

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

the class BridgeImpl method pause.

@Override
public void pause() throws Exception {
    if (logger.isDebugEnabled()) {
        logger.debug("Bridge " + this.name + " being paused");
    }
    executor.execute(new PauseRunnable());
    if (notificationService != null) {
        TypedProperties props = new TypedProperties();
        props.putSimpleStringProperty(new SimpleString("name"), name);
        Notification notification = new Notification(nodeUUID.toString(), CoreNotificationType.BRIDGE_STOPPED, props);
        try {
            notificationService.sendNotification(notification);
        } catch (Exception e) {
            ActiveMQServerLogger.LOGGER.notificationBridgeStoppedError(e);
        }
    }
}
Also used : SimpleString(org.apache.activemq.artemis.api.core.SimpleString) TypedProperties(org.apache.activemq.artemis.utils.collections.TypedProperties) Notification(org.apache.activemq.artemis.core.server.management.Notification) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) ActiveMQInterruptedException(org.apache.activemq.artemis.api.core.ActiveMQInterruptedException)

Example 8 with Notification

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

the class BridgeImpl method start.

@Override
public synchronized void start() throws Exception {
    if (started) {
        return;
    }
    started = true;
    stopping = false;
    activate();
    if (notificationService != null) {
        TypedProperties props = new TypedProperties();
        props.putSimpleStringProperty(new SimpleString("name"), name);
        Notification notification = new Notification(nodeUUID.toString(), CoreNotificationType.BRIDGE_STARTED, props);
        notificationService.sendNotification(notification);
    }
}
Also used : SimpleString(org.apache.activemq.artemis.api.core.SimpleString) TypedProperties(org.apache.activemq.artemis.utils.collections.TypedProperties) Notification(org.apache.activemq.artemis.core.server.management.Notification)

Example 9 with Notification

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

the class BroadcastGroupImpl method stop.

@Override
public synchronized void stop() {
    if (!started) {
        return;
    }
    if (future != null) {
        future.cancel(false);
    }
    try {
        endpoint.close(true);
    } catch (Exception e1) {
        ActiveMQServerLogger.LOGGER.broadcastGroupClosed(e1);
    }
    started = false;
    if (notificationService != null) {
        TypedProperties props = new TypedProperties();
        props.putSimpleStringProperty(new SimpleString("name"), new SimpleString(name));
        Notification notification = new Notification(nodeManager.getNodeId().toString(), CoreNotificationType.BROADCAST_GROUP_STOPPED, props);
        try {
            notificationService.sendNotification(notification);
        } catch (Exception e) {
            ActiveMQServerLogger.LOGGER.broadcastGroupClosed(e);
        }
    }
}
Also used : SimpleString(org.apache.activemq.artemis.api.core.SimpleString) TypedProperties(org.apache.activemq.artemis.utils.collections.TypedProperties) Notification(org.apache.activemq.artemis.core.server.management.Notification)

Example 10 with Notification

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

the class ClusterConnectionImpl method activate.

private synchronized void activate() throws Exception {
    if (!started) {
        return;
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Activating cluster connection nodeID=" + nodeManager.getNodeId() + " for server=" + this.server);
    }
    liveNotifier = new LiveNotifier();
    liveNotifier.updateAsLive();
    liveNotifier.schedule();
    serverLocator = clusterConnector.createServerLocator();
    if (serverLocator != null) {
        if (!useDuplicateDetection) {
            logger.debug("DuplicateDetection is disabled, sending clustered messages blocked");
        }
        final TopologyMember currentMember = topology.getMember(manager.getNodeId());
        if (currentMember == null) {
            // sanity check only
            throw new IllegalStateException("InternalError! The ClusterConnection doesn't know about its own node = " + this);
        }
        serverLocator.setNodeID(nodeManager.getNodeId().toString());
        serverLocator.setIdentity("(main-ClusterConnection::" + server.toString() + ")");
        serverLocator.setReconnectAttempts(0);
        serverLocator.setClusterConnection(true);
        serverLocator.setClusterTransportConfiguration(connector);
        serverLocator.setInitialConnectAttempts(-1);
        serverLocator.setClientFailureCheckPeriod(clientFailureCheckPeriod);
        serverLocator.setConnectionTTL(connectionTTL);
        serverLocator.setConfirmationWindowSize(confirmationWindowSize);
        // if not using duplicate detection, we will send blocked
        serverLocator.setBlockOnDurableSend(!useDuplicateDetection);
        serverLocator.setBlockOnNonDurableSend(!useDuplicateDetection);
        serverLocator.setCallTimeout(callTimeout);
        serverLocator.setCallFailoverTimeout(callFailoverTimeout);
        serverLocator.setProducerWindowSize(producerWindowSize);
        if (retryInterval > 0) {
            this.serverLocator.setRetryInterval(retryInterval);
        }
        serverLocator.setAfterConnectionInternalListener(this);
        serverLocator.setProtocolManagerFactory(ActiveMQServerSideProtocolManagerFactory.getInstance(serverLocator));
        serverLocator.start(server.getExecutorFactory().getExecutor());
    }
    if (managementService != null) {
        TypedProperties props = new TypedProperties();
        props.putSimpleStringProperty(new SimpleString("name"), name);
        Notification notification = new Notification(nodeManager.getNodeId().toString(), CoreNotificationType.CLUSTER_CONNECTION_STARTED, props);
        logger.debug("sending notification: " + notification);
        managementService.sendNotification(notification);
    }
    // we add as a listener after we have sent the cluster start notif as the listener may start sending notifs before
    addClusterTopologyListener(this);
}
Also used : SimpleString(org.apache.activemq.artemis.api.core.SimpleString) TopologyMember(org.apache.activemq.artemis.api.core.client.TopologyMember) TypedProperties(org.apache.activemq.artemis.utils.collections.TypedProperties) Notification(org.apache.activemq.artemis.core.server.management.Notification)

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