本文整理汇总了Java中org.apache.flume.Sink.setName方法的典型用法代码示例。如果您正苦于以下问题:Java Sink.setName方法的具体用法?Java Sink.setName怎么用?Java Sink.setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.flume.Sink
的用法示例。
在下文中一共展示了Sink.setName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import org.apache.flume.Sink; //导入方法依赖的package包/类
@Override
public Sink create(String name, String type) throws FlumeException {
Preconditions.checkNotNull(name, "name");
Preconditions.checkNotNull(type, "type");
logger.info("Creating instance of sink: {}, type: {}", name, type);
Class<? extends Sink> sinkClass = getClass(type);
try {
Sink sink = sinkClass.newInstance();
sink.setName(name);
return sink;
} catch (Exception ex) {
throw new FlumeException("Unable to create sink: " + name
+ ", type: " + type + ", class: " + sinkClass.getName(), ex);
}
}
示例2: testIRCSinkMissingSplitLineProperty
import org.apache.flume.Sink; //导入方法依赖的package包/类
@Test
public void testIRCSinkMissingSplitLineProperty() {
Sink ircSink = new IRCSink();
ircSink.setName("IRC Sink - " + UUID.randomUUID().toString());
Context context = new Context();
context.put("hostname", "localhost");
context.put("port", String.valueOf(ircServerPort));
context.put("nick", "flume");
context.put("password", "flume");
context.put("user", "flume");
context.put("name", "flume-dev");
context.put("chan", "flume");
context.put("splitchars", "false");
Configurables.configure(ircSink, context);
Channel memoryChannel = new MemoryChannel();
Configurables.configure(memoryChannel, context);
ircSink.setChannel(memoryChannel);
ircSink.start();
Transaction txn = memoryChannel.getTransaction();
txn.begin();
Event event = EventBuilder.withBody("Dummy Event".getBytes());
memoryChannel.put(event);
txn.commit();
txn.close();
try {
Sink.Status status = ircSink.process();
if (status == Sink.Status.BACKOFF) {
fail("Error occured");
}
} catch (EventDeliveryException eDelExcp) {
// noop
}
}