import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Random; import org.apache.flume.Context;
import org.apache.flume.EventDeliveryException;
import org.apache.flume.PollableSource;
import org.apache.flume.conf.Configurable;
import org.apache.flume.event.EventBuilder;
import org.apache.flume.source.AbstractSource; public class MySouce extends AbstractSource implements Configurable,
PollableSource { @Override
public long getBackOffSleepIncrement() {
// TODO Auto-generated method stub
return 0;
} @Override
public long getMaxBackOffSleepInterval() {
// TODO Auto-generated method stub
return 0;
} @Override
public Status process() throws EventDeliveryException {
try { while (true) { int max = 20; int min = 10; Random random = new Random(); int s = random.nextInt(max) % (max - min + 1) + min; HashMap<String, String> header = new HashMap<String, String>(); header.put("id", Integer.toString(s)); this.getChannelProcessor().processEvent(
EventBuilder.withBody(Integer.toString(s),
Charset.forName("UTF-8"), header));
Thread.sleep(1000);
} } catch (InterruptedException e) { e.printStackTrace(); }
return null;
} @Override
public void configure(Context arg0) {
// TODO Auto-generated method stub } }

Hadoop实战-Flume之自定义Source(十八)的更多相关文章

  1. Hadoop实战-Flume之自定义Sink(十九)

    import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import j ...

  2. Hadoop实战-Flume之Sink Failover(十六)

    a1.sources = r1 a1.sinks = k1 k2 a1.channels = c1 # Describe/configure the source a1.sources.r1.type ...

  3. Hadoop实战-Flume之Hdfs Sink(十)

    a1.sources = r1 a1.sinks = k1 a1.channels = c1 # Describe/configure the source a1.sources.r1.type = ...

  4. Hadoop生态圈-Flume的主流source源配置

    Hadoop生态圈-Flume的主流source源配置 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 本篇博客只是配置的是Flume主流的Source,想要了解更详细的配置信息请参 ...

  5. Hadoop实战-Flume之Source multiplexing(十五)

    a1.sources = r1 a1.sinks = k1 k2 a1.channels = c1 c2 # Describe/configure the source a1.sources.r1.t ...

  6. Hadoop实战-Flume之Source replicating(十四)

    a1.sources = r1 a1.sinks = k1 k2 a1.channels = c1 c2 # Describe/configure the source a1.sources.r1.t ...

  7. Hadoop实战-Flume之Source regex_extractor(十二)

    a1.sources = r1 a1.sinks = k1 a1.channels = c1 # Describe/configure the source a1.sources.r1.type = ...

  8. Hadoop实战-Flume之Source regex_filter(十三)

    a1.sources = r1 a1.sinks = k1 a1.channels = c1 # Describe/configure the source a1.sources.r1.type = ...

  9. Hadoop实战-Flume之Source interceptor(十一)(2017-05-16 22:40)

    a1.sources = r1 a1.sinks = k1 a1.channels = c1 # Describe/configure the source a1.sources.r1.type = ...

随机推荐

  1. centos 7 mysql 离线安装教程

    1. 解压下载的zip包,会发现有以下几个rpm包: MySQL-client-advanced-5.6.22-1.el7.x86_64.rpm MySQL-devel-advanced-5.6.22 ...

  2. 某考试 T2 Seg

    Seg [问题描述]数轴上有n条线段,第i条线段的左端点是a[i],右端点是b[i].Bob发现1~2n共2n个整数点,每个点都是某条线段的端点.这些线段有如下两类特点:1 x y,表示第x条线段和第 ...

  3. ETL之Kettle

    Kettle是一款国外开源的ETL工具,纯java编写,可以在Window.Linux.Unix上运行. 说白了就是,很有必要去理解一般ETL工具必备的特性和功能,这样才更好的掌握Kettle的使用. ...

  4. 模型搭建练习1_用numpy和tensor、variable实现前后向传播、实现激活函数

    用numpy实现搭建一个简单的forward和backward import numpy as np N, D_in, H, D_out = 64, 1000, 100, 10 x = np.rand ...

  5. 【POI】导出xls文件报错:The maximum number of cell styles was exceeded. You can define up to 4000 styles in a .xls workbook

    使用POI导出xls文件,由于数据过多,导致导出xls报错如下: The maximum number of cell styles was exceeded. You can define up t ...

  6. ajax跨域解决办法

    在使用jquery的ajax作请求时,http://127.0.0.1:8080,类似这样的一个本地请求,会产生跨域问题, 解决办法一: jsonp: var url= "http://12 ...

  7. 2017.2.21 activiti实战--第十三章--流量数据查询与跟踪(一)查询接口介绍及运行时数据查询

    学习资料:<Activiti实战> 第十三章 流量数据查询与跟踪 本章讲解运行时与历史数据的查询方法.主要包含三种:标准查询,Native查询,CustomSql查询. 13.1 Quer ...

  8. HDU 4927 大数

    题意非常easy: 对于长度为n的数.做n-1遍.生成的新数列: b1=a2-a1   b2=a3-a2  b3=a4-a3 c1=b2-b1   c2=b3-b2 ans=c2-c1 最后推出公式: ...

  9. HDU 4746 Mophues (莫比乌斯反演应用)

    Mophues Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 327670/327670 K (Java/Others) Total ...

  10. JDK5新特性之线程同步工具类(三)

    一. Semaphore Semaphore能够控制同一时候訪问资源的线程个数, 比如: 实现一个文件同意的并发訪问数. Semaphore实现的功能就类似厕全部5个坑, 增加有十个人要上厕所, 那么 ...