Search in sources :

Example 1 with FixedReceiveBufferSizePredictorFactory

use of org.jboss.netty.channel.FixedReceiveBufferSizePredictorFactory 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 FixedReceiveBufferSizePredictorFactory

use of org.jboss.netty.channel.FixedReceiveBufferSizePredictorFactory 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 3 with FixedReceiveBufferSizePredictorFactory

use of org.jboss.netty.channel.FixedReceiveBufferSizePredictorFactory in project graylog2-server by Graylog2.

the class AbstractTcpTransport method getBootstrap.

@Override
protected Bootstrap getBootstrap() {
    final ServerBootstrap bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(bossExecutor, workerExecutor));
    bootstrap.setOption("receiveBufferSizePredictorFactory", new FixedReceiveBufferSizePredictorFactory(8192));
    bootstrap.setOption("receiveBufferSize", getRecvBufferSize());
    bootstrap.setOption("child.receiveBufferSize", getRecvBufferSize());
    bootstrap.setOption("child.keepAlive", tcpKeepalive);
    return bootstrap;
}
Also used : NioServerSocketChannelFactory(org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory) FixedReceiveBufferSizePredictorFactory(org.jboss.netty.channel.FixedReceiveBufferSizePredictorFactory) ServerBootstrap(org.jboss.netty.bootstrap.ServerBootstrap)

Example 4 with FixedReceiveBufferSizePredictorFactory

use of org.jboss.netty.channel.FixedReceiveBufferSizePredictorFactory in project camel by apache.

the class SingleUDPNettyServerBootstrapFactory method startServerBootstrap.

protected void startServerBootstrap() throws Exception {
    // create non-shared worker pool
    int count = configuration.getWorkerCount() > 0 ? configuration.getWorkerCount() : NettyHelper.DEFAULT_IO_THREADS;
    workerPool = new NioDatagramWorkerPool(Executors.newCachedThreadPool(), count);
    datagramChannelFactory = new NioDatagramChannelFactory(workerPool);
    connectionlessBootstrap = new ConnectionlessBootstrap(datagramChannelFactory);
    connectionlessBootstrap.setOption("child.keepAlive", configuration.isKeepAlive());
    connectionlessBootstrap.setOption("child.tcpNoDelay", configuration.isTcpNoDelay());
    connectionlessBootstrap.setOption("reuseAddress", configuration.isReuseAddress());
    connectionlessBootstrap.setOption("child.reuseAddress", configuration.isReuseAddress());
    connectionlessBootstrap.setOption("child.connectTimeoutMillis", configuration.getConnectTimeout());
    connectionlessBootstrap.setOption("child.broadcast", configuration.isBroadcast());
    connectionlessBootstrap.setOption("sendBufferSize", configuration.getSendBufferSize());
    connectionlessBootstrap.setOption("receiveBufferSize", configuration.getReceiveBufferSize());
    // only set this if user has specified
    if (configuration.getReceiveBufferSizePredictor() > 0) {
        connectionlessBootstrap.setOption("receiveBufferSizePredictorFactory", new FixedReceiveBufferSizePredictorFactory(configuration.getReceiveBufferSizePredictor()));
    }
    if (configuration.getBacklog() > 0) {
        connectionlessBootstrap.setOption("backlog", configuration.getBacklog());
    }
    // set any additional netty options
    if (configuration.getOptions() != null) {
        for (Map.Entry<String, Object> entry : configuration.getOptions().entrySet()) {
            connectionlessBootstrap.setOption(entry.getKey(), entry.getValue());
        }
    }
    LOG.debug("Created ConnectionlessBootstrap {} with options: {}", connectionlessBootstrap, connectionlessBootstrap.getOptions());
    // set the pipeline factory, which creates the pipeline for each newly created channels
    connectionlessBootstrap.setPipelineFactory(pipelineFactory);
    InetSocketAddress hostAddress = new InetSocketAddress(configuration.getHost(), configuration.getPort());
    IpV4Subnet multicastSubnet = new IpV4Subnet(MULTICAST_SUBNET);
    if (multicastSubnet.contains(configuration.getHost())) {
        datagramChannel = (DatagramChannel) connectionlessBootstrap.bind(hostAddress);
        String networkInterface = configuration.getNetworkInterface() == null ? LOOPBACK_INTERFACE : configuration.getNetworkInterface();
        multicastNetworkInterface = NetworkInterface.getByName(networkInterface);
        ObjectHelper.notNull(multicastNetworkInterface, "No network interface found for '" + networkInterface + "'.");
        LOG.info("ConnectionlessBootstrap joining {}:{} using network interface: {}", new Object[] { configuration.getHost(), configuration.getPort(), multicastNetworkInterface.getName() });
        datagramChannel.joinGroup(hostAddress, multicastNetworkInterface).syncUninterruptibly();
        allChannels.add(datagramChannel);
    } else {
        LOG.info("ConnectionlessBootstrap binding to {}:{}", configuration.getHost(), configuration.getPort());
        channel = connectionlessBootstrap.bind(hostAddress);
        allChannels.add(channel);
    }
}
Also used : NioDatagramChannelFactory(org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory) InetSocketAddress(java.net.InetSocketAddress) NioDatagramWorkerPool(org.jboss.netty.channel.socket.nio.NioDatagramWorkerPool) FixedReceiveBufferSizePredictorFactory(org.jboss.netty.channel.FixedReceiveBufferSizePredictorFactory) Map(java.util.Map) IpV4Subnet(org.jboss.netty.handler.ipfilter.IpV4Subnet) ConnectionlessBootstrap(org.jboss.netty.bootstrap.ConnectionlessBootstrap)

Aggregations

FixedReceiveBufferSizePredictorFactory (org.jboss.netty.channel.FixedReceiveBufferSizePredictorFactory)4 ConnectionlessBootstrap (org.jboss.netty.bootstrap.ConnectionlessBootstrap)3 NioDatagramChannelFactory (org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory)3 ServerPipelineFactory (com.jcumulus.server.rtmfp.ServerPipelineFactory)1 Sessions (com.jcumulus.server.rtmfp.Sessions)1 InetSocketAddress (java.net.InetSocketAddress)1 ParseException (java.text.ParseException)1 Map (java.util.Map)1 ServerBootstrap (org.jboss.netty.bootstrap.ServerBootstrap)1 NioDatagramWorkerPool (org.jboss.netty.channel.socket.nio.NioDatagramWorkerPool)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 XMPPServer (org.jivesoftware.openfire.XMPPServer)1 UnauthorizedException (org.jivesoftware.openfire.auth.UnauthorizedException)1 GroupNotFoundException (org.jivesoftware.openfire.group.GroupNotFoundException)1 ComponentException (org.xmpp.component.ComponentException)1