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. 笔记-迎难而上之Java基础进阶-终

    使用Stream流的方式,遍历集合 import java.util.*; public class StreamDemo{ public static void main(String[] args ...

  2. http协议中connection头的作用

    在http1.1中request和reponse header中都有可能出现一个connection的头,此header的含义是当client和server通信时对于长链接如何进行处理.   在htt ...

  3. 【redis】redis实现API接口调用调用次数的限制

    redis实现API接口调用调用次数的限制 参考地址:https://bbs.csdn.net/topics/391856106?page=1 参考地址:https://www.cnblogs.com ...

  4. (原创)linux安装xgboost快速高效方法

    1.先安装git ubuntu:   apt-get install git centos:    yum install git 2.下载xgboost仓库,注意有--recursive(有子模块哦 ...

  5. iOS for循环创建button,button的宽度依据上面的文字来自适应.

    近期须要使用一个标签页,寻思自己写一个demo. 标签的大小依据上面的文字来自适应大小,须要依据后台返回的数据自己主动换行.没有加入 NSArray *arr = @[@"无知", ...

  6. Hibernate之load和get的差别

    load和get都会能够起到从数据库中获取持久态数据的作用.可是还有些略微的差别的. 參考以下的这个样例: @Test(expected = IllegalArgumentException.clas ...

  7. Netty通过心跳保持长链接

    Netty自带心跳检测功能,IdleStateHandler,客户端在写空闲时主动发起心跳请求,服务器接受到心跳请求后给出一个心跳响应.当客户端在一定时间范围内不能够给出响应则断开链接. public ...

  8. JAVA_Error initializing endpoint怎么办

    1 运行CMD,输入命令netstat –ano,找到这个TCP,后缀为8080的PID(我的是2660),然后打开任务管理器,在进程选项卡中打开PID查看   2 在右侧的进程窗口找到PID是左侧的 ...

  9. Solidworks拖动装配体的时候物资动力有什么用

    Solidworks物资动力就是模拟真实的场景,你在拖动或旋转零件的时候会和周围的零件碰撞,有相互力的作用. 1 标准拖动   2 碰撞检查   3 选择物资动力(零件上面的黑白相间小圆表示物体重心) ...

  10. Android解析聚合数据之天气预报

    免费天气预报API:https://www.juhe.cn/docs/api/id/73 ,申请APPKEY MainActivity.java <span style="font-s ...