Package org.apache.flume

Examples of org.apache.flume.Event


    sink.start();

    Transaction txn = channel.getTransaction();
    txn.begin();
    for(int i=0; i < 10; i++) {
      Event event = new SimpleEvent();
      event.setBody(("test event " + i).getBytes());
      channel.put(event);
    }
    txn.commit();
    txn.close();
View Full Code Here


    List<BucketWriter> writers = Lists.newArrayList();
    transaction.begin();
    try {
      int txnEventCount = 0;
      for (txnEventCount = 0; txnEventCount < batchSize; txnEventCount++) {
        Event event = channel.take();
        if (event == null) {
          break;
        }

        // reconstruct the path name by substituting place holders
        String realPath = BucketPath.escapeString(path, event.getHeaders(),
            timeZone, needRounding, roundUnit, roundValue);
        BucketWriter bucketWriter = sfWriters.get(realPath);

        // we haven't seen this file yet, so open it and cache the handle
        if (bucketWriter == null) {
View Full Code Here

            // first add to takeList so that if write to disk
            // fails rollback actually does it's work
            Preconditions.checkState(takeList.offer(ptr), "takeList offer failed "
                 + channelNameDescriptor);
            log.take(transactionID, ptr); // write take to disk
            Event event = log.get(ptr);
            return event;
          } catch (IOException e) {
            throw new ChannelException("Take failed due to IO error "
                    + channelNameDescriptor, e);
          }
View Full Code Here

    // take an event, roll it back, and
    // then make sure a put fails
    Transaction transaction;
    transaction = channel.getTransaction();
    transaction.begin();
    Event event = channel.take();
    Assert.assertNotNull(event);
    transaction.rollback();
    transaction.close();
    // ensure the take the didn't change the state of the capacity
    Assert.assertEquals(0, fillChannel(channel, "capacity").size());
View Full Code Here

          String prefix, int number) {
    Set<String> events = Sets.newHashSet();
    tx.begin();
    for (int i = 0; i < number; i++) {
      String eventData = (prefix + UUID.randomUUID()).toString();
      Event event = EventBuilder.withBody(eventData.getBytes());
      channel.put(event);
      events.add(eventData);
    }
    return events;
  }
View Full Code Here

    bb.get(buf);
    HexDump.dump(buf, 0, System.out, 0);
    */

    byte b = 0;
    Event e = null;
    boolean doneReading = false;

    try {
      while (!doneReading && in.readable()) {
        b = in.readByte();
View Full Code Here

    List<Event> channelEvents = new ArrayList<Event>();
    Transaction txn = channel.getTransaction();
    txn.begin();
    for (int i = 0; i < 10; i++) {
      Event e = channel.take();
      Assert.assertNotNull(e);
      channelEvents.add(e);
    }

    try {
      txn.commit();
    } catch (Throwable t) {
      txn.rollback();
    } finally {
      txn.close();
    }

    source.stop();
    for (Event e : channelEvents) {
      Assert.assertNotNull(e);
      String str = new String(e.getBody(), Charsets.UTF_8);
      logger.info(str);
      if (keepFields.equals("true") || keepFields.equals("all")) {
        Assert.assertArrayEquals(bodyWithTandH.trim().getBytes(),
            e.getBody());
      } else if (keepFields.equals("false") || keepFields.equals("none")) {
        Assert.assertArrayEquals(data1.getBytes(), e.getBody());
      } else if (keepFields.equals("hostname")) {
        Assert.assertArrayEquals(bodyWithHostname.getBytes(), e.getBody());
      } else if (keepFields.equals("timestamp")) {
        Assert.assertArrayEquals(bodyWithTimestamp.getBytes(), e.getBody());
      }
    }
  }
View Full Code Here

    List<Event> channelEvents = new ArrayList<Event>();
    Transaction txn = channel.getTransaction();
    txn.begin();
    for (int i = 0; i < 10; i++) {
      Event e = channel.take();
      Assert.assertNotNull(e);
      channelEvents.add(e);
    }

    try {
      txn.commit();
    } catch (Throwable t) {
      txn.rollback();
    } finally {
      txn.close();
    }

    source.stop();
    for (Event e : channelEvents) {
      Assert.assertNotNull(e);
      Assert.assertArrayEquals(largePayload, e.getBody());
    }
  }
View Full Code Here

public class TestEventBuilder {

  @Test
  public void testBody() {
    Event e1 = EventBuilder.withBody("e1".getBytes());
    Assert.assertNotNull(e1);
    Assert.assertArrayEquals("body is correct", "e1".getBytes(), e1.getBody());

    Event e2 = EventBuilder.withBody(Long.valueOf(2).toString().getBytes());
    Assert.assertNotNull(e2);
    Assert.assertArrayEquals("body is correct", Long.valueOf(2L).toString()
        .getBytes(), e2.getBody());
  }
View Full Code Here

    Map<String, String> headers = new HashMap<String, String>();

    headers.put("one", "1");
    headers.put("two", "2");

    Event e1 = EventBuilder.withBody("e1".getBytes(), headers);

    Assert.assertNotNull(e1);
    Assert.assertArrayEquals("e1 has the proper body", "e1".getBytes(),
        e1.getBody());
    Assert.assertEquals("e1 has the proper headers", 2, e1.getHeaders().size());
    Assert.assertEquals("e1 has a one key", "1", e1.getHeaders().get("one"));
  }
View Full Code Here

TOP

Related Classes of org.apache.flume.Event

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.