Package com.cloudera.flume.core

Examples of com.cloudera.flume.core.Event


    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());
    long time1 = Long.parseLong(t1);
    long time2 = Long.parseLong(t2);
    assertTrue("Time difference with repeated exec should be >= 1s", time2
        - time1 >= 1);
  }
View Full Code Here


    EventSource source = builder.build("tail -F " + f.getAbsolutePath());
    source.open();

    fw.write("foo\n");
    fw.flush();
    Event e = source.next();
    assertTrue(Arrays.equals("foo".getBytes(), e.getBody()));

    fw.write("bar\n");
    fw.flush();
    e = source.next();
    assertTrue(Arrays.equals("bar".getBytes(), e.getBody()));

    fw.write("baz\n");
    fw.flush();
    e = source.next();
    assertTrue(Arrays.equals("baz".getBytes(), e.getBody()));

    source.close();
  }
View Full Code Here

    EventSource source = builder.build("tail -F " + f.getAbsolutePath());
    source.open();

    fw.write("foo\n");
    fw.flush();
    Event e = source.next();
    assertTrue(Arrays.equals("foo".getBytes(), e.getBody()));

    // this case inserts an extremely long line.
    int max = (int) FlumeConfiguration.get().getEventMaxSizeBytes();
    int tooBig = max * 10;
    byte[] data = new byte[tooBig];
    for (int i = 0; i < data.length; i++) {
      data[i] = 'a';
    }
    fw.write(new String(data) + "\n");
    fw.flush();
    e = source.next();
    assertEquals(max, e.getBody().length);

    // back to previous test
    fw.write("baz\n");
    fw.flush();
    e = source.next();
    assertTrue(Arrays.equals("baz".getBytes(), e.getBody()));

    source.close();
  }
View Full Code Here

        "Need to open source before reading from it");
    String s = raf.readLine();
    if (s == null)
      return null;

    Event e = new EventImpl(s.getBytes());
    updateEventProcessingStats(e);
    return e;
  }
View Full Code Here

    int size = this.minBodySize
        + this.rand.nextInt(this.maxBodySize - this.minBodySize);
    count++;
    byte[] data = new byte[size];
    rand.nextBytes(data);
    Event e = new EventImpl(data);
    updateEventProcessingStats(e);
    return e;
  }
View Full Code Here

      return ' ';
    return b;
  }

  public Event next() throws IOException {
    Event e = super.next();
    if (e == null)
      return null;

    // NOTE: this is a reference to the body. and will be modified
    byte[] body = e.getBody();
    for (int i = 0; i < body.length; i++) {
      body[i] = toAscii(body[i]);
    }

    return e;
View Full Code Here

  public void testReorderDecorator() throws IOException, InterruptedException {
    ReorderDecorator<EventSink> reorder =
        new ReorderDecorator<EventSink>(new ConsoleEventSink(), .5, .5, 0);
    reorder.open();
    for (int i = 0; i < 10; i++) {
      Event e = new EventImpl(new byte[0]);
      e.set("order", ByteBuffer.allocate(4).putInt(i).array());
      reorder.append(e);
    }
    System.out.println("closing");
    reorder.close();
  }
View Full Code Here

    MemorySinkSource mss = new MemorySinkSource();
    ReorderDecorator<EventSink> reorder =
        new ReorderDecorator<EventSink>(mss, .5, .5, 0);
    reorder.open();
    for (int i = 0; i < 10; i++) {
      Event e = new EventImpl(new byte[0]);
      e.set("order", ByteBuffer.allocate(4).putInt(i).array());
      reorder.append(e);
    }
    System.out.println("closing");
    reorder.close();
    int[] order = { 0, 2, 1, 4, 3, 5, 7, 6, 8, 9 };
    for (int i = 0; i < order.length; i++) {
      Event e = mss.next();
      int j = ByteBuffer.wrap(e.get("order")).asIntBuffer().get();
      assertEquals(j, order[i]);
    }

  }
View Full Code Here

    src.open();
  }

  @Override
  public Event next() throws IOException, InterruptedException {
    Event e = src.next();
    updateEventProcessingStats(e);
    return e;
  }
View Full Code Here

    DataFileReader<EventImpl> dr = new DataFileReader<EventImpl>(f, dtm);

    EventImpl eout = null;
    for (Object o : dr) {
      eout = (EventImpl) o; // TODO (jon) fix AVRO -- this is gross
      Event expected = mem.next();
      Assert.assertTrue(Arrays.equals(eout.getBody(), expected.getBody()));
    }

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