本文整理汇总了Java中org.apache.flume.channel.ChannelProcessor.initialize方法的典型用法代码示例。如果您正苦于以下问题:Java ChannelProcessor.initialize方法的具体用法?Java ChannelProcessor.initialize怎么用?Java ChannelProcessor.initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.flume.channel.ChannelProcessor
的用法示例。
在下文中一共展示了ChannelProcessor.initialize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.apache.flume.channel.ChannelProcessor; //导入方法依赖的package包/类
@Override
public void start() {
PollableSource source = (PollableSource) getSource();
ChannelProcessor cp = source.getChannelProcessor();
cp.initialize();
source.start();
runner = new PollingRunner();
runner.source = source;
runner.counterGroup = counterGroup;
runner.shouldStop = shouldStop;
runnerThread = new Thread(runner);
runnerThread.setName(getClass().getSimpleName() + "-" +
source.getClass().getSimpleName() + "-" + source.getName());
runnerThread.start();
lifecycleState = LifecycleState.START;
}
示例2: start
import org.apache.flume.channel.ChannelProcessor; //导入方法依赖的package包/类
@Override
public void start() {
Source source = getSource();
ChannelProcessor cp = source.getChannelProcessor();
cp.initialize();
source.start();
lifecycleState = LifecycleState.START;
}
示例3: testCensor
import org.apache.flume.channel.ChannelProcessor; //导入方法依赖的package包/类
@Test
public void testCensor() {
MemoryChannel memCh = new MemoryChannel();
memCh.configure(new Context());
memCh.start();
ChannelSelector cs = new ReplicatingChannelSelector();
cs.setChannels(Lists.<Channel>newArrayList(memCh));
ChannelProcessor cp = new ChannelProcessor(cs);
// source config
Map<String, String> cfgMap = Maps.newHashMap();
cfgMap.put("interceptors", "a");
String builderClass = CensoringInterceptor.Builder.class.getName();
cfgMap.put("interceptors.a.type", builderClass);
Context ctx = new Context(cfgMap);
// setup
cp.configure(ctx);
cp.initialize();
Map<String, String> headers = Maps.newHashMap();
String badWord = "scribe";
headers.put("Bad-Words", badWord);
Event event1 = EventBuilder.withBody("test", Charsets.UTF_8, headers);
Assert.assertEquals(badWord, event1.getHeaders().get("Bad-Words"));
cp.processEvent(event1);
Transaction tx = memCh.getTransaction();
tx.begin();
Event event1a = memCh.take();
Assert.assertNull(event1a.getHeaders().get("Bad-Words"));
tx.commit();
tx.close();
// cleanup / shutdown
cp.close();
memCh.stop();
}