本文整理汇总了Java中org.apache.flume.ChannelSelector类的典型用法代码示例。如果您正苦于以下问题:Java ChannelSelector类的具体用法?Java ChannelSelector怎么用?Java ChannelSelector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChannelSelector类属于org.apache.flume包,在下文中一共展示了ChannelSelector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testExceptionFromGetTransaction
import org.apache.flume.ChannelSelector; //导入依赖的package包/类
/**
* Ensure that we bubble up any specific exception thrown from getTransaction
* instead of another exception masking it such as an NPE
*/
@Test(expected = ChannelException.class)
public void testExceptionFromGetTransaction() {
// create a channel which unexpectedly throws a ChEx on getTransaction()
Channel ch = mock(Channel.class);
when(ch.getTransaction()).thenThrow(new ChannelException("doh!"));
ChannelSelector sel = new ReplicatingChannelSelector();
sel.setChannels(Lists.newArrayList(ch));
ChannelProcessor proc = new ChannelProcessor(sel);
List<Event> events = Lists.newArrayList();
events.add(EventBuilder.withBody("event 1", Charsets.UTF_8));
proc.processEventBatch(events);
}
示例2: testNullFromGetTransaction
import org.apache.flume.ChannelSelector; //导入依赖的package包/类
/**
* Ensure that we see the original NPE from the PreConditions check instead
* of an auto-generated NPE, which could be masking something else.
*/
@Test
public void testNullFromGetTransaction() {
// channel which returns null from getTransaction()
Channel ch = mock(Channel.class);
when(ch.getTransaction()).thenReturn(null);
ChannelSelector sel = new ReplicatingChannelSelector();
sel.setChannels(Lists.newArrayList(ch));
ChannelProcessor proc = new ChannelProcessor(sel);
List<Event> events = Lists.newArrayList();
events.add(EventBuilder.withBody("event 1", Charsets.UTF_8));
boolean threw = false;
try {
proc.processEventBatch(events);
} catch (NullPointerException ex) {
threw = true;
Assert.assertNotNull("NPE must be manually thrown", ex.getMessage());
}
Assert.assertTrue("Must throw NPE", threw);
}
示例3: setUp
import org.apache.flume.ChannelSelector; //导入依赖的package包/类
@Before
public void setUp() throws UnknownHostException {
localhost = InetAddress.getByName("127.0.0.1");
source = new AvroSource();
channel = new MemoryChannel();
Configurables.configure(channel, new Context());
List<Channel> channels = new ArrayList<Channel>();
channels.add(channel);
ChannelSelector rcs = new ReplicatingChannelSelector();
rcs.setChannels(channels);
source.setChannelProcessor(new ChannelProcessor(rcs));
}
示例4: init
import org.apache.flume.ChannelSelector; //导入依赖的package包/类
private void init(String keepFields) {
source = new SyslogUDPSource();
channel = new MemoryChannel();
Configurables.configure(channel, new Context());
List<Channel> channels = new ArrayList<Channel>();
channels.add(channel);
ChannelSelector rcs = new ReplicatingChannelSelector();
rcs.setChannels(channels);
source.setChannelProcessor(new ChannelProcessor(rcs));
Context context = new Context();
context.put("host", InetAddress.getLoopbackAddress().getHostAddress());
context.put("port", String.valueOf(TEST_SYSLOG_PORT));
context.put("keepFields", keepFields);
source.configure(context);
}
示例5: init
import org.apache.flume.ChannelSelector; //导入依赖的package包/类
private void init(String keepFields) {
source = new SyslogTcpSource();
channel = new MemoryChannel();
Configurables.configure(channel, new Context());
List<Channel> channels = new ArrayList<>();
channels.add(channel);
ChannelSelector rcs = new ReplicatingChannelSelector();
rcs.setChannels(channels);
source.setChannelProcessor(new ChannelProcessor(rcs));
Context context = new Context();
context.put("port", String.valueOf(TEST_SYSLOG_PORT));
context.put("keepFields", keepFields);
source.configure(context);
}
示例6: setUp
import org.apache.flume.ChannelSelector; //导入依赖的package包/类
@Before
public void setUp() {
source = new SpoolDirectorySource();
channel = new MemoryChannel();
Configurables.configure(channel, new Context());
List<Channel> channels = new ArrayList<Channel>();
channels.add(channel);
ChannelSelector rcs = new ReplicatingChannelSelector();
rcs.setChannels(channels);
source.setChannelProcessor(new ChannelProcessor(rcs));
tmpDir = Files.createTempDir();
}
示例7: setUp
import org.apache.flume.ChannelSelector; //导入依赖的package包/类
/**
* We set up the the Netcat source and Flume Memory Channel on localhost
*
* @throws UnknownHostException
*/
@Before
public void setUp() throws UnknownHostException {
localhost = InetAddress.getByName("127.0.0.1");
source = new NetcatSource();
channel = new MemoryChannel();
Configurables.configure(channel, new Context());
List<Channel> channels = new ArrayList<Channel>();
channels.add(channel);
ChannelSelector rcs = new ReplicatingChannelSelector();
rcs.setChannels(channels);
source.setChannelProcessor(new ChannelProcessor(rcs));
}
示例8: setUp
import org.apache.flume.ChannelSelector; //导入依赖的package包/类
@Before
public void setUp() {
source = new TaildirSource();
channel = new MemoryChannel();
Configurables.configure(channel, new Context());
List<Channel> channels = new ArrayList<Channel>();
channels.add(channel);
ChannelSelector rcs = new ReplicatingChannelSelector();
rcs.setChannels(channels);
source.setChannelProcessor(new ChannelProcessor(rcs));
tmpDir = Files.createTempDir();
posFilePath = tmpDir.getAbsolutePath() + "/taildir_position_test.json";
}
示例9: setUp
import org.apache.flume.ChannelSelector; //导入依赖的package包/类
@Before
public void setUp() {
logger.info("Running setup");
channel = new MemoryChannel();
source = new NetcatSource();
Context context = new Context();
Configurables.configure(channel, context);
List<Channel> channels = Lists.newArrayList(channel);
ChannelSelector rcs = new ReplicatingChannelSelector();
rcs.setChannels(channels);
source.setChannelProcessor(new ChannelProcessor(rcs));
}
示例10: setUp
import org.apache.flume.ChannelSelector; //导入依赖的package包/类
@Before
@Override
public void setUp() throws Exception {
super.setUp();
//setup flume to write to
source = new AvroSource();
ch = new MemoryChannel();
Configurables.configure(ch, new Context());
Context context = new Context();
//This should match whats present in the pipeline.json file
context.put("port", String.valueOf(9050));
context.put("bind", "localhost");
Configurables.configure(source, context);
List<Channel> channels = new ArrayList<>();
channels.add(ch);
ChannelSelector rcs = new ReplicatingChannelSelector();
rcs.setChannels(channels);
source.setChannelProcessor(new ChannelProcessor(rcs));
source.start();
}
示例11: setUp
import org.apache.flume.ChannelSelector; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
port = NetworkUtils.getRandomPort();
source = new ThriftSource();
ch = new MemoryChannel();
Configurables.configure(ch, new Context());
Context context = new Context();
context.put("port", String.valueOf(port));
context.put("bind", "localhost");
Configurables.configure(source, context);
List<Channel> channels = new ArrayList<>();
channels.add(ch);
ChannelSelector rcs = new ReplicatingChannelSelector();
rcs.setChannels(channels);
source.setChannelProcessor(new ChannelProcessor(rcs));
source.start();
}
示例12: setUp
import org.apache.flume.ChannelSelector; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
port = NetworkUtils.getRandomPort();
source = new AvroSource();
ch = new MemoryChannel();
Configurables.configure(ch, new Context());
Context context = new Context();
context.put("port", String.valueOf(port));
context.put("bind", "localhost");
Configurables.configure(source, context);
List<Channel> channels = new ArrayList<>();
channels.add(ch);
ChannelSelector rcs = new ReplicatingChannelSelector();
rcs.setChannels(channels);
source.setChannelProcessor(new ChannelProcessor(rcs));
source.start();
}
示例13: setUp
import org.apache.flume.ChannelSelector; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
URL schemaUrl = getClass().getClassLoader().getResource("myrecord.avsc");
Files.copy(Resources.newInputStreamSupplier(schemaUrl),
new File("/tmp/myrecord.avsc"));
int port = 25430;
source = new AvroSource();
ch = new MemoryChannel();
Configurables.configure(ch, new Context());
Context context = new Context();
context.put("port", String.valueOf(port));
context.put("bind", "localhost");
Configurables.configure(source, context);
List<Channel> channels = new ArrayList<Channel>();
channels.add(ch);
ChannelSelector rcs = new ReplicatingChannelSelector();
rcs.setChannels(channels);
source.setChannelProcessor(new ChannelProcessor(rcs));
source.start();
}
示例14: create
import org.apache.flume.ChannelSelector; //导入依赖的package包/类
public static ChannelSelector create(List<Channel> channels,
Map<String, String> config) {
ChannelSelector selector = getSelectorForType(config.get(
BasicConfigurationConstants.CONFIG_TYPE));
selector.setChannels(channels);
Context context = new Context();
context.putAll(config);
Configurables.configure(selector, context);
return selector;
}
示例15: configureSource
import org.apache.flume.ChannelSelector; //导入依赖的package包/类
private void configureSource() {
List<Channel> channels = new ArrayList<Channel>();
channels.add(channel);
ChannelSelector rcs = new ReplicatingChannelSelector();
rcs.setChannels(channels);
source.setChannelProcessor(new ChannelProcessor(rcs));
}