码迷,mamicode.com
首页 > Web开发 > 详细

一个spark receiver 或多个spark receiver 接收 多个flume agent

时间:2015-04-08 18:09:37      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:spark

  1. 利用一个spark receiver 接收多个flume agent

String host = args[0];
  int port = Integer.parseInt(args[1]);
  String host1 = args[2];
  int port1 = Integer.parseInt(args[3]);

  InetSocketAddress address1 = new InetSocketAddress(host,port);
  InetSocketAddress address2 = new InetSocketAddress(host1,port1);

  InetSocketAddress[] InetSocketAddressArray = {address1,address2};

JavaStreamingContext jssc = new JavaStreamingContext(new SparkConf().setAppName("JavaFlumeEventHandle_1"), Durations.seconds(2));
 JavaReceiverInputDStream<SparkFlumeEvent> flumeStream = FlumeUtils.createPollingStream(jssc, InetSocketAddressArray, StorageLevel.MEMORY_AND_DISK_SER_2());
  1. 2个spark receiver接收多个flume agent

        String host = args[0];
        int port = Integer.parseInt(args[1]);
        String host1 = args[2];
        int port1 = Integer.parseInt(args[3]);

        InetSocketAddress address1 = new InetSocketAddress(host,port);
        InetSocketAddress address2 = new InetSocketAddress(host1,port1);

        InetSocketAddress[] InetSocketAddressArray = {address1,address2};

      JavaStreamingContext jssc = new JavaStreamingContext(new SparkConf().setAppName("JavaFlumeEventHandle_1"), Durations.seconds(2));
//       JavaReceiverInputDStream<SparkFlumeEvent> flumeStream = FlumeUtils.createPollingStream(jssc, InetSocketAddressArray, StorageLevel.MEMORY_AND_DISK_SER_2());

        JavaReceiverInputDStream<SparkFlumeEvent> flumeStream = FlumeUtils.createPollingStream(jssc,host,port);
        JavaReceiverInputDStream<SparkFlumeEvent> flumeStream1 = FlumeUtils.createPollingStream(jssc, host1, port1);
        JavaDStream<SparkFlumeEvent> union = flumeStream.union(flumeStream1);

性能参照:
http://blog.sina.com.cn/s/blog_13122bdbc0102vay7.html

一个spark receiver 或多个spark receiver 接收 多个flume agent

标签:spark

原文地址:http://blog.csdn.net/kntao/article/details/44943267

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!