Package com.cloudera.flume.core

Examples of com.cloudera.flume.core.Event


  @Override
  public Event next() throws IOException {

    try {

      Event e = null;
      // block until an event shows up
      while ((e = q.poll(100, TimeUnit.MILLISECONDS)) == null) {

        synchronized (this) {
          // or bail out if closed
          if (closed) {
            return null;
          }
        }

      }
      // return the event
      synchronized (this) {
        dequeued.getAndIncrement();
        updateEventProcessingStats(e);
        return e;
      }
    } catch (InterruptedException e) {
      throw new IOException("Waiting for queue element was interrupted! "
          + e.getMessage(), e);
    }
  }
View Full Code Here


    File tmp = File.createTempFile("test", "tmp");
    tmp.deleteOnExit();
    SeqfileEventSink sink = new SeqfileEventSink(tmp);
    sink.open();
    for (int i = 0; i < 100; i++) {
      Event e = new EventImpl(("test " + i).getBytes());
      sink.append(e);
    }
    sink.close();

    SeqfileEventSource src = SeqfileEventSource
View Full Code Here

      if (browser != null && !browser.equals("-")) {
        fields.put("browser", browser.getBytes());
      }

      Event e = new EventImpl(body.getBytes(), d.getTime(), Priority.INFO,
          Clock.nanos(), host, fields);
      return e;
    } catch (ParseException e) {
      LOG.warn("Failed to parse apache access log line: '" + s + "'", e);
      return null;
View Full Code Here

    MemorySinkSource mem = new MemorySinkSource();
    FanOutSink<EventSink> fo = new FanOutSink<EventSink>(cnt, mem);
    BatchingDecorator<EventSink> b = new BatchingDecorator<EventSink>(fo, 10, 0);
    b.open();
    for (int i = 0; i < total; i++) {
      Event e = new EventImpl(("message " + i).getBytes());
      b.append(e);
    }
    b.close();
    Assert.assertEquals(11, cnt.getCount());

    // unbatch the batch.
    CounterSink cnt2 = new CounterSink("unbatch");
    UnbatchingDecorator<EventSink> ub = new UnbatchingDecorator<EventSink>(cnt2);
    Event ue = null;
    ub.open();
    while ((ue = mem.next()) != null) {
      ub.append(ue);
    }
    Assert.assertEquals(total, cnt2.getCount());
View Full Code Here

    FanOutSink<EventSink> fo = new FanOutSink<EventSink>(cnt, mem);
    BatchingDecorator<EventSink> b = new BatchingDecorator<EventSink>(fo, 1024,
        3000);
    b.open();
    for (int i = 0; i < total; i++) {
      Event e = new EventImpl(("message " + i).getBytes());
      b.append(e);
    }
    Thread.sleep(5000);
    Assert.assertEquals(1, cnt.getCount());
    b.close();
View Full Code Here

    FanOutSink<EventSink> fo = new FanOutSink<EventSink>(cnt, mem);
    BatchingDecorator<EventSink> b = new BatchingDecorator<EventSink>(fo, 10,
        3000);
    b.open();
    for (int i = 0; i < total; i++) {
      Event e = new EventImpl(("message " + i).getBytes());
      b.append(e);
    }
    b.close();
    Assert.assertEquals(11, cnt.getCount());
  }
View Full Code Here

    MemorySinkSource mem = new MemorySinkSource();
    BatchingDecorator<EventSink> b = new BatchingDecorator<EventSink>(mem, 10,
        0);
    b.open();
    for (int i = 0; i < 100; i++) {
      Event e = new EventImpl(("canned data " + i).getBytes());
      b.append(e);
    }

    MemorySinkSource mem2 = new MemorySinkSource();
    GzipDecorator<EventSink> gz = new GzipDecorator<EventSink>(mem2);
    Event be = mem.next();
    gz.open();
    gz.append(be);

    Event gzbe = mem2.next();
    MemorySinkSource mem3 = new MemorySinkSource();
    GunzipDecorator<EventSink> gunz = new GunzipDecorator<EventSink>(mem3);
    gunz.open();
    gunz.append(gzbe);
    Event gunze = mem3.next();

    int origsz = new WriteableEvent(be).toBytes().length;
    int gzipsz = new WriteableEvent(gzbe).toBytes().length;
    int ungzsz = new WriteableEvent(gunze).toBytes().length;
View Full Code Here

  public void testFileSource() throws IOException, InterruptedException {
    EventSource src = new TextFileSource(TEST);
    src.open();
    int count = 0;
    while (true) {
      Event e = src.next();
      if (e == null)
        break;
      count++;
      System.out.println(e);
    }
View Full Code Here

    }

    @Override
    public Event next() throws IOException, InterruptedException {
      try {
        Event e1 = src.next();
        if (e1 == null)
          return null;

        // The roller used by the writing portion of the WAL tags values with a
        // rolltag attribute. This tag is not relevant downstream and may cause
        // a problem if a downstream roller tries to add its own rolltag. This
        // prevents that from being a problem.
        Event e2 = EventImpl.unselect(e1, RollSink.DEFAULT_ROLL_TAG);
        updateEventProcessingStats(e2);
        return e2;
      } catch (IOException ioe) {
        LOG.warn("next had a problem " + src, ioe);
        changeState(tag, null, State.ERROR);
View Full Code Here

      }
    };
    t.start();

    for (int i = 0; i < total; i++) {
      Event e = new EventImpl(("message " + i).getBytes());
      l.append(e);
    }
    t.join();
    long count = c.getCount();
    System.out.println("trigger thread joined, count is now: " + count);
View Full Code Here

TOP

Related Classes of com.cloudera.flume.core.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.