Hadoop实战-Flume之自定义Source(十八)
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(十八)的更多相关文章
- Hadoop实战-Flume之自定义Sink(十九)
import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import j ...
- Hadoop实战-Flume之Sink Failover(十六)
a1.sources = r1 a1.sinks = k1 k2 a1.channels = c1 # Describe/configure the source a1.sources.r1.type ...
- Hadoop实战-Flume之Hdfs Sink(十)
a1.sources = r1 a1.sinks = k1 a1.channels = c1 # Describe/configure the source a1.sources.r1.type = ...
- Hadoop生态圈-Flume的主流source源配置
Hadoop生态圈-Flume的主流source源配置 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 本篇博客只是配置的是Flume主流的Source,想要了解更详细的配置信息请参 ...
- Hadoop实战-Flume之Source multiplexing(十五)
a1.sources = r1 a1.sinks = k1 k2 a1.channels = c1 c2 # Describe/configure the source a1.sources.r1.t ...
- Hadoop实战-Flume之Source replicating(十四)
a1.sources = r1 a1.sinks = k1 k2 a1.channels = c1 c2 # Describe/configure the source a1.sources.r1.t ...
- Hadoop实战-Flume之Source regex_extractor(十二)
a1.sources = r1 a1.sinks = k1 a1.channels = c1 # Describe/configure the source a1.sources.r1.type = ...
- Hadoop实战-Flume之Source regex_filter(十三)
a1.sources = r1 a1.sinks = k1 a1.channels = c1 # Describe/configure the source a1.sources.r1.type = ...
- 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 = ...
随机推荐
- RAID 1-6
RAID 0 RAID 0亦称为带区集.它将两个以上的磁盘串联起来,成为一个大容量的磁盘.在存放数据时,分段后分散存储在这些磁盘中,因为读写时都可以并行处理,所以在所有的级别中,RAID 0的速度是最 ...
- 【Kafka】《Kafka权威指南》——分区partition
在上篇的例子里([Kafka]<Kafka权威指南>--写数据), ProducerRecord 对象包含了目标主题.键和值. Kafka 的消息是 一个个 键值对, ProducerRe ...
- django admin页面样式丢失问题
wamp 配置django admin页面样式丢失问题 第一种方法:在apache配置文件httpd.conf中加入如下代码:Alias /static "E:\Python27\Lib\s ...
- Android 项目开发实战:聚合数据短信验证码
聚合数据集成短信验证码官网: https://www.juhe.cn/docs/api/id/54 我根据文档集成了一个例子 效果: 源码下载:http://download.csdn.net/det ...
- 【Android实战】Gallary+ImageSwicther图片查看器
仿照如今各大新闻站点图片新闻的浏览模式,上面展示详细图片(ImageSwitch),以下是能够滑动的小图片(Gallery). 当中须要注意的是ImageSwitch须要定义一个工厂返回的组件,而且能 ...
- PropertiesTest
import java.io.FileInputStream; import java.io.IOException; import java.util.Properties; public clas ...
- .net 定时执行 windows 服务
1.新建项目 --> Windows 服务 2.Service1.cs代码 using System; using System.Collections.Generic; using Syste ...
- VueJS自定义过滤器:new Vue({filters:{filter1:function(){}....}})
Vue.js 允许你自定义过滤器,被用作一些常见的文本格式化. 语法 <!-- 在两个大括号中 --> {{ message | capitalize }} <!-- 在 v-bin ...
- idea设置自定义图片
看图操作哈: 1. 2. 逼格满满:
- SpringMVC hibernate增加多数据源 (SSHE/SYPRO增加多数据源为例)
SpringMVC hibernate增加多数据源 (以类SSHE/SYPRO增加多数据源为例作说明) 注:适用与SpringMVC + Hibernate的项目.其它框架的仅仅能说作參考用 配置Sp ...