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


Java ChannelSelector类代码示例

本文整理汇总了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);
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:20,代码来源:TestChannelProcessor.java

示例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);
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:27,代码来源:TestChannelProcessor.java

示例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));
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:17,代码来源:TestAvroSource.java

示例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);

}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:22,代码来源:TestSyslogUdpSource.java

示例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);

}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:21,代码来源:TestSyslogTcpSource.java

示例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();
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:17,代码来源:TestSpoolDirectorySource.java

示例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));
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:22,代码来源:TestNetcatSource.java

示例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";
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:18,代码来源:TestTaildirSource.java

示例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));
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:17,代码来源:TestNetcatSource.java

示例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();
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:23,代码来源:FlumeDestinationPipelineRunIT.java

示例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();
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:20,代码来源:TestFlumeThriftTarget.java

示例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();
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:20,代码来源:TestFlumeFailoverTarget.java

示例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();
}
 
开发者ID:cloudera,项目名称:cdk,代码行数:27,代码来源:TestLog4jAppenderWithAvro.java

示例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;
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:15,代码来源:ChannelSelectorFactory.java

示例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));
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:10,代码来源:TestThriftSource.java


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