当前位置: 首页>>代码示例>>Java>>正文


Java RollingFileSink类代码示例

本文整理汇总了Java中org.apache.flume.sink.RollingFileSink的典型用法代码示例。如果您正苦于以下问题:Java RollingFileSink类的具体用法?Java RollingFileSink怎么用?Java RollingFileSink使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RollingFileSink类属于org.apache.flume.sink包,在下文中一共展示了RollingFileSink类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCSV

import org.apache.flume.sink.RollingFileSink; //导入依赖的package包/类
@Test
public void testCSV() {
  MemoryChannel ch = new MemoryChannel();
  ch.configure(new Context());

  RollingFileSink s = new RollingFileSink();
  s.setChannel(ch);
  Context ctx = new Context();
  ctx.put("sink.directory", "target/test");
  ctx.put("sink.serializer", CSVAvroSerializer.Builder.class.getName());
  s.configure(ctx);

  String line = "1371782343001,1371782343023,view,65605,201.112.234.35,tgoodwin,/product/24923,/product/60444";
  Event e = EventBuilder.withBody(line, Charsets.UTF_8);

  Transaction txn = ch.getTransaction();
  txn.begin();
  ch.put(e);
  txn.commit();
  txn.close();

  try {
    s.process();
  } catch (EventDeliveryException ex) {
    ex.printStackTrace();
  }
}
 
开发者ID:mpercy,项目名称:flume-rtq-hadoop-summit-2013,代码行数:28,代码来源:TestCSVAvroSerializer.java

示例2: createAvroSourceWithLocalFileRollingSink

import org.apache.flume.sink.RollingFileSink; //导入依赖的package包/类
@SuppressWarnings("unused")
private void createAvroSourceWithLocalFileRollingSink() {
	channel = new MemoryChannel();
	String channelName = "AvroSourceMemoryChannel-" + UUID.randomUUID();
	channel.setName(channelName);

	sink = new RollingFileSink();
	sink.setName("RollingFileSink-" + UUID.randomUUID());
	Map<String, String> paramters = new HashMap<>();
	paramters.put("type", "file_roll");
	paramters.put("sink.directory", "target/flumefilelog");
	Context sinkContext = new Context(paramters);
	sink.configure(sinkContext);
	Configurables.configure(channel, sinkContext);
	sink.setChannel(channel);

	final Map<String, String> properties = new HashMap<String, String>();
	properties.put("type", "avro");
	properties.put("bind", "localhost");
	properties.put("port", "44444");
	properties.put("selector.type", "multiplexing");
	properties.put("selector.header", "State");
	properties.put("selector.mapping.VIEWED", channelName);
	properties.put("selector.mapping.default", channelName);

	avroSource = new AvroSource();
	avroSource.setName("AvroSource-" + UUID.randomUUID());
	Context sourceContext = new Context(properties);
	avroSource.configure(sourceContext);
	ChannelSelector selector = new MultiplexingChannelSelector();
	List<Channel> channels = new ArrayList<>();
	channels.add(channel);
	selector.setChannels(channels);
	final Map<String, String> selectorProperties = new HashMap<String, String>();
	properties.put("default", channelName);
	Context selectorContext = new Context(selectorProperties);
	selector.configure(selectorContext);
	ChannelProcessor cp = new ChannelProcessor(selector);
	avroSource.setChannelProcessor(cp);

	sink.start();
	channel.start();
	avroSource.start();
}
 
开发者ID:jaibeermalik,项目名称:searchanalytics-bigdata,代码行数:45,代码来源:FlumeAgentServiceImpl.java

示例3: SpoolingDirectoryFileSink

import org.apache.flume.sink.RollingFileSink; //导入依赖的package包/类
public SpoolingDirectoryFileSink() throws NoSuchFieldException, IllegalAccessException {
	Field pathManagerField = RollingFileSink.class.getDeclaredField("pathController");
	pathManagerField.setAccessible(true);
	spoolingDirectoryPathManager = new SpoolingDirectoryPathManager();
	pathManagerField.set(this, spoolingDirectoryPathManager);
}
 
开发者ID:unruly,项目名称:flume-spooling-directory-sink,代码行数:7,代码来源:SpoolingDirectoryFileSink.java


注:本文中的org.apache.flume.sink.RollingFileSink类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。