Package org.apache.flume

Examples of org.apache.flume.Channel.take()


    for (long i = 0; i < 100; i++) {
      source.process();

      for (long j = batchSize; j > 0; j--) {
        Event event = channel.take();
        String expectedVal = String.valueOf(((i+1)*batchSize)-j);
        String resultedVal = new String(event.getBody());
        Assert.assertTrue("Expected " + expectedVal + " is not equals to " +
            resultedVal, expectedVal.equals(resultedVal));
      }
View Full Code Here


    source.start();

    for (long i = 0; i < 100; i++) {
      source.process();
      Event event = channel.take();

      Assert.assertArrayEquals(String.valueOf(i).getBytes(),
          new String(event.getBody()).getBytes());
    }
    source.stop();
View Full Code Here

    try {
      transaction.begin();
      createConnection();

      Event event = channel.take();

      if (event == null) {
        counterGroup.incrementAndGet("event.empty");
        status = Status.BACKOFF;
      } else {
View Full Code Here

      t2.interrupt();
    }

    Transaction tx = channel.getTransaction();
    tx.begin();
    Event e = channel.take();
    Assert.assertEquals("second event", new String(e.getBody()));
    Assert.assertNull(channel.take());
    tx.commit();
    tx.close();
  }
View Full Code Here

    Transaction tx = channel.getTransaction();
    tx.begin();
    Event e = channel.take();
    Assert.assertEquals("second event", new String(e.getBody()));
    Assert.assertNull(channel.take());
    tx.commit();
    tx.close();
  }

  /**
 
View Full Code Here

    // verify the counts
    Transaction tx = channel.getTransaction();
    tx.begin();
    Event e;
    while((e = channel.take()) != null) {
      String index = new String(e.getBody());
      AtomicInteger remain = committedPuts.get(index);
      int post = remain.decrementAndGet();
      if(post == 0) {
        committedPuts.remove(index);
View Full Code Here

            Transaction tx = channel.getTransaction();
            tx.begin();
            Event[] taken = new Event[events];
            int k;
            for(k = 0; k < events; k++) {
              taken[k] = channel.take();
              if(taken[k] == null) break;
            }
            if(rng.nextBoolean()) {
              try {
                tx.commit();
View Full Code Here

    Transaction tx = channel.getTransaction();
    tx.begin();
    Event e;
    // first pull out what's left in the channel and remove it from the
    // committed map
    while((e = channel.take()) != null) {
      String index = new String(e.getBody());
      AtomicInteger remain = committedPuts.get(index);
      int post = remain.decrementAndGet();
      if(post == 0) {
        committedPuts.remove(index);
View Full Code Here

    try {
      transaction.begin();
      Event event = null;
      for (int txnEventCount = 0; txnEventCount < txnEventMax; txnEventCount++) {
        event = null;
        event = channel.take();
        if (event == null) {
          break;
        }

        // reconstruct the path name by substituting place holders
View Full Code Here

    Event event;

    FileOutputStream outputStream = new FileOutputStream(
        "/tmp/flume-execsource." + Thread.currentThread().getId());

    while ((event = channel.take()) != null) {
      outputStream.write(event.getBody());
      outputStream.write('\n');
    }

    outputStream.close();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.