Package com.cloudera.flume.core

Examples of com.cloudera.flume.core.Event


    if (curSource == null) {
      return null;
    }

    // read next event
    Event e = getValidNext();
    if (e != null) {
      updateEventProcessingStats(e);
      return e; // successful case
    }
View Full Code Here


   * @throws InterruptedException
   */
  @Test
  public void checkSynth() throws IOException, InterruptedException {
    EventSource src = new SynthSource(5, 10, 1337);
    Event e = null;
    EventSink snk = new ConsoleEventSink(new AvroJsonOutputFormat());
    MemorySinkSource mem = new MemorySinkSource();
    while ((e = src.next()) != null) {
      snk.append(e); // visual inspection
      mem.append(e); // testing
    }

    mem.open();
    int i = 0;
    while ((e = mem.next()) != null) {
      i++;
      assertEquals(10, e.getBody().length);
    }
    assertEquals(5, i);

  }
View Full Code Here

   * @throws InterruptedException
   */
  @Test
  public void testMultipleVaryMessageBytes() throws IOException,
      InterruptedException {
    Event e1, e2;
    for (EventSource src : BenchmarkHarness.varyMsgBytes.values()) {
      src.open();
      e1 = src.next();
      src.open();
      e2 = src.next();
      assertTrue(Arrays.equals(e1.getBody(), e2.getBody()));
    }
  }
View Full Code Here

   * @throws InterruptedException
   */
  @Test
  public void checkAttrSynth() throws IOException, InterruptedException {
    EventSource src = new AttrSynthSource(5, 10, 20, 15, 1337);
    Event e = null;
    EventSink snk = new ConsoleEventSink(new AvroJsonOutputFormat());
    MemorySinkSource mem = new MemorySinkSource();
    while ((e = src.next()) != null) {
      snk.append(e); // visual inspection
      mem.append(e); // testing
    }

    mem.open();
    int i = 0;
    while ((e = mem.next()) != null) {
      i++;
      Map<String, byte[]> ents = e.getAttrs();
      assertEquals(10, ents.size()); // 10 generated + 1 (service)
      for (String a : ents.keySet()) {
        assertEquals(20, a.length());
      }
      for (byte[] v : ents.values()) {
View Full Code Here

   * @throws InterruptedException
   */
  @Test
  public void testAttrsMultipleVaryMessageBytes() throws IOException,
      InterruptedException {
    Event e1, e2;
    for (EventSource src : BenchmarkHarness.varyNumAttrs.values()) {
      src.open();
      e1 = src.next();
      src.open();
      e2 = src.next();
      assertTrue(Arrays.equals(e1.getBody(), e2.getBody()));
    }
  }
View Full Code Here

  public void testNewExtractor() throws EventExtractException {
    String msg = "This is a test";
    String entry = "<13>" + msg + "\n";
    DataInputStream in = new DataInputStream(new ByteArrayInputStream(entry
        .getBytes()));
    Event e = SyslogWireExtractor.extractEvent(in);
    Assert.assertEquals(1, e.get(SyslogConsts.SYSLOG_FACILITY)[0]); // 1 is syslog
    Assert.assertEquals(5, e.get(SyslogConsts.SYSLOG_SEVERITY)[0]); // 5 is
    Assert.assertTrue(Arrays.equals(msg.getBytes(), e.getBody()));
  }
View Full Code Here

    }

    @Override
    public Event next() throws IOException, InterruptedException {
      try {
        Event e = src.next();
        if (e != null) {
          readEvtCount.incrementAndGet();
          // TODO make the roll tag a parameter so that we don't have to remove
          // it here.
          e = EventImpl.unselect(e, RollSink.DEFAULT_ROLL_TAG);
View Full Code Here

    DataInputStream in = new DataInputStream(new ByteArrayInputStream(entry
        .getBytes()));

    SyslogWireExtractor fmt = new SyslogWireExtractor();
    Event e = fmt.extract(in);
    System.out.printf("size entry: %d, size formatted: %d ",
        entry.getBytes().length, fmt.toBytes(e).length);
    Assert.assertTrue(Arrays.equals(entry.getBytes(), fmt.toBytes(e)));
  }
View Full Code Here

    DataInputStream in = new DataInputStream(new ByteArrayInputStream(entry
        .getBytes()));

    SyslogWireExtractor fmt = new SyslogWireExtractor();
    Event e = fmt.extract(in);
    Assert.assertTrue(Arrays.equals(entry.getBytes(), fmt.toBytes(e)));

  }
View Full Code Here

    DataInputStream in = new DataInputStream(new ByteArrayInputStream(entry
        .getBytes()));

    SyslogWireExtractor fmt = new SyslogWireExtractor();
    Event e = fmt.extract(in);
    Assert.assertTrue(Arrays.equals(entry.getBytes(), fmt.toBytes(e)));

  }
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.