Search in sources :

Example 1 with ProtobufDecoder

use of org.jboss.netty.handler.codec.protobuf.ProtobufDecoder in project opennms by OpenNMS.

the class TcpOutputStrategyTest method setUpClass.

@BeforeClass
public static void setUpClass() {
    // Setup a quick Netty TCP server that decodes the protobuf messages
    // and appends these to a list when received
    ChannelFactory factory = new NioServerSocketChannelFactory();
    ServerBootstrap bootstrap = new ServerBootstrap(factory);
    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {

        public ChannelPipeline getPipeline() {
            return Channels.pipeline(new ProtobufDecoder(PerformanceDataReadings.getDefaultInstance()), new PerfDataServerHandler());
        }
    });
    Channel channel = bootstrap.bind(new InetSocketAddress(0));
    InetSocketAddress addr = (InetSocketAddress) channel.getLocalAddress();
    // Point the TCP exporter to our server
    System.setProperty("org.opennms.rrd.tcp.host", addr.getHostString());
    System.setProperty("org.opennms.rrd.tcp.port", Integer.toString(addr.getPort()));
    // Always use queueing during these tests
    System.setProperty("org.opennms.rrd.usequeue", Boolean.TRUE.toString());
    // Use the temporary folder as the base directory
    System.setProperty("rrd.base.dir", tempFolder.getRoot().getAbsolutePath());
}
Also used : NioServerSocketChannelFactory(org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory) InetSocketAddress(java.net.InetSocketAddress) Channel(org.jboss.netty.channel.Channel) ProtobufDecoder(org.jboss.netty.handler.codec.protobuf.ProtobufDecoder) NioServerSocketChannelFactory(org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory) ChannelFactory(org.jboss.netty.channel.ChannelFactory) ChannelPipelineFactory(org.jboss.netty.channel.ChannelPipelineFactory) ServerBootstrap(org.jboss.netty.bootstrap.ServerBootstrap) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline) BeforeClass(org.junit.BeforeClass)

Example 2 with ProtobufDecoder

use of org.jboss.netty.handler.codec.protobuf.ProtobufDecoder in project Terasology by MovingBlocks.

the class InfoRequestPipelineFactory method getPipeline.

@Override
public ChannelPipeline getPipeline() throws Exception {
    JoinStatusImpl joinStatus = new JoinStatusImpl();
    ChannelPipeline p = Channels.pipeline();
    p.addLast(MetricRecordingHandler.NAME, new MetricRecordingHandler());
    p.addLast("lengthFrameDecoder", new LengthFieldBasedFrameDecoder(8388608, 0, 3, 0, 3));
    p.addLast("inflateDecoder", new ZlibDecoder());
    p.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
    p.addLast("protobufDecoder", new ProtobufDecoder(NetData.NetMessage.getDefaultInstance()));
    p.addLast("frameEncoder", new ProtobufVarint32LengthFieldPrepender());
    p.addLast("protobufEncoder", new ProtobufEncoder());
    p.addLast("authenticationHandler", new ClientHandshakeHandler(joinStatus));
    p.addLast("connectionHandler", new ServerInfoRequestHandler());
    return p;
}
Also used : ProtobufEncoder(org.jboss.netty.handler.codec.protobuf.ProtobufEncoder) ClientHandshakeHandler(org.terasology.network.internal.ClientHandshakeHandler) ZlibDecoder(org.jboss.netty.handler.codec.compression.ZlibDecoder) MetricRecordingHandler(org.terasology.network.internal.MetricRecordingHandler) ProtobufDecoder(org.jboss.netty.handler.codec.protobuf.ProtobufDecoder) ProtobufVarint32LengthFieldPrepender(org.jboss.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender) LengthFieldBasedFrameDecoder(org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder) ProtobufVarint32FrameDecoder(org.jboss.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder) JoinStatusImpl(org.terasology.network.internal.JoinStatusImpl) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline) ServerInfoRequestHandler(org.terasology.network.internal.ServerInfoRequestHandler)

Example 3 with ProtobufDecoder

use of org.jboss.netty.handler.codec.protobuf.ProtobufDecoder in project Terasology by MovingBlocks.

the class TerasologyClientPipelineFactory method getPipeline.

@Override
public ChannelPipeline getPipeline() throws Exception {
    JoinStatusImpl joinStatus = new JoinStatusImpl();
    ChannelPipeline p = pipeline();
    p.addLast(MetricRecordingHandler.NAME, new MetricRecordingHandler());
    p.addLast("lengthFrameDecoder", new LengthFieldBasedFrameDecoder(8388608, 0, 3, 0, 3));
    p.addLast("inflateDecoder", new ZlibDecoder());
    p.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
    p.addLast("protobufDecoder", new ProtobufDecoder(NetData.NetMessage.getDefaultInstance()));
    p.addLast("frameEncoder", new ProtobufVarint32LengthFieldPrepender());
    p.addLast("protobufEncoder", new ProtobufEncoder());
    p.addLast("authenticationHandler", new ClientHandshakeHandler(joinStatus));
    p.addLast("connectionHandler", new ClientConnectionHandler(joinStatus, networkSystem));
    p.addLast("handler", new ClientHandler(networkSystem));
    return p;
}
Also used : ProtobufEncoder(org.jboss.netty.handler.codec.protobuf.ProtobufEncoder) ClientHandshakeHandler(org.terasology.network.internal.ClientHandshakeHandler) ZlibDecoder(org.jboss.netty.handler.codec.compression.ZlibDecoder) MetricRecordingHandler(org.terasology.network.internal.MetricRecordingHandler) ProtobufDecoder(org.jboss.netty.handler.codec.protobuf.ProtobufDecoder) ProtobufVarint32LengthFieldPrepender(org.jboss.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender) ClientHandler(org.terasology.network.internal.ClientHandler) ClientConnectionHandler(org.terasology.network.internal.ClientConnectionHandler) LengthFieldBasedFrameDecoder(org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder) ProtobufVarint32FrameDecoder(org.jboss.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder) JoinStatusImpl(org.terasology.network.internal.JoinStatusImpl) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline)

Example 4 with ProtobufDecoder

use of org.jboss.netty.handler.codec.protobuf.ProtobufDecoder in project Terasology by MovingBlocks.

the class TerasologyServerPipelineFactory method getPipeline.

@Override
public ChannelPipeline getPipeline() throws Exception {
    ChannelPipeline p = pipeline();
    p.addLast(MetricRecordingHandler.NAME, new MetricRecordingHandler());
    p.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
    p.addLast("protobufDecoder", new ProtobufDecoder(NetData.NetMessage.getDefaultInstance()));
    p.addLast("frameLengthEncoder", new LengthFieldPrepender(3));
    p.addLast("deflateEncoder", new ZlibEncoder());
    p.addLast("frameEncoder", new ProtobufVarint32LengthFieldPrepender());
    p.addLast("protobufEncoder", new ProtobufEncoder());
    p.addLast("authenticationHandler", new ServerHandshakeHandler());
    p.addLast("connectionHandler", new ServerConnectionHandler(networkSystem));
    p.addLast("handler", new ServerHandler(networkSystem));
    return p;
}
Also used : ZlibEncoder(org.jboss.netty.handler.codec.compression.ZlibEncoder) ProtobufEncoder(org.jboss.netty.handler.codec.protobuf.ProtobufEncoder) ServerConnectionHandler(org.terasology.network.internal.ServerConnectionHandler) ServerHandshakeHandler(org.terasology.network.internal.ServerHandshakeHandler) MetricRecordingHandler(org.terasology.network.internal.MetricRecordingHandler) ProtobufDecoder(org.jboss.netty.handler.codec.protobuf.ProtobufDecoder) ProtobufVarint32LengthFieldPrepender(org.jboss.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender) ServerHandler(org.terasology.network.internal.ServerHandler) ProtobufVarint32LengthFieldPrepender(org.jboss.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender) LengthFieldPrepender(org.jboss.netty.handler.codec.frame.LengthFieldPrepender) ProtobufVarint32FrameDecoder(org.jboss.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline)

Aggregations

ChannelPipeline (org.jboss.netty.channel.ChannelPipeline)4 ProtobufDecoder (org.jboss.netty.handler.codec.protobuf.ProtobufDecoder)4 ProtobufEncoder (org.jboss.netty.handler.codec.protobuf.ProtobufEncoder)3 ProtobufVarint32FrameDecoder (org.jboss.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder)3 ProtobufVarint32LengthFieldPrepender (org.jboss.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender)3 MetricRecordingHandler (org.terasology.network.internal.MetricRecordingHandler)3 ZlibDecoder (org.jboss.netty.handler.codec.compression.ZlibDecoder)2 LengthFieldBasedFrameDecoder (org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder)2 ClientHandshakeHandler (org.terasology.network.internal.ClientHandshakeHandler)2 JoinStatusImpl (org.terasology.network.internal.JoinStatusImpl)2 InetSocketAddress (java.net.InetSocketAddress)1 ServerBootstrap (org.jboss.netty.bootstrap.ServerBootstrap)1 Channel (org.jboss.netty.channel.Channel)1 ChannelFactory (org.jboss.netty.channel.ChannelFactory)1 ChannelPipelineFactory (org.jboss.netty.channel.ChannelPipelineFactory)1 NioServerSocketChannelFactory (org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory)1 ZlibEncoder (org.jboss.netty.handler.codec.compression.ZlibEncoder)1 LengthFieldPrepender (org.jboss.netty.handler.codec.frame.LengthFieldPrepender)1 BeforeClass (org.junit.BeforeClass)1 ClientConnectionHandler (org.terasology.network.internal.ClientConnectionHandler)1