Package com.cloudera.flume.core

Examples of com.cloudera.flume.core.EventSource.open()


    EventSource src = FlumeBuilder.buildSource(LogicalNodeContext.testingContext(),"thrift(31337)");

    EventSink snk = FlumeBuilder.buildSink("thrift(\"0.0.0.0\",31337)");

    src.open();

    // iterate until an exception is thrown
    int i = 0;
    try {
      for (i = 0; true; i++) {
View Full Code Here


  public void testSurviveManyOpens() throws IOException, FlumeSpecException,
      InterruptedException {
    Benchmark b = new Benchmark("connection exhaust");

    EventSource src = FlumeBuilder.buildSource(LogicalNodeContext.testingContext(), "thrift(31337)");
    src.open();

    // iterate until an exception is thrown
    for (int i = 0; i < 10000; i++) { // previous fails at 1000, make sure ok at
      // an order of magnitude bigger.
View Full Code Here

    String cmd = temp.getAbsolutePath();

    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();
View Full Code Here

   * Test process creation and reading from stdout; assumes 'yes' is available.
   */
  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) {
View Full Code Here

  @Test
  public void testEmptyCommand() throws IOException, InterruptedException {
    Exception e = null;
    try {
      EventSource source = new ExecNioSource.Builder().build("");
      source.open();
      source.close();
    } catch (IllegalArgumentException i) {
      e = i;
    }
    assertNotNull("testEmptyCommand expected IllegalArgumentException", e);
View Full Code Here

    out.write("#!/bin/bash\necho \"Hello world!\" >&2 \n");
    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
View Full Code Here

    final CountDownLatch started = new CountDownLatch(1);
    final CountDownLatch latch = new CountDownLatch(1);
    Thread t = new Thread() {
      public void run() {
        try {
          source.open();
          started.countDown();
          source.next();
          latch.countDown();
        } catch (Exception e) {
          LOG.warn("Event consumption thread caught exception, test will fail",
View Full Code Here

    out.write("#!/bin/bash\n echo \"Hello\"\necho \"World!\"\n");
    out.close();
    String cmd = temp.getAbsolutePath();
    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());
View Full Code Here

    String cmd = temp.getAbsolutePath();
    ExecNioSource.Builder builder = new ExecNioSource.Builder();
    // aggregate = false, restart=true, restart after 1000ms
    EventSource source = builder.build("/bin/bash " + cmd, "false", "true",
        "1000");
    source.open();
    Event e1 = source.next();
    Event e2 = source.next();
    source.close();
    String t1 = new String(e1.getBody());
    String t2 = new String(e2.getBody());
View Full Code Here

    ExecNioSource.Builder builder = new ExecNioSource.Builder();
    EventSource source = builder.build("date");
    for (int i = 0; i < 1024; ++i) {
      try {
        source = builder.build("date");
        source.open();
        source.close();
      } catch (Exception e) {
        assertTrue("Exec open / close failed on iteration " + i
            + " with failure " + e, false);
      }
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.