Package com.cloudera.flume.reporter.history

Examples of com.cloudera.flume.reporter.history.CountHistoryReporter


   * next.
   */
  @Test
  public void testTestCountHistory() throws IOException, InterruptedException {
    // have a huge period and just force them in the test.
    CountHistoryReporter r = new CountHistoryReporter("test timeline", 5000000,
        t);
    r.open();
    Event e = new EventImpl("Test message".getBytes());

    // just a little forward to make things slighlty "out of sync"
    // 3
    r.append(e);
    r.append(e);
    r.append(e);
    r.forcedRotate();

    // 2
    r.append(e);
    r.append(e);
    r.forcedRotate();

    // 4
    r.append(e);
    r.append(e);
    r.append(e);
    r.append(e);
    r.forcedRotate();

    // 0 // this never registers!
    r.forcedRotate();

    // 1
    r.append(e);
    r.forcedRotate();

    r.append(e);

    long[] ans = { 3, 2, 4, 0, 1 };
    int i = 0;
    for (Pair<Long, CounterSink> p : r.getHistory()) {
      System.out.printf("time: %,18d count: %8d\n", p.getLeft(), p.getRight()
          .getCount());
      Assert.assertEquals(ans[i], p.getRight().getCount());
      i++;
    }
    r.close();
  }
View Full Code Here


  @Test
  public void testTestCountHistoryClocked() throws IOException, InterruptedException {
    MockClock m = new MockClock(0);
    Clock.setClock(m);

    CountHistoryReporter r = new CountHistoryReporter("test timeline", 500, t);
    r.open();
    Event e = new EventImpl("Test message".getBytes());

    // just a little forward to make things slighlty "out of sync"
    // 3
    r.append(e);
    r.append(e);
    r.append(e);
    m.forward(501);

    // 2
    r.append(e);
    r.append(e);
    m.forward(501);

    // 4
    r.append(e);
    r.append(e);
    r.append(e);
    r.append(e);
    m.forward(501);

    // 0 // this never registers!
    m.forward(501);

    // 1
    r.append(e);
    m.forward(501);

    r.append(e);

    long[] times = { 0, 501, 1002, 1503, 2004 };
    long[] ans = { 3, 2, 4, 0, 1 };
    int i = 0;
    for (Pair<Long, CounterSink> p : r.getHistory()) {
      System.out.printf("time: %8d count: %8d\n", p.getLeft(), p.getRight()
          .getCount());
      Assert.assertEquals(ans[i], p.getRight().getCount());
      Assert.assertEquals((long) p.getLeft(), times[i]);
      i++;
    }
    r.close();
  }
View Full Code Here

   * next.
   */
  @Test
  public void testTestCountHistory() throws IOException, InterruptedException {
    // have a huge period and just force them in the test.
    CountHistoryReporter r = new CountHistoryReporter("test timeline", 5000000,
        t);
    r.open();
    Event e = new EventImpl("Test message".getBytes());

    // just a little forward to make things slighlty "out of sync"
    // 3
    r.append(e);
    r.append(e);
    r.append(e);
    r.forcedRotate();

    // 2
    r.append(e);
    r.append(e);
    r.forcedRotate();

    // 4
    r.append(e);
    r.append(e);
    r.append(e);
    r.append(e);
    r.forcedRotate();

    // 0 // this never registers!
    r.forcedRotate();

    // 1
    r.append(e);
    r.forcedRotate();

    r.append(e);

    long[] ans = { 3, 2, 4, 0, 1 };
    int i = 0;
    for (Pair<Long, CounterSink> p : r.getHistory()) {
      System.out.printf("time: %,18d count: %8d\n", p.getLeft(), p.getRight()
          .getCount());
      Assert.assertEquals(ans[i], p.getRight().getCount());
      i++;
    }
    r.close();
  }
View Full Code Here

  @Test
  public void testTestCountHistoryClocked() throws IOException {
    MockClock m = new MockClock(0);
    Clock.setClock(m);

    CountHistoryReporter r = new CountHistoryReporter("test timeline", 500, t);
    r.open();
    Event e = new EventImpl("Test message".getBytes());

    // just a little forward to make things slighlty "out of sync"
    // 3
    r.append(e);
    r.append(e);
    r.append(e);
    m.forward(501);

    // 2
    r.append(e);
    r.append(e);
    m.forward(501);

    // 4
    r.append(e);
    r.append(e);
    r.append(e);
    r.append(e);
    m.forward(501);

    // 0 // this never registers!
    m.forward(501);

    // 1
    r.append(e);
    m.forward(501);

    r.append(e);

    long[] times = { 0, 501, 1002, 1503, 2004 };
    long[] ans = { 3, 2, 4, 0, 1 };
    int i = 0;
    for (Pair<Long, CounterSink> p : r.getHistory()) {
      System.out.printf("time: %8d count: %8d\n", p.getLeft(), p.getRight()
          .getCount());
      Assert.assertEquals(ans[i], p.getRight().getCount());
      Assert.assertEquals((long) p.getLeft(), times[i]);
      i++;
    }
    r.close();
  }
View Full Code Here

TOP

Related Classes of com.cloudera.flume.reporter.history.CountHistoryReporter

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.