Package org.apache.flume

Examples of org.apache.flume.Context


  }

  @Test
  public void testNegativeCapacities() {
    Context context = new Context();
    Map<String, String> parms = new HashMap<String, String>();
    parms.put("capacity", "-3");
    parms.put("transactionCapacity", "-1");
    context.putAll(parms);
    Configurables.configure(channel, context);

    Assert.assertTrue(field("queue")
            .ofType(LinkedBlockingDeque.class)
            .in(channel).get()
View Full Code Here


    underlying.shutdownNow();
    verify(eventsPulled);
  }

  private KafkaChannel startChannel(boolean parseAsFlume) throws Exception {
    Context context = prepareDefaultContext(parseAsFlume);
    final KafkaChannel channel = new KafkaChannel();
    Configurables.configure(channel, context);
    channel.start();
    return channel;
  }
View Full Code Here

  @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();
View Full Code Here

    tmpDir.delete();
  }

  @Test (expected = IllegalArgumentException.class)
  public void testInvalidSortOrder() {
    Context context = new Context();
    context.put(SpoolDirectorySourceConfigurationConstants.SPOOL_DIRECTORY,
        tmpDir.getAbsolutePath());
    context.put(SpoolDirectorySourceConfigurationConstants.CONSUME_ORDER,
        "undefined");
    Configurables.configure(source, context);   
  }
View Full Code Here

    Assert.assertTrue(eventStrings.isEmpty());
  }

  private Context prepareDefaultContext(boolean parseAsFlume) {
    // Prepares a default context with Kafka Server Properties
    Context context = new Context();
    context.put(KafkaChannelConfiguration.BROKER_LIST_FLUME_KEY,
      testUtil.getKafkaServerUrl());
    context.put(KafkaChannelConfiguration.ZOOKEEPER_CONNECT_FLUME_KEY,
      testUtil.getZkUrl());
    context.put(KafkaChannelConfiguration.PARSE_AS_FLUME_EVENT,
      String.valueOf(parseAsFlume));
    context.put(KafkaChannelConfiguration.READ_SMALLEST_OFFSET, "true");
    context.put(KafkaChannelConfiguration.TOPIC, topic);
    return context;
  }
View Full Code Here

    Configurables.configure(source, context);   
  }
 
  @Test
  public void testValidSortOrder() {
    Context context = new Context();
    context.put(SpoolDirectorySourceConfigurationConstants.SPOOL_DIRECTORY,
        tmpDir.getAbsolutePath());
    context.put(SpoolDirectorySourceConfigurationConstants.CONSUME_ORDER,
        "oLdESt");
    Configurables.configure(source, context);
    context.put(SpoolDirectorySourceConfigurationConstants.CONSUME_ORDER,
        "yoUnGest");
    Configurables.configure(source, context);
    context.put(SpoolDirectorySourceConfigurationConstants.CONSUME_ORDER,
        "rAnDom");
    Configurables.configure(source, context);   
  }
View Full Code Here

    Configurables.configure(source, context);   
  }
 
  @Test
  public void testPutFilenameHeader() throws IOException, InterruptedException {
    Context context = new Context();
    File f1 = new File(tmpDir.getAbsolutePath() + "/file1");

    Files.write("file1line1\nfile1line2\nfile1line3\nfile1line4\n" +
                "file1line5\nfile1line6\nfile1line7\nfile1line8\n",
                f1, Charsets.UTF_8);

    context.put(SpoolDirectorySourceConfigurationConstants.SPOOL_DIRECTORY,
        tmpDir.getAbsolutePath());
    context.put(SpoolDirectorySourceConfigurationConstants.FILENAME_HEADER,
        "true");
    context.put(SpoolDirectorySourceConfigurationConstants.FILENAME_HEADER_KEY,
        "fileHeaderKeyTest");

    Configurables.configure(source, context);
    source.start();
    while (source.getSourceCounter().getEventAcceptedCount() < 8) {
View Full Code Here

  }

  @Test
  public void testPutBasenameHeader() throws IOException,
    InterruptedException {
    Context context = new Context();
    File f1 = new File(tmpDir.getAbsolutePath() + "/file1");

    Files.write("file1line1\nfile1line2\nfile1line3\nfile1line4\n" +
      "file1line5\nfile1line6\nfile1line7\nfile1line8\n",
      f1, Charsets.UTF_8);

    context.put(SpoolDirectorySourceConfigurationConstants.SPOOL_DIRECTORY,
        tmpDir.getAbsolutePath());
    context.put(SpoolDirectorySourceConfigurationConstants.BASENAME_HEADER,
        "true");
    context.put(SpoolDirectorySourceConfigurationConstants.BASENAME_HEADER_KEY,
        "basenameHeaderKeyTest");

    Configurables.configure(source, context);
    source.start();
    while (source.getSourceCounter().getEventAcceptedCount() < 8) {
View Full Code Here

    txn.close();
  }

  @Test
  public void testLifecycle() throws IOException, InterruptedException {
    Context context = new Context();
    File f1 = new File(tmpDir.getAbsolutePath() + "/file1");

    Files.write("file1line1\nfile1line2\nfile1line3\nfile1line4\n" +
                "file1line5\nfile1line6\nfile1line7\nfile1line8\n",
                f1, Charsets.UTF_8);

    context.put(SpoolDirectorySourceConfigurationConstants.SPOOL_DIRECTORY,
        tmpDir.getAbsolutePath());

    Configurables.configure(source, context);

    for (int i = 0; i < 10; i++) {
View Full Code Here

  @Test
  public void testReconfigure() throws InterruptedException, IOException {
    final int NUM_RECONFIGS = 20;
    for (int i = 0; i < NUM_RECONFIGS; i++) {
      Context context = new Context();
      File file = new File(tmpDir.getAbsolutePath() + "/file-" + i);
      Files.write("File " + i, file, Charsets.UTF_8);
      context.put(SpoolDirectorySourceConfigurationConstants.SPOOL_DIRECTORY,
          tmpDir.getAbsolutePath());
      Configurables.configure(source, context);
      source.start();
      Thread.sleep(TimeUnit.SECONDS.toMillis(1));
      Transaction txn = channel.getTransaction();
View Full Code Here

TOP

Related Classes of org.apache.flume.Context

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.