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. 2016集训测试赛(二十)Problem A: Y队列

    Solution 考虑给定一个\(n\), 如何求\(1\)到\(n\)的正整数中有多少在队列中. 不难注意到我们只需要处理质数次方的情况即可, 因为合数次方会被其因数处理到. 同时我们考虑到可能存在 ...

  2. Data structure basics - Java Implementation

    Stack & Queue Implementations FixedCapacityQueue package cn.edu.tsinghua.stat.mid_term; import j ...

  3. Docking For WPF–AvalonDock

    桌面程序的应用,不可避免的就会用到大量的布局控件,之前的一个项目也想过去做类似于Visual Studio的那种灵活的布局控件,也就是界面上的控件能够实现拖拽放置.隐藏.窗口化等一系列的操作,但由于开 ...

  4. dump_stack的简单使用

    转载:http://blog.csdn.net/sanchuyayun/article/details/39183941 刚刚接触内核,在调试过程中用printk打印信息当然是直接有效的办法,但当我们 ...

  5. 使用Git Gui从Bonobo服务器中克隆Repository(仓库)

    刚开始在使用Git Gui从Bonobo服务器中克隆Repository(仓库)中遇到一些问题,如下图所示: 后来百度,有人遇到类似的问题,得到解决思路,请大家参考这里.大意说出现这个问题是因为要克隆 ...

  6. ArcGIS 开发时,解决__类型“XX”同时存在于“”和“”中__的错误

    错误提示:类型“ESRI.ArcGIS.ADF.BaseClasses.BaseCommand”同时存在于“e:\Program Files\ArcGIS\DeveloperKit10.2\DotNe ...

  7. datasnap——动态注册服务类

    datasnap——动态注册服务类 在DataSnap的应用程序时,我们首先需要注册的服务器类,以提供访问客户端应用程序的服务器方法.通常的做法是使用DSServerClass组件,但有些时候,我们要 ...

  8. Oracle 11gR2 RAC 单网卡 转 双网卡绑定 配置步骤

    之前写过一篇双网卡绑定的文章,如下: Oracle RAC 与 网卡绑定 http://blog.csdn.net/tianlesoftware/article/details/6189639 Ora ...

  9. python logging模块学习(转)

    前言 日志是非常重要的,最近有接触到这个,所以系统的看一下Python这个模块的用法.本文即为Logging模块的用法简介,主要参考文章为Python官方文档,链接见参考列表. 另外,Python的H ...

  10. CLI/C++中混合类的使用【转】

    http://www.cppblog.com/mzty/archive/2007/12/24/39517.html CLI/C++中混合类的使用 一 混合类 所谓混合类是指CLI/C++中native ...