Search in sources :

Example 1 with ConnectionlessBootstrap

use of org.jboss.netty.bootstrap.ConnectionlessBootstrap in project Openfire by igniterealtime.

the class RayoComponent method doStart.

public void doStart() {
    Log.info("RayoComponent initialize " + jid);
    XMPPServer server = XMPPServer.getInstance();
    server.getIQDiscoInfoHandler().addServerFeature(RAYO_CORE);
    rayoProvider = new RayoProvider();
    rayoProvider.setValidator(new Validator());
    server.getIQDiscoInfoHandler().addServerFeature(RAYO_RECORD);
    recordProvider = new RecordProvider();
    recordProvider.setValidator(new Validator());
    server.getIQDiscoInfoHandler().addServerFeature(RAYO_SAY);
    sayProvider = new SayProvider();
    sayProvider.setValidator(new Validator());
    server.getIQDiscoInfoHandler().addServerFeature(RAYO_HANDSET);
    handsetProvider = new HandsetProvider();
    handsetProvider.setValidator(new Validator());
    createIQHandlers();
    try {
        Log.info("Starting jCumulus.....");
        sessions = new Sessions();
        ExecutorService executorservice = Executors.newCachedThreadPool();
        NioDatagramChannelFactory niodatagramchannelfactory = new NioDatagramChannelFactory(executorservice);
        bootstrap = new ConnectionlessBootstrap(niodatagramchannelfactory);
        OrderedMemoryAwareThreadPoolExecutor orderedmemoryawarethreadpoolexecutor = new OrderedMemoryAwareThreadPoolExecutor(10, 0x100000L, 0x40000000L, 100L, TimeUnit.MILLISECONDS, Executors.defaultThreadFactory());
        bootstrap.setPipelineFactory(new ServerPipelineFactory(sessions, orderedmemoryawarethreadpoolexecutor));
        bootstrap.setOption("reuseAddress", Boolean.valueOf(true));
        bootstrap.setOption("sendBufferSize", Integer.valueOf(1215));
        bootstrap.setOption("receiveBufferSize", Integer.valueOf(2048));
        bootstrap.setOption("receiveBufferSizePredictorFactory", new FixedReceiveBufferSizePredictorFactory(2048));
        InetSocketAddress inetsocketaddress = new InetSocketAddress(JiveGlobals.getIntProperty("voicebridge.rtmfp.port", 1935));
        Log.info("Listening on " + inetsocketaddress.getPort() + " port");
        channel = bootstrap.bind(inetsocketaddress);
    } catch (Exception e) {
        Log.error("jCumulus startup failure");
        e.printStackTrace();
    }
}
Also used : Sessions(com.jcumulus.server.rtmfp.Sessions) ComponentException(org.xmpp.component.ComponentException) UnauthorizedException(org.jivesoftware.openfire.auth.UnauthorizedException) GroupNotFoundException(org.jivesoftware.openfire.group.GroupNotFoundException) ParseException(java.text.ParseException) ServerPipelineFactory(com.jcumulus.server.rtmfp.ServerPipelineFactory) XMPPServer(org.jivesoftware.openfire.XMPPServer) NioDatagramChannelFactory(org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory) OrderedMemoryAwareThreadPoolExecutor(org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor) FixedReceiveBufferSizePredictorFactory(org.jboss.netty.channel.FixedReceiveBufferSizePredictorFactory) ConnectionlessBootstrap(org.jboss.netty.bootstrap.ConnectionlessBootstrap)

Example 2 with ConnectionlessBootstrap

use of org.jboss.netty.bootstrap.ConnectionlessBootstrap in project pinpoint by naver.

the class NettyUdpReceiverTest method createUdpServer.

private ConnectionlessBootstrap createUdpServer() {
    DatagramChannelFactory udpFactory = new NioDatagramChannelFactory(Executors.newCachedThreadPool(), 4);
    ChannelPipelineFactory pipelineFactory = new ChannelPipelineFactory() {

        @Override
        public ChannelPipeline getPipeline() throws Exception {
            ChannelPipeline pipeline = Channels.pipeline();
            pipeline.addLast("test", new SimpleChannelHandler() {

                @Override
                public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
                    String name = Thread.currentThread().getName();
                    logger.debug("sleep:{}", name);
                    Thread.sleep(10000);
                    //                        if (!name.equals("New I/O worker #1")) {
                    logger.debug("messageReceived thread-{} message:", Thread.currentThread().getName());
                //                        }
                }
            });
            return pipeline;
        }
    };
    ConnectionlessBootstrap udpBootstrap = new ConnectionlessBootstrap(udpFactory);
    udpBootstrap.setPipelineFactory(pipelineFactory);
    return udpBootstrap;
}
Also used : NioDatagramChannelFactory(org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory) DatagramChannelFactory(org.jboss.netty.channel.socket.DatagramChannelFactory) NioDatagramChannelFactory(org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory) IOException(java.io.IOException) ConnectionlessBootstrap(org.jboss.netty.bootstrap.ConnectionlessBootstrap)

Example 3 with ConnectionlessBootstrap

use of org.jboss.netty.bootstrap.ConnectionlessBootstrap in project graylog2-server by Graylog2.

the class UdpTransport method getBootstrap.

@Override
public Bootstrap getBootstrap() {
    final ConnectionlessBootstrap bootstrap = new ConnectionlessBootstrap(new NioDatagramChannelFactory(workerExecutor));
    final int recvBufferSize = Ints.saturatedCast(getRecvBufferSize());
    LOG.debug("Setting receive buffer size to {} bytes", recvBufferSize);
    bootstrap.setOption("receiveBufferSizePredictorFactory", new FixedReceiveBufferSizePredictorFactory(recvBufferSize));
    bootstrap.setOption("receiveBufferSize", recvBufferSize);
    return bootstrap;
}
Also used : NioDatagramChannelFactory(org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory) FixedReceiveBufferSizePredictorFactory(org.jboss.netty.channel.FixedReceiveBufferSizePredictorFactory) ConnectionlessBootstrap(org.jboss.netty.bootstrap.ConnectionlessBootstrap)

Example 4 with ConnectionlessBootstrap

use of org.jboss.netty.bootstrap.ConnectionlessBootstrap in project graylog2-server by Graylog2.

the class NettyTransport method launch.

@Override
public void launch(final MessageInput input) throws MisfireException {
    final LinkedHashMap<String, Callable<? extends ChannelHandler>> handlerList = getBaseChannelHandlers(input);
    final LinkedHashMap<String, Callable<? extends ChannelHandler>> finalHandlers = getFinalChannelHandlers(input);
    handlerList.putAll(finalHandlers);
    try {
        bootstrap = getBootstrap();
        bootstrap.setPipelineFactory(getPipelineFactory(handlerList));
        // sigh, bindable bootstraps do not share a common interface
        int receiveBufferSize;
        if (bootstrap instanceof ConnectionlessBootstrap) {
            acceptChannel = ((ConnectionlessBootstrap) bootstrap).bind(socketAddress);
            final DefaultDatagramChannelConfig channelConfig = (DefaultDatagramChannelConfig) acceptChannel.getConfig();
            receiveBufferSize = channelConfig.getReceiveBufferSize();
        } else if (bootstrap instanceof ServerBootstrap) {
            acceptChannel = ((ServerBootstrap) bootstrap).bind(socketAddress);
            final ServerSocketChannelConfig channelConfig = (ServerSocketChannelConfig) acceptChannel.getConfig();
            receiveBufferSize = channelConfig.getReceiveBufferSize();
        } else {
            log.error("Unknown Netty bootstrap class returned: {}. Cannot safely bind.", bootstrap);
            throw new IllegalStateException("Unknown netty bootstrap class returned: " + bootstrap + ". Cannot safely bind.");
        }
        if (receiveBufferSize != getRecvBufferSize()) {
            log.warn("receiveBufferSize (SO_RCVBUF) for input {} should be {} but is {}.", input, getRecvBufferSize(), receiveBufferSize);
        }
    } catch (Exception e) {
        throw new MisfireException(e);
    }
}
Also used : MisfireException(org.graylog2.plugin.inputs.MisfireException) SimpleChannelHandler(org.jboss.netty.channel.SimpleChannelHandler) ChannelHandler(org.jboss.netty.channel.ChannelHandler) DefaultDatagramChannelConfig(org.jboss.netty.channel.socket.DefaultDatagramChannelConfig) ServerSocketChannelConfig(org.jboss.netty.channel.socket.ServerSocketChannelConfig) Callable(java.util.concurrent.Callable) ServerBootstrap(org.jboss.netty.bootstrap.ServerBootstrap) MisfireException(org.graylog2.plugin.inputs.MisfireException) ConnectionlessBootstrap(org.jboss.netty.bootstrap.ConnectionlessBootstrap)

Example 5 with ConnectionlessBootstrap

use of org.jboss.netty.bootstrap.ConnectionlessBootstrap in project camel by apache.

the class NettyUdpConnectedSendTest method createNettyUdpReceiver.

public void createNettyUdpReceiver() {
    bootstrap = new ConnectionlessBootstrap(new NioDatagramChannelFactory());
    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {

        @Override
        public ChannelPipeline getPipeline() throws Exception {
            ChannelPipeline channelPipeline = Channels.pipeline();
            channelPipeline.addLast("StringDecoder", new StringDecoder(CharsetUtil.UTF_8));
            channelPipeline.addLast("ContentHandler", new ContentHandler());
            return channelPipeline;
        }
    });
}
Also used : NioDatagramChannelFactory(org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory) StringDecoder(org.jboss.netty.handler.codec.string.StringDecoder) ChannelPipelineFactory(org.jboss.netty.channel.ChannelPipelineFactory) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline) ConnectionlessBootstrap(org.jboss.netty.bootstrap.ConnectionlessBootstrap)

Aggregations

ConnectionlessBootstrap (org.jboss.netty.bootstrap.ConnectionlessBootstrap)61 ChannelPipeline (org.jboss.netty.channel.ChannelPipeline)50 ServerBootstrap (org.jboss.netty.bootstrap.ServerBootstrap)47 TrackerServer (org.traccar.TrackerServer)46 StringEncoder (org.jboss.netty.handler.codec.string.StringEncoder)24 StringDecoder (org.jboss.netty.handler.codec.string.StringDecoder)20 NioDatagramChannelFactory (org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory)10 CharacterDelimiterFrameDecoder (org.traccar.CharacterDelimiterFrameDecoder)10 LengthFieldBasedFrameDecoder (org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder)8 InetSocketAddress (java.net.InetSocketAddress)7 ChannelPipelineFactory (org.jboss.netty.channel.ChannelPipelineFactory)4 FixedReceiveBufferSizePredictorFactory (org.jboss.netty.channel.FixedReceiveBufferSizePredictorFactory)4 LineBasedFrameDecoder (org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder)4 DatagramChannelFactory (org.jboss.netty.channel.socket.DatagramChannelFactory)3 IOException (java.io.IOException)2 Map (java.util.Map)2 Channel (org.jboss.netty.channel.Channel)2 FixedLengthFrameDecoder (org.jboss.netty.handler.codec.frame.FixedLengthFrameDecoder)2 Test (org.junit.Test)2 ServerPipelineFactory (com.jcumulus.server.rtmfp.ServerPipelineFactory)1