本文整理汇总了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();
}
}
示例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();
}
示例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);
}