Package com.cloudera.flume.core

Examples of com.cloudera.flume.core.Event


    buf.put((byte) '\n');
    ret = ExecNioSource.extractLines(buf, "cmd", "tag", q);
    assertTrue(ret);
    assertEquals(0, buf.position()); // should have buffer cleared
    assertEquals(1, q.size());
    Event e = q.poll();
    assertEquals(maxSz, e.getBody().length);

    // Normal Case
    for (int i = 0; i < maxSz; i++) {
      if (i % 1024 == 1023) {
        buf.put((byte) '\n');
      } else {
        buf.put((byte) 'b');
      }
    }
    ret = ExecNioSource.extractLines(buf, "cmd", "tag", q);
    assertTrue(ret);
    assertEquals(0, buf.position()); // should have buffer cleared
    assertEquals(32, q.size());
    for (int i = 0; i < 32; i++) {
      e = q.poll();
      assertEquals(1023, e.getBody().length);
    }
  }
View Full Code Here


    f.write(tooLarge.toString().getBytes());
    f.close();
    EventSource source = new ExecNioSource.Builder().build("cat "
        + tmp.getCanonicalPath());
    source.open();
    Event e = source.next();
    assertNotNull(e);
    assertEquals(max, e.getBody().length); // check that event was truncated.
    source.close();
    FileUtil.rmr(tmpdir);
    // Check that the stdout reader closed correctly
    assertTrue(((ExecNioSource) source).readOut.signalDone.get());
  }
View Full Code Here

    f.write(tooLarge.toString().getBytes());
    f.close();
    EventSource source = new ExecNioSource.Builder().build(
        "cat " + tmp.getCanonicalPath(), "true");
    source.open();
    Event e = source.next();
    assertNotNull(e);
    assertEquals(max, e.getBody().length); // check that event was truncated.
    source.close();
    FileUtil.rmr(tmpdir);
    // Check that the stdout reader closed correctly
    assertTrue(((ExecNioSource) source).readOut.signalDone.get());
  }
View Full Code Here

    EventSource source = new ExecNioSource.Builder().build("/bin/bash " + cmd,
        "true");

    source.open();
    Event e = source.next();
    assertNotNull(e);
    assertEquals(26, e.getBody().length); // check that we read both lines
    source.close();

    // Check that the stdout reader closed correctly
    assertTrue(((ExecNioSource) source).readOut.signalDone.get());
  }
View Full Code Here

   */
  public void testSimpleExec() throws IOException {
    try {
      EventSource source = new ExecNioSource.Builder().build("yes");
      source.open();
      Event e = source.next();
      String body = new String(e.getBody());
      assertEquals("Expected event body to be 'y', but got " + body, body, "y");
      source.close();
    } catch (Exception e) {
      LOG.error(e.getMessage(), e);
      fail(e.getMessage());
    }
  }
View Full Code Here

    // send to counter 10x.
    EventSinkDecorator<CounterSink> s = new MultiplierDecorator<CounterSink>(
        cnt, repeat);
    s.open();
    for (int i = 0; i < msgs; i++) {
      Event e = new EventImpl(("" + i).getBytes());
      s.append(e);
    }

    Assert.assertEquals(msgs * repeat, cnt.getCount());
  }
View Full Code Here

    String cfg = "{ mult(" + repeat + ") => counter(\"count\") }";
    EventSink s = FlumeBuilder.buildSink(new ReportTestingContext(), cfg);
    s.open();

    for (int i = 0; i < msgs; i++) {
      Event e = new EventImpl(("" + i).getBytes());
      s.append(e);
    }

    CounterSink cnt = (CounterSink) ReportManager.get().getReportable("count");
    Assert.assertEquals(msgs * repeat, cnt.getCount());
View Full Code Here

        + ") => [console, counter(\"count\")] }}";
    EventSink s = FlumeBuilder.buildSink(new ReportTestingContext(), cfg);
    s.open();

    for (int i = 0; i < msgs; i++) {
      Event e = new EventImpl(("" + i).getBytes());
      s.append(e);
    }
    s.close();

    CounterSink cnt = (CounterSink) ReportManager.get().getReportable("count");
View Full Code Here

    out.close();
    String cmd = temp.getAbsolutePath();

    EventSource source = new ExecNioSource.Builder().build("/bin/bash " + cmd);
    source.open();
    Event e = source.next();
    String body = new String(e.getBody());
    String src = new String(e.get(ExecNioSource.A_PROC_SOURCE));
    source.close();
    assertEquals("Expected event body to be 'Hello World!', but got '" + body
        + "'", body, "Hello world!");
    assertEquals("Expected to receive event from STDERR, but got " + src, src,
        "STDERR");
View Full Code Here

    ExecNioSource.Builder builder = new ExecNioSource.Builder();
    EventSource source = builder.build("/bin/bash " + cmd, "true");
    source.open();

    Clock.sleep(250); // need to sleep to let things percolate through threads.
    Event e = source.next();
    source.close();
    String output = new String(e.getBody());
    assertEquals("Expected aggregate exec output to be 'Hello\nWorld!', "
        + "but got '" + output + "'", output, "Hello\nWorld!\n");

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