Search in sources :

Example 6 with ChannelHandler

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

the class AbstractTcpTransportTest method getBaseChannelHandlersFailsIfTempDirDoesNotExist.

@Test
public void getBaseChannelHandlersFailsIfTempDirDoesNotExist() throws IOException {
    final File tmpDir = temporaryFolder.newFolder();
    assumeTrue(tmpDir.delete());
    System.setProperty("java.io.tmpdir", tmpDir.getAbsolutePath());
    final Configuration configuration = new Configuration(ImmutableMap.of("bind_address", "localhost", "port", 12345, "tls_enable", true));
    final AbstractTcpTransport transport = new AbstractTcpTransport(configuration, throughputCounter, localRegistry, bossPool, workerPool, connectionCounter) {

        @Override
        protected Bootstrap getBootstrap() {
            return super.getBootstrap();
        }

        @Override
        protected LinkedHashMap<String, Callable<? extends ChannelHandler>> getBaseChannelHandlers(MessageInput input) {
            return super.getBaseChannelHandlers(input);
        }
    };
    expectedException.expect(IllegalStateException.class);
    expectedException.expectMessage("Couldn't write to temporary directory: " + tmpDir.getAbsolutePath());
    transport.getBaseChannelHandlers(input);
}
Also used : Configuration(org.graylog2.plugin.configuration.Configuration) MessageInput(org.graylog2.plugin.inputs.MessageInput) ChannelHandler(org.jboss.netty.channel.ChannelHandler) File(java.io.File) Callable(java.util.concurrent.Callable) Test(org.junit.Test)

Example 7 with ChannelHandler

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

the class AbstractTcpTransportTest method getBaseChannelHandlersFailsIfTempDirIsNotWritable.

@Test
public void getBaseChannelHandlersFailsIfTempDirIsNotWritable() throws IOException {
    final File tmpDir = temporaryFolder.newFolder();
    assumeTrue(tmpDir.setWritable(false));
    assumeFalse(tmpDir.canWrite());
    System.setProperty("java.io.tmpdir", tmpDir.getAbsolutePath());
    final Configuration configuration = new Configuration(ImmutableMap.of("bind_address", "localhost", "port", 12345, "tls_enable", true));
    final AbstractTcpTransport transport = new AbstractTcpTransport(configuration, throughputCounter, localRegistry, bossPool, workerPool, connectionCounter) {

        @Override
        protected Bootstrap getBootstrap() {
            return super.getBootstrap();
        }

        @Override
        protected LinkedHashMap<String, Callable<? extends ChannelHandler>> getBaseChannelHandlers(MessageInput input) {
            return super.getBaseChannelHandlers(input);
        }
    };
    expectedException.expect(IllegalStateException.class);
    expectedException.expectMessage("Couldn't write to temporary directory: " + tmpDir.getAbsolutePath());
    transport.getBaseChannelHandlers(input);
}
Also used : Configuration(org.graylog2.plugin.configuration.Configuration) MessageInput(org.graylog2.plugin.inputs.MessageInput) ChannelHandler(org.jboss.netty.channel.ChannelHandler) File(java.io.File) Callable(java.util.concurrent.Callable) Test(org.junit.Test)

Example 8 with ChannelHandler

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

the class AbstractTcpTransportTest method getBaseChannelHandlersGeneratesSelfSignedCertificates.

@Test
public void getBaseChannelHandlersGeneratesSelfSignedCertificates() {
    final Configuration configuration = new Configuration(ImmutableMap.of("bind_address", "localhost", "port", 12345, "tls_enable", true));
    final AbstractTcpTransport transport = new AbstractTcpTransport(configuration, throughputCounter, localRegistry, bossPool, workerPool, connectionCounter) {

        @Override
        protected Bootstrap getBootstrap() {
            return super.getBootstrap();
        }

        @Override
        protected LinkedHashMap<String, Callable<? extends ChannelHandler>> getBaseChannelHandlers(MessageInput input) {
            return super.getBaseChannelHandlers(input);
        }
    };
    final MessageInput input = mock(MessageInput.class);
    assertThat(transport.getBaseChannelHandlers(input)).containsKey("tls");
}
Also used : Configuration(org.graylog2.plugin.configuration.Configuration) MessageInput(org.graylog2.plugin.inputs.MessageInput) ChannelHandler(org.jboss.netty.channel.ChannelHandler) Callable(java.util.concurrent.Callable) Test(org.junit.Test)

Example 9 with ChannelHandler

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

the class AbstractTcpTransportTest method getBaseChannelHandlersFailsIfTempDirIsNoDirectory.

@Test
public void getBaseChannelHandlersFailsIfTempDirIsNoDirectory() throws IOException {
    final File file = temporaryFolder.newFile();
    assumeTrue(file.isFile());
    System.setProperty("java.io.tmpdir", file.getAbsolutePath());
    final Configuration configuration = new Configuration(ImmutableMap.of("bind_address", "localhost", "port", 12345, "tls_enable", true));
    final AbstractTcpTransport transport = new AbstractTcpTransport(configuration, throughputCounter, localRegistry, bossPool, workerPool, connectionCounter) {

        @Override
        protected Bootstrap getBootstrap() {
            return super.getBootstrap();
        }

        @Override
        protected LinkedHashMap<String, Callable<? extends ChannelHandler>> getBaseChannelHandlers(MessageInput input) {
            return super.getBaseChannelHandlers(input);
        }
    };
    expectedException.expect(IllegalStateException.class);
    expectedException.expectMessage("Couldn't write to temporary directory: " + file.getAbsolutePath());
    transport.getBaseChannelHandlers(input);
}
Also used : Configuration(org.graylog2.plugin.configuration.Configuration) MessageInput(org.graylog2.plugin.inputs.MessageInput) ChannelHandler(org.jboss.netty.channel.ChannelHandler) File(java.io.File) Callable(java.util.concurrent.Callable) Test(org.junit.Test)

Example 10 with ChannelHandler

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

the class MultipleCodecsTest method createRegistry.

@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry registry = super.createRegistry();
    // START SNIPPET: registry-beans
    ChannelHandlerFactory lengthDecoder = ChannelHandlerFactories.newLengthFieldBasedFrameDecoder(1048576, 0, 4, 0, 4);
    StringDecoder stringDecoder = new StringDecoder();
    registry.bind("length-decoder", lengthDecoder);
    registry.bind("string-decoder", stringDecoder);
    LengthFieldPrepender lengthEncoder = new LengthFieldPrepender(4);
    StringEncoder stringEncoder = new StringEncoder();
    registry.bind("length-encoder", lengthEncoder);
    registry.bind("string-encoder", stringEncoder);
    List<ChannelHandler> decoders = new ArrayList<ChannelHandler>();
    decoders.add(lengthDecoder);
    decoders.add(stringDecoder);
    List<ChannelHandler> encoders = new ArrayList<ChannelHandler>();
    encoders.add(lengthEncoder);
    encoders.add(stringEncoder);
    registry.bind("encoders", encoders);
    registry.bind("decoders", decoders);
    // END SNIPPET: registry-beans
    return registry;
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) StringEncoder(org.jboss.netty.handler.codec.string.StringEncoder) ArrayList(java.util.ArrayList) StringDecoder(org.jboss.netty.handler.codec.string.StringDecoder) ChannelHandler(org.jboss.netty.channel.ChannelHandler) LengthFieldPrepender(org.jboss.netty.handler.codec.frame.LengthFieldPrepender)

Aggregations

ChannelHandler (org.jboss.netty.channel.ChannelHandler)30 Callable (java.util.concurrent.Callable)12 ChannelPipeline (org.jboss.netty.channel.ChannelPipeline)9 ArrayList (java.util.ArrayList)5 MessageInput (org.graylog2.plugin.inputs.MessageInput)5 SimpleChannelHandler (org.jboss.netty.channel.SimpleChannelHandler)5 SslHandler (org.jboss.netty.handler.ssl.SslHandler)5 ReadTimeoutHandler (org.jboss.netty.handler.timeout.ReadTimeoutHandler)5 File (java.io.File)4 InetSocketAddress (java.net.InetSocketAddress)4 SocketAddress (java.net.SocketAddress)4 Configuration (org.graylog2.plugin.configuration.Configuration)4 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)4 Channel (org.jboss.netty.channel.Channel)4 Test (org.junit.Test)4 NettyHttpDatabusRelayConnection (com.linkedin.databus.client.netty.NettyHttpDatabusRelayConnection)3 NettyHttpDatabusRelayConnectionInspector (com.linkedin.databus.client.netty.NettyHttpDatabusRelayConnectionInspector)3 Checkpoint (com.linkedin.databus.core.Checkpoint)3 DbusEventBuffer (com.linkedin.databus.core.DbusEventBuffer)3 DbusEventInfo (com.linkedin.databus.core.DbusEventInfo)3