Package reactor.net.tcp.syslog.hdfs

Examples of reactor.net.tcp.syslog.hdfs.HdfsConsumer


    EventLoopGroup bossGroup = new NioEventLoopGroup(2);
    EventLoopGroup workerGroup = new NioEventLoopGroup(4);

    Configuration conf = new Configuration();
    conf.addResource("/usr/local/Cellar/hadoop/1.1.2/libexec/conf/core-site.xml");
    final HdfsConsumer hdfs = new HdfsConsumer(conf, "loadtests", "syslog");

    ServerBootstrap b = new ServerBootstrap();
    b.group(bossGroup, workerGroup)
     .localAddress(3000)
     .channel(NioServerSocketChannel.class)
     .childHandler(new ChannelInitializer<SocketChannel>() {
       @Override
       public void initChannel(SocketChannel ch) throws Exception {
         ChannelPipeline pipeline = ch.pipeline();
         pipeline.addLast("framer", new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
         pipeline.addLast("decoder", new StringDecoder());
         pipeline.addLast("syslogDecoder", new MessageToMessageDecoder<String>() {
           Function<Buffer, SyslogMessage> decoder = new SyslogCodec().decoder(null);

           @Override
           public void decode(ChannelHandlerContext ctx, String msg, List<Object> messages) throws Exception {
             messages.add(decoder.apply(Buffer.wrap(msg + "\n")));
           }
         });
         pipeline.addLast("handler", new ChannelInboundHandlerAdapter() {

           @Override
           public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
             latch.countDown();
             hdfs.accept((SyslogMessage)msg);
           }
         });
       }
     });
View Full Code Here


  @Ignore
  public void testTcpSyslogServer() throws InterruptedException, IOException {
    //final FileChannelConsumer<SyslogMessage> fcc = new FileChannelConsumer<SyslogMessage>(".", "syslog", -1, -1);
    Configuration conf = new Configuration();
    conf.addResource("/usr/local/Cellar/hadoop/1.1.2/libexec/conf/core-site.xml");
    final HdfsConsumer hdfs = new HdfsConsumer(conf, "loadtests", "syslog");

    TcpServer<SyslogMessage, Void> server = new TcpServerSpec<SyslogMessage, Void>(NettyTcpServer.class)
        .env(env)
            //.using(SynchronousDispatcher.INSTANCE)
            //.dispatcher(Environment.RING_BUFFER_GROUP)
View Full Code Here

TOP

Related Classes of reactor.net.tcp.syslog.hdfs.HdfsConsumer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.