Search in sources :

Example 1 with RemoteEventException

use of org.xwiki.observation.remote.RemoteEventException in project xwiki-platform by xwiki.

the class JGroupsNetworkAdapter method stopChannel.

@Override
public void stopChannel(String channelId) throws RemoteEventException {
    JChannel channel = this.channels.get(channelId);
    if (channel == null) {
        throw new RemoteEventException(MessageFormat.format("Channel [{0}] is not started", channelId));
    }
    channel.close();
    this.channels.remove(channelId);
    // Unregister the channel from the JMX Server
    try {
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        JmxConfigurator.unregister(channel, mbs, channel.getClusterName());
    } catch (Exception e) {
        this.logger.warn("Failed to unregister channel [" + channelId + "] from the JMX Server", e);
    }
    this.logger.info("Channel [{}] stopped", channelId);
}
Also used : JChannel(org.jgroups.JChannel) RemoteEventException(org.xwiki.observation.remote.RemoteEventException) RemoteEventException(org.xwiki.observation.remote.RemoteEventException) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException) IOException(java.io.IOException) MBeanServer(javax.management.MBeanServer)

Example 2 with RemoteEventException

use of org.xwiki.observation.remote.RemoteEventException in project xwiki-platform by xwiki.

the class DefaultRemoteObservationManager method initialize.

@Override
public void initialize() throws InitializationException {
    try {
        String networkAdapterHint = this.configuration.getNetworkAdapter();
        this.networkAdapter = this.componentManager.getInstance(NetworkAdapter.class, networkAdapterHint);
    } catch (ComponentLookupException e) {
        throw new InitializationException("Failed to initialize network adapter [" + this.configuration.getNetworkAdapter() + "]", e);
    }
    // Start configured channels and register them against the JMX server
    for (String channelId : this.configuration.getChannels()) {
        try {
            startChannel(channelId);
        } catch (RemoteEventException e) {
            this.logger.error("Failed to start channel [" + channelId + "]", e);
        }
    }
}
Also used : NetworkAdapter(org.xwiki.observation.remote.NetworkAdapter) RemoteEventException(org.xwiki.observation.remote.RemoteEventException) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException) InitializationException(org.xwiki.component.phase.InitializationException)

Example 3 with RemoteEventException

use of org.xwiki.observation.remote.RemoteEventException in project xwiki-platform by xwiki.

the class JGroupsNetworkAdapter method startChannel.

@Override
public void startChannel(String channelId) throws RemoteEventException {
    if (this.channels.containsKey(channelId)) {
        throw new RemoteEventException(MessageFormat.format("Channel [{0}] already started", channelId));
    }
    JChannel channel;
    try {
        channel = createChannel(channelId);
        channel.connect("event");
        this.channels.put(channelId, channel);
    } catch (Exception e) {
        throw new RemoteEventException("Failed to create channel [" + channelId + "]", e);
    }
    // Register the channel against the JMX Server
    try {
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        JmxConfigurator.registerChannel(channel, mbs, channel.getClusterName());
    } catch (Exception e) {
        this.logger.warn("Failed to register channel [" + channelId + "] against the JMX Server", e);
    }
    this.logger.info("Channel [{}] started", channelId);
}
Also used : JChannel(org.jgroups.JChannel) RemoteEventException(org.xwiki.observation.remote.RemoteEventException) RemoteEventException(org.xwiki.observation.remote.RemoteEventException) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException) IOException(java.io.IOException) MBeanServer(javax.management.MBeanServer)

Aggregations

ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)3 RemoteEventException (org.xwiki.observation.remote.RemoteEventException)3 IOException (java.io.IOException)2 MBeanServer (javax.management.MBeanServer)2 JChannel (org.jgroups.JChannel)2 InitializationException (org.xwiki.component.phase.InitializationException)1 NetworkAdapter (org.xwiki.observation.remote.NetworkAdapter)1