Search in sources :

Example 31 with TypedProperties

use of org.apache.activemq.artemis.utils.collections.TypedProperties in project activemq-artemis by apache.

the class BridgeImpl method stop.

@Override
public void stop() throws Exception {
    if (stopping) {
        return;
    }
    stopping = true;
    if (logger.isDebugEnabled()) {
        logger.debug("Bridge " + this.name + " being stopped");
    }
    if (futureScheduledReconnection != null) {
        futureScheduledReconnection.cancel(true);
    }
    executor.execute(new StopRunnable());
    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.broadcastBridgeStoppedError(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 32 with TypedProperties

use of org.apache.activemq.artemis.utils.collections.TypedProperties in project activemq-artemis by apache.

the class BroadcastGroupImpl method start.

@Override
public synchronized void start() throws Exception {
    if (started) {
        return;
    }
    endpoint.openBroadcaster();
    started = true;
    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_STARTED, props);
        notificationService.sendNotification(notification);
    }
    activate();
}
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 33 with TypedProperties

use of org.apache.activemq.artemis.utils.collections.TypedProperties in project activemq-artemis by apache.

the class ClusterConnectionImpl method stop.

@Override
public void stop() throws Exception {
    if (!started) {
        return;
    }
    stopping = true;
    if (logger.isDebugEnabled()) {
        logger.debug(this + "::stopping ClusterConnection");
    }
    if (serverLocator != null) {
        serverLocator.removeClusterTopologyListener(this);
    }
    logger.debug("Cluster connection being stopped for node" + nodeManager.getNodeId() + ", server = " + this.server + " serverLocator = " + serverLocator);
    synchronized (this) {
        for (MessageFlowRecord record : records.values()) {
            try {
                record.close();
            } catch (Exception ignore) {
            }
        }
    }
    if (managementService != null) {
        TypedProperties props = new TypedProperties();
        props.putSimpleStringProperty(new SimpleString("name"), name);
        Notification notification = new Notification(nodeManager.getNodeId().toString(), CoreNotificationType.CLUSTER_CONNECTION_STOPPED, props);
        managementService.sendNotification(notification);
    }
    executor.execute(new Runnable() {

        @Override
        public void run() {
            synchronized (ClusterConnectionImpl.this) {
                closeLocator(serverLocator);
                serverLocator = null;
            }
        }
    });
    started = false;
}
Also used : MessageFlowRecord(org.apache.activemq.artemis.core.server.cluster.MessageFlowRecord) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) TypedProperties(org.apache.activemq.artemis.utils.collections.TypedProperties) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) Notification(org.apache.activemq.artemis.core.server.management.Notification)

Example 34 with TypedProperties

use of org.apache.activemq.artemis.utils.collections.TypedProperties in project activemq-artemis by apache.

the class TypedPropertiesTest method setUp.

@Before
public void setUp() throws Exception {
    props = new TypedProperties();
    key = RandomUtil.randomSimpleString();
}
Also used : TypedProperties(org.apache.activemq.artemis.utils.collections.TypedProperties) Before(org.junit.Before)

Example 35 with TypedProperties

use of org.apache.activemq.artemis.utils.collections.TypedProperties in project activemq-artemis by apache.

the class TypedPropertiesTest method testEncodeDecode.

@Test
public void testEncodeDecode() throws Exception {
    props.putByteProperty(RandomUtil.randomSimpleString(), RandomUtil.randomByte());
    props.putBytesProperty(RandomUtil.randomSimpleString(), RandomUtil.randomBytes());
    props.putBytesProperty(RandomUtil.randomSimpleString(), null);
    props.putBooleanProperty(RandomUtil.randomSimpleString(), RandomUtil.randomBoolean());
    props.putShortProperty(RandomUtil.randomSimpleString(), RandomUtil.randomShort());
    props.putIntProperty(RandomUtil.randomSimpleString(), RandomUtil.randomInt());
    props.putLongProperty(RandomUtil.randomSimpleString(), RandomUtil.randomLong());
    props.putFloatProperty(RandomUtil.randomSimpleString(), RandomUtil.randomFloat());
    props.putDoubleProperty(RandomUtil.randomSimpleString(), RandomUtil.randomDouble());
    props.putCharProperty(RandomUtil.randomSimpleString(), RandomUtil.randomChar());
    props.putSimpleStringProperty(RandomUtil.randomSimpleString(), RandomUtil.randomSimpleString());
    props.putSimpleStringProperty(RandomUtil.randomSimpleString(), null);
    SimpleString keyToRemove = RandomUtil.randomSimpleString();
    props.putSimpleStringProperty(keyToRemove, RandomUtil.randomSimpleString());
    ActiveMQBuffer buffer = ActiveMQBuffers.dynamicBuffer(1024);
    props.encode(buffer.byteBuf());
    Assert.assertEquals(props.getEncodeSize(), buffer.writerIndex());
    TypedProperties decodedProps = new TypedProperties();
    decodedProps.decode(buffer.byteBuf());
    TypedPropertiesTest.assertEqualsTypeProperties(props, decodedProps);
    buffer.clear();
    // After removing a property, you should still be able to encode the Property
    props.removeProperty(keyToRemove);
    props.encode(buffer.byteBuf());
    Assert.assertEquals(props.getEncodeSize(), buffer.writerIndex());
}
Also used : SimpleString(org.apache.activemq.artemis.api.core.SimpleString) TypedProperties(org.apache.activemq.artemis.utils.collections.TypedProperties) ActiveMQBuffer(org.apache.activemq.artemis.api.core.ActiveMQBuffer) Test(org.junit.Test)

Aggregations

TypedProperties (org.apache.activemq.artemis.utils.collections.TypedProperties)43 Notification (org.apache.activemq.artemis.core.server.management.Notification)24 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)23 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)8 Test (org.junit.Test)5 ActiveMQInterruptedException (org.apache.activemq.artemis.api.core.ActiveMQInterruptedException)3 ByteBuf (io.netty.buffer.ByteBuf)2 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 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)2 ActiveMQIllegalStateException (org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException)2 ActiveMQNonExistentQueueException (org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException)2 ClusterConnection (org.apache.activemq.artemis.core.server.cluster.ClusterConnection)2 Connection (org.apache.activemq.artemis.spi.core.remoting.Connection)2 ServerBootstrap (io.netty.bootstrap.ServerBootstrap)1 ChannelInitializer (io.netty.channel.ChannelInitializer)1