Search in sources :

Example 1 with ExecutionHandler

use of org.jboss.netty.handler.execution.ExecutionHandler in project Openfire by igniterealtime.

the class ServerPipelineFactory method getPipeline.

public ChannelPipeline getPipeline() throws Exception {
    ChannelPipeline channelpipeline = Channels.pipeline();
    channelpipeline.addLast("pipelineExecutor", new ExecutionHandler(orderedmemoryawarethreadpoolexecutor));
    channelpipeline.addLast("handler", new RtmfpChannelUpstreamHandler(sessions));
    return channelpipeline;
}
Also used : ExecutionHandler(org.jboss.netty.handler.execution.ExecutionHandler)

Example 2 with ExecutionHandler

use of org.jboss.netty.handler.execution.ExecutionHandler in project camel by apache.

the class DefaultServerPipelineFactory method getPipeline.

@Override
public ChannelPipeline getPipeline() throws Exception {
    ChannelPipeline channelPipeline = Channels.pipeline();
    SslHandler sslHandler = configureServerSSLOnDemand();
    if (sslHandler != null) {
        // must close on SSL exception
        sslHandler.setCloseOnSSLException(true);
        LOG.debug("Server SSL handler configured and added as an interceptor against the ChannelPipeline: {}", sslHandler);
        addToPipeline("ssl", channelPipeline, sslHandler);
    }
    List<ChannelHandler> encoders = consumer.getConfiguration().getEncoders();
    for (int x = 0; x < encoders.size(); x++) {
        ChannelHandler encoder = encoders.get(x);
        if (encoder instanceof ChannelHandlerFactory) {
            // use the factory to create a new instance of the channel as it may not be shareable
            encoder = ((ChannelHandlerFactory) encoder).newChannelHandler();
        }
        addToPipeline("encoder-" + x, channelPipeline, encoder);
    }
    List<ChannelHandler> decoders = consumer.getConfiguration().getDecoders();
    for (int x = 0; x < decoders.size(); x++) {
        ChannelHandler decoder = decoders.get(x);
        if (decoder instanceof ChannelHandlerFactory) {
            // use the factory to create a new instance of the channel as it may not be shareable
            decoder = ((ChannelHandlerFactory) decoder).newChannelHandler();
        }
        addToPipeline("decoder-" + x, channelPipeline, decoder);
    }
    if (consumer.getConfiguration().isOrderedThreadPoolExecutor()) {
        // this must be added just before the ServerChannelHandler
        // use ordered thread pool, to ensure we process the events in order, and can send back
        // replies in the expected order. eg this is required by TCP.
        // and use a Camel thread factory so we have consistent thread namings
        ExecutionHandler executionHandler = new ExecutionHandler(consumer.getEndpoint().getComponent().getExecutorService());
        addToPipeline("executionHandler", channelPipeline, executionHandler);
        LOG.debug("Using OrderedMemoryAwareThreadPoolExecutor with core pool size: {}", consumer.getConfiguration().getMaximumPoolSize());
    }
    // our handler must be added last
    addToPipeline("handler", channelPipeline, new ServerChannelHandler(consumer));
    LOG.trace("Created ChannelPipeline: {}", channelPipeline);
    return channelPipeline;
}
Also used : ServerChannelHandler(org.apache.camel.component.netty.handlers.ServerChannelHandler) ExecutionHandler(org.jboss.netty.handler.execution.ExecutionHandler) ServerChannelHandler(org.apache.camel.component.netty.handlers.ServerChannelHandler) ChannelHandler(org.jboss.netty.channel.ChannelHandler) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline) SslHandler(org.jboss.netty.handler.ssl.SslHandler)

Example 3 with ExecutionHandler

use of org.jboss.netty.handler.execution.ExecutionHandler in project camel by apache.

the class HttpServerPipelineFactory method getPipeline.

@Override
public ChannelPipeline getPipeline() throws Exception {
    // Create a default pipeline implementation.
    ChannelPipeline pipeline = Channels.pipeline();
    SslHandler sslHandler = configureServerSSLOnDemand();
    if (sslHandler != null) {
        // must close on SSL exception
        sslHandler.setCloseOnSSLException(true);
        LOG.debug("Server SSL handler configured and added as an interceptor against the ChannelPipeline: {}", sslHandler);
        pipeline.addLast("ssl", sslHandler);
    }
    pipeline.addLast("decoder", new HttpRequestDecoder(4096, configuration.getMaxHeaderSize(), 8192));
    List<ChannelHandler> decoders = consumer.getConfiguration().getDecoders();
    for (int x = 0; x < decoders.size(); x++) {
        ChannelHandler decoder = decoders.get(x);
        if (decoder instanceof ChannelHandlerFactory) {
            // use the factory to create a new instance of the channel as it may not be shareable
            decoder = ((ChannelHandlerFactory) decoder).newChannelHandler();
        }
        pipeline.addLast("decoder-" + x, decoder);
    }
    pipeline.addLast("aggregator", new HttpChunkAggregator(configuration.getChunkedMaxContentLength()));
    pipeline.addLast("encoder", new HttpResponseEncoder());
    List<ChannelHandler> encoders = consumer.getConfiguration().getEncoders();
    for (int x = 0; x < encoders.size(); x++) {
        ChannelHandler encoder = encoders.get(x);
        if (encoder instanceof ChannelHandlerFactory) {
            // use the factory to create a new instance of the channel as it may not be shareable
            encoder = ((ChannelHandlerFactory) encoder).newChannelHandler();
        }
        pipeline.addLast("encoder-" + x, encoder);
    }
    if (supportCompressed()) {
        pipeline.addLast("deflater", new HttpContentCompressor());
    }
    if (consumer.getConfiguration().isOrderedThreadPoolExecutor()) {
        // this must be added just before the HttpServerMultiplexChannelHandler
        // use ordered thread pool, to ensure we process the events in order, and can send back
        // replies in the expected order. eg this is required by TCP.
        // and use a Camel thread factory so we have consistent thread namings
        ExecutionHandler executionHandler = new ExecutionHandler(consumer.getEndpoint().getComponent().getExecutorService());
        pipeline.addLast("executionHandler", executionHandler);
        LOG.debug("Using OrderedMemoryAwareThreadPoolExecutor with core pool size: {}", consumer.getConfiguration().getMaximumPoolSize());
    }
    int port = consumer.getConfiguration().getPort();
    ChannelHandler handler = consumer.getEndpoint().getComponent().getMultiplexChannelHandler(port).getChannelHandler();
    pipeline.addLast("handler", handler);
    return pipeline;
}
Also used : HttpResponseEncoder(org.jboss.netty.handler.codec.http.HttpResponseEncoder) ChannelHandlerFactory(org.apache.camel.component.netty.ChannelHandlerFactory) HttpRequestDecoder(org.jboss.netty.handler.codec.http.HttpRequestDecoder) HttpContentCompressor(org.jboss.netty.handler.codec.http.HttpContentCompressor) HttpChunkAggregator(org.jboss.netty.handler.codec.http.HttpChunkAggregator) ExecutionHandler(org.jboss.netty.handler.execution.ExecutionHandler) ChannelHandler(org.jboss.netty.channel.ChannelHandler) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline) SslHandler(org.jboss.netty.handler.ssl.SslHandler)

Example 4 with ExecutionHandler

use of org.jboss.netty.handler.execution.ExecutionHandler in project bagheera by mozilla-metrics.

the class AccessFilterTest method setup.

@Before
public void setup() throws IOException {
    String[] namespaces = new String[] { "foo_*", "bar" };
    WildcardProperties props = new WildcardProperties();
    String propsFileStr = "foo_*.allow.delete.access=false\n" + "foo_*.id.validation=true\n" + "bar.allow.delete.access=true\n" + "bar.id.validation=false";
    InputStream is = new ByteArrayInputStream(propsFileStr.getBytes("UTF-8"));
    props.load(is);
    filter = new AccessFilter(new Validator(namespaces), props);
    remoteAddr = InetSocketAddress.createUnresolved("192.168.1.1", 51723);
    Channel channel = createMock(Channel.class);
    expect(channel.getCloseFuture()).andReturn(new DefaultChannelFuture(channel, false));
    expect(channel.getRemoteAddress()).andReturn(remoteAddr);
    OrderedMemoryAwareThreadPoolExecutor executor = new OrderedMemoryAwareThreadPoolExecutor(10, 0L, 0L);
    final ExecutionHandler handler = new ExecutionHandler(executor, true, true);
    ctx = new FakeChannelHandlerContext(channel, handler);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) DefaultChannelFuture(org.jboss.netty.channel.DefaultChannelFuture) WildcardProperties(com.mozilla.bagheera.util.WildcardProperties) Channel(org.jboss.netty.channel.Channel) ExecutionHandler(org.jboss.netty.handler.execution.ExecutionHandler) OrderedMemoryAwareThreadPoolExecutor(org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor) Validator(com.mozilla.bagheera.validation.Validator) FakeChannelHandlerContext(org.jboss.netty.channel.FakeChannelHandlerContext) Before(org.junit.Before)

Example 5 with ExecutionHandler

use of org.jboss.netty.handler.execution.ExecutionHandler in project bagheera by mozilla-metrics.

the class ContentLengthFilterTest method setup.

@Before
public void setup() {
    Channel channel = createMock(Channel.class);
    expect(channel.getCloseFuture()).andReturn(new DefaultChannelFuture(channel, false));
    expect(channel.getRemoteAddress()).andReturn(InetSocketAddress.createUnresolved("192.168.1.1", 51723));
    OrderedMemoryAwareThreadPoolExecutor executor = new OrderedMemoryAwareThreadPoolExecutor(10, 0L, 0L);
    final ExecutionHandler handler = new ExecutionHandler(executor, true, true);
    ctx = new FakeChannelHandlerContext(channel, handler);
}
Also used : DefaultChannelFuture(org.jboss.netty.channel.DefaultChannelFuture) Channel(org.jboss.netty.channel.Channel) ExecutionHandler(org.jboss.netty.handler.execution.ExecutionHandler) OrderedMemoryAwareThreadPoolExecutor(org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor) FakeChannelHandlerContext(org.jboss.netty.channel.FakeChannelHandlerContext) Before(org.junit.Before)

Aggregations

ExecutionHandler (org.jboss.netty.handler.execution.ExecutionHandler)5 Channel (org.jboss.netty.channel.Channel)2 ChannelHandler (org.jboss.netty.channel.ChannelHandler)2 ChannelPipeline (org.jboss.netty.channel.ChannelPipeline)2 DefaultChannelFuture (org.jboss.netty.channel.DefaultChannelFuture)2 FakeChannelHandlerContext (org.jboss.netty.channel.FakeChannelHandlerContext)2 OrderedMemoryAwareThreadPoolExecutor (org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor)2 SslHandler (org.jboss.netty.handler.ssl.SslHandler)2 Before (org.junit.Before)2 WildcardProperties (com.mozilla.bagheera.util.WildcardProperties)1 Validator (com.mozilla.bagheera.validation.Validator)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 ChannelHandlerFactory (org.apache.camel.component.netty.ChannelHandlerFactory)1 ServerChannelHandler (org.apache.camel.component.netty.handlers.ServerChannelHandler)1 HttpChunkAggregator (org.jboss.netty.handler.codec.http.HttpChunkAggregator)1 HttpContentCompressor (org.jboss.netty.handler.codec.http.HttpContentCompressor)1 HttpRequestDecoder (org.jboss.netty.handler.codec.http.HttpRequestDecoder)1 HttpResponseEncoder (org.jboss.netty.handler.codec.http.HttpResponseEncoder)1