Search in sources :

Example 91 with ChannelPipeline

use of org.jboss.netty.channel.ChannelPipeline in project cdap by caskdata.

the class ClientChannelPipelineFactory method getPipeline.

@Override
public ChannelPipeline getPipeline() throws Exception {
    ChannelPipeline pipeline = Channels.pipeline();
    pipeline.addLast("tracker", connectionTracker);
    pipeline.addLast("request-encoder", new HttpRequestEncoder());
    // outbound handler gets dynamically added here (after 'request-encoder')
    pipeline.addLast("response-decoder", new HttpResponseDecoder());
    // disable the read-specific and write-specific timeouts; we only utilize IdleState#ALL_IDLE
    pipeline.addLast("idle-event-generator", new IdleStateHandler(timer, 0, 0, connectionTimeout));
    pipeline.addLast("idle-event-processor", new IdleEventProcessor());
    return pipeline;
}
Also used : IdleEventProcessor(co.cask.cdap.gateway.router.handlers.IdleEventProcessor) IdleStateHandler(org.jboss.netty.handler.timeout.IdleStateHandler) HttpRequestEncoder(org.jboss.netty.handler.codec.http.HttpRequestEncoder) HttpResponseDecoder(org.jboss.netty.handler.codec.http.HttpResponseDecoder) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline)

Example 92 with ChannelPipeline

use of org.jboss.netty.channel.ChannelPipeline in project opennms by OpenNMS.

the class AsyncBasicDetectorNettyImpl method isServiceDetected.

/**
 * {@inheritDoc}
 */
@Override
public final DetectFuture isServiceDetected(final InetAddress address) {
    DetectFuture detectFuture = new DetectFutureFailedImpl(this, new IllegalStateException());
    try {
        ClientBootstrap bootstrap = new ClientBootstrap(m_factory);
        bootstrap.setPipelineFactory(new ChannelPipelineFactory() {

            @Override
            public ChannelPipeline getPipeline() throws Exception {
                ChannelPipeline retval = Channels.pipeline();
                // Upstream handlers
                // retval.addLast("retryHandler", new RetryChannelHandler());
                appendToPipeline(retval);
                // Downstream handlers
                retval.addLast("detectorHandler", getDetectorHandler(getConversation()));
                if (isUseSSLFilter()) {
                    // Use a relaxed SSL context
                    retval.addLast("sslHandler", new SslHandler(createClientSSLContext().createSSLEngine()));
                }
                return retval;
            }
        });
        bootstrap.setOption("tcpNoDelay", true);
        bootstrap.setOption("keepAlive", true);
        SocketAddress remoteAddress = new InetSocketAddress(address, getPort());
        ChannelFuture future = bootstrap.connect(remoteAddress);
        future.addListener(new RetryChannelFutureListener(remoteAddress, this.getRetries()));
        detectFuture = new DetectFutureNettyImpl(this, future);
    } catch (Throwable e) {
        detectFuture = new DetectFutureFailedImpl(this, e);
    }
    return detectFuture;
}
Also used : ChannelFuture(org.jboss.netty.channel.ChannelFuture) InetSocketAddress(java.net.InetSocketAddress) IOException(java.io.IOException) KeyManagementException(java.security.KeyManagementException) ServiceDetectionFailedException(org.opennms.netmgt.provision.support.DetectFutureNettyImpl.ServiceDetectionFailedException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline) SslHandler(org.jboss.netty.handler.ssl.SslHandler) DetectFuture(org.opennms.netmgt.provision.DetectFuture) ClientBootstrap(org.jboss.netty.bootstrap.ClientBootstrap) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) ChannelPipelineFactory(org.jboss.netty.channel.ChannelPipelineFactory)

Example 93 with ChannelPipeline

use of org.jboss.netty.channel.ChannelPipeline in project NabAlive by jcheype.

the class HttpApiServerPipelineFactory method getPipeline.

@Override
public ChannelPipeline getPipeline() throws Exception {
    ChannelPipeline pipeline = pipeline();
    // Uncomment the following line if you want HTTPS
    //        SSLEngine engine = //SecureChatSslContextFactory.getServerContext().createSSLEngine();
    //        engine.setUseClientMode(false);
    //        pipeline.addLast("ssl", new SslHandler(engine));
    pipeline.addLast("timeout", new IdleStateHandler(timer, 0, 0, 20));
    pipeline.addLast("decoder", new HttpRequestDecoder());
    pipeline.addLast("encoder", new HttpResponseEncoder());
    //        pipeline.addLast("comressor", new HttpContentCompressor(9));
    pipeline.addLast("aggregator", new HttpChunkAggregator(65536));
    pipeline.addLast("chunkedWriter", new ChunkedWriteHandler());
    //pipeline.addLast("executor", eh);
    pipeline.addLast("handler", handler);
    return pipeline;
}
Also used : ChunkedWriteHandler(org.jboss.netty.handler.stream.ChunkedWriteHandler) IdleStateHandler(org.jboss.netty.handler.timeout.IdleStateHandler) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline)

Example 94 with ChannelPipeline

use of org.jboss.netty.channel.ChannelPipeline in project NabAlive by jcheype.

the class NabaliveServer method start.

@PostConstruct
public void start() {
    logger.info("Starting server.");
    // Configure the server.
    bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));
    // Set up the pipeline factory.
    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {

        public ChannelPipeline getPipeline() throws Exception {
            ChannelPipeline pipeline = pipeline();
            pipeline.addLast("timeout", new IdleStateHandler(timer, 0, 0, 20));
            pipeline.addLast("nabaliveServerHandler", nabaliveServerHandler);
            return pipeline;
        }
    });
    bootstrap.setOption("reuseAddress", true);
    // Bind and start to accept incoming connections.
    bind = bootstrap.bind(new InetSocketAddress(XMPP_PORT));
}
Also used : NioServerSocketChannelFactory(org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory) InetSocketAddress(java.net.InetSocketAddress) IdleStateHandler(org.jboss.netty.handler.timeout.IdleStateHandler) ChannelPipelineFactory(org.jboss.netty.channel.ChannelPipelineFactory) ServerBootstrap(org.jboss.netty.bootstrap.ServerBootstrap) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline) PostConstruct(javax.annotation.PostConstruct)

Example 95 with ChannelPipeline

use of org.jboss.netty.channel.ChannelPipeline in project bigbluebutton by bigbluebutton.

the class AbstractOutboundPipelineFactory method getPipeline.

public ChannelPipeline getPipeline() throws Exception {
    ChannelPipeline pipeline = Channels.pipeline();
    // Add the text line codec combination first
    pipeline.addLast("encoder", new StringEncoder());
    // Note that outbound mode requires the decoder to treat many 'headers' as body lines
    pipeline.addLast("decoder", new EslFrameDecoder(8092, true));
    // Add an executor to ensure separate thread for each upstream message from here
    pipeline.addLast("executor", new ExecutionHandler(new OrderedMemoryAwareThreadPoolExecutor(16, 1048576, 1048576)));
    // now the outbound client logic
    pipeline.addLast("clientHandler", makeHandler());
    return pipeline;
}
Also used : StringEncoder(org.jboss.netty.handler.codec.string.StringEncoder) EslFrameDecoder(org.freeswitch.esl.client.transport.message.EslFrameDecoder) ExecutionHandler(org.freeswitch.esl.client.internal.debug.ExecutionHandler) OrderedMemoryAwareThreadPoolExecutor(org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline)

Aggregations

ChannelPipeline (org.jboss.netty.channel.ChannelPipeline)165 ServerBootstrap (org.jboss.netty.bootstrap.ServerBootstrap)58 TrackerServer (org.traccar.TrackerServer)43 InetSocketAddress (java.net.InetSocketAddress)37 ChannelPipelineFactory (org.jboss.netty.channel.ChannelPipelineFactory)32 ConnectionlessBootstrap (org.jboss.netty.bootstrap.ConnectionlessBootstrap)26 Channel (org.jboss.netty.channel.Channel)26 SimpleObjectCaptureHandler (com.linkedin.databus2.test.container.SimpleObjectCaptureHandler)24 SocketAddress (java.net.SocketAddress)20 StringEncoder (org.jboss.netty.handler.codec.string.StringEncoder)18 SimpleTestServerConnection (com.linkedin.databus2.test.container.SimpleTestServerConnection)17 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)16 NioServerSocketChannelFactory (org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory)16 HttpRequest (org.jboss.netty.handler.codec.http.HttpRequest)16 HttpResponse (org.jboss.netty.handler.codec.http.HttpResponse)16 HttpResponseEncoder (org.jboss.netty.handler.codec.http.HttpResponseEncoder)16 DefaultHttpResponse (org.jboss.netty.handler.codec.http.DefaultHttpResponse)15 HttpRequestDecoder (org.jboss.netty.handler.codec.http.HttpRequestDecoder)15 StringDecoder (org.jboss.netty.handler.codec.string.StringDecoder)14 LoggingHandler (org.jboss.netty.handler.logging.LoggingHandler)14