Search in sources :

Example 1 with NioDatagramChannelFactory

use of org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory 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 NioDatagramChannelFactory

use of org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory 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 NioDatagramChannelFactory

use of org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory 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 NioDatagramChannelFactory

use of org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory 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)

Example 5 with NioDatagramChannelFactory

use of org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory in project camel by apache.

the class NettyProducer method setupUDPCommunication.

protected void setupUDPCommunication() throws Exception {
    if (datagramChannelFactory == null) {
        int count = configuration.getWorkerCount() > 0 ? configuration.getWorkerCount() : NettyHelper.DEFAULT_IO_THREADS;
        workerPool = new NioDatagramWorkerPool(Executors.newCachedThreadPool(), count);
        datagramChannelFactory = new NioDatagramChannelFactory(workerPool);
    }
}
Also used : NioDatagramChannelFactory(org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory) NioDatagramWorkerPool(org.jboss.netty.channel.socket.nio.NioDatagramWorkerPool)

Aggregations

NioDatagramChannelFactory (org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory)11 ConnectionlessBootstrap (org.jboss.netty.bootstrap.ConnectionlessBootstrap)10 ChannelPipeline (org.jboss.netty.channel.ChannelPipeline)4 ChannelPipelineFactory (org.jboss.netty.channel.ChannelPipelineFactory)4 FixedReceiveBufferSizePredictorFactory (org.jboss.netty.channel.FixedReceiveBufferSizePredictorFactory)4 InetSocketAddress (java.net.InetSocketAddress)3 DatagramChannelFactory (org.jboss.netty.channel.socket.DatagramChannelFactory)3 IOException (java.io.IOException)2 NioDatagramWorkerPool (org.jboss.netty.channel.socket.nio.NioDatagramWorkerPool)2 StringDecoder (org.jboss.netty.handler.codec.string.StringDecoder)2 ServerPipelineFactory (com.jcumulus.server.rtmfp.ServerPipelineFactory)1 Sessions (com.jcumulus.server.rtmfp.Sessions)1 ParseException (java.text.ParseException)1 Map (java.util.Map)1 ServerBootstrap (org.jboss.netty.bootstrap.ServerBootstrap)1 ChannelFactory (org.jboss.netty.channel.ChannelFactory)1 FixedReceiveBufferSizePredictor (org.jboss.netty.channel.FixedReceiveBufferSizePredictor)1 NioServerSocketChannelFactory (org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory)1 OrderedMemoryAwareThreadPoolExecutor (org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor)1 IpV4Subnet (org.jboss.netty.handler.ipfilter.IpV4Subnet)1