Package com.cloudera.flume.reporter

Examples of com.cloudera.flume.reporter.ReportEvent


    agent.open();
    agent.append(e);

    for (int i = 0; i < 30; i++) {
      Clock.sleep(100);
      ReportEvent r = mem.getReport();
      LOG.info(r);
      if (r.getLongMetric("number of events") > 0) {
        return;
      }
    }
    fail("Test timed out, event didn't make it");
  }
View Full Code Here


  /**
   * Create a new ThriftReportServer and add a single report to it
   */
  @Before
  public void startReportServer() throws TTransportException {
    final ReportEvent reportEvent = new ReportEvent("test");

    reportServer = new ThriftReportServer(PORT);
    reportServer.serve();

    reportEvent.setDoubleMetric("doubleAttr", .5);
    Attributes.register("doubleAttr", Type.DOUBLE);
    Reportable reportable = new Reportable() {
      @Override
      public String getName() {
        return "reportable1";
View Full Code Here

  public void testGetFanOutMetrics() throws JSONException, FlumeSpecException {
    ReportTestUtils.setupSinkFactory();

    EventSink snk = FlumeBuilder.buildSink(new ReportTestingContext(),
        "[ one, two, three]");
    ReportEvent rpt = snk.getMetrics();
    LOG.info(ReportUtil.toJSONObject(rpt).toString());
    assertEquals(3, rpt.getLongMetric(FanOutSink.R_SUBSINKS).longValue());
    assertNull(rpt.getStringMetric("Fanout[0].name"));
    assertNull(rpt.getStringMetric("Fanout[1].name"));
    assertNull(rpt.getStringMetric("Fanout[2].name"));

    ReportEvent all = ReportUtil.getFlattenedReport(snk);
    LOG.info(ReportUtil.toJSONObject(all).toString());
    assertEquals(3, rpt.getLongMetric(FanOutSink.R_SUBSINKS).longValue());
    assertEquals("One", all.getStringMetric("Fanout[0].name"));
    assertEquals("Two", all.getStringMetric("Fanout[1].name"));
    assertEquals("Three", all.getStringMetric("Fanout[2].name"));
  }
View Full Code Here

  /**
   * Create a new ReportServer and add a single report to it
   */
  @Before
  public void startReportServer() throws IOException {
    final ReportEvent reportEvent = new ReportEvent("test");

    reportServer = new AvroReportServer(PORT);
    reportServer.serve();
    url = new URL("http", "localhost", PORT, "/");
    reportEvent.setDoubleMetric("doubleAttr", .5);
    Attributes.register("doubleAttr", Type.DOUBLE);
    Reportable reportable = new Reportable() {
      @Override
      public String getName() {
        return "reportable1";
View Full Code Here

  @Test
  public void testGetBackoffFailoverMetrics() throws JSONException {
    ReportTestUtils.setupSinkFactory();
    SinkBuilder bld = BackOffFailOverSink.builder();
    EventSink snk = bld.build(new ReportTestingContext(), "one", "two");
    ReportEvent rpt = snk.getMetrics();
    LOG.info(ReportUtil.toJSONObject(rpt).toString());
    assertNotNull(rpt.getLongMetric(BackOffFailOverSink.A_PRIMARY));
    assertNotNull(rpt.getLongMetric(BackOffFailOverSink.A_FAILS));
    assertNotNull(rpt.getLongMetric(BackOffFailOverSink.A_BACKUPS));
    assertNull(rpt.getStringMetric("primary.one.name"));
    assertNull(rpt.getStringMetric("backup.two.name"));

    ReportEvent all = ReportUtil.getFlattenedReport(snk);
    LOG.info(ReportUtil.toJSONObject(all).toString());
    assertNotNull(all.getLongMetric(BackOffFailOverSink.A_PRIMARY));
    assertNotNull(all.getLongMetric(BackOffFailOverSink.A_FAILS));
    assertNotNull(all.getLongMetric(BackOffFailOverSink.A_BACKUPS));
    assertEquals("One", all.getStringMetric("primary.One.name"));
    assertEquals("Two", all.getStringMetric("backup.Two.name"));
  }
View Full Code Here

  @Test
  public void testGetFailoverMetrics() throws JSONException {
    ReportTestUtils.setupSinkFactory();
    SinkBuilder bld = FailOverSink.builder();
    EventSink snk = bld.build(new ReportTestingContext(), "one", "two");
    ReportEvent rpt = snk.getMetrics();
    LOG.info(ReportUtil.toJSONObject(rpt).toString());
    assertNotNull(rpt.getLongMetric(FailOverSink.R_FAILS));
    assertNotNull(rpt.getLongMetric(FailOverSink.R_BACKUPS));
    assertNull(rpt.getStringMetric("primary.one.name"));
    assertNull(rpt.getStringMetric("backup.two.name"));

    ReportEvent all = ReportUtil.getFlattenedReport(snk);
    LOG.info(ReportUtil.toJSONObject(all).toString());
    assertNotNull(all.getLongMetric(FailOverSink.R_FAILS));
    assertNotNull(all.getLongMetric(FailOverSink.R_BACKUPS));
    assertEquals("One", all.getStringMetric("primary.One.name"));
    assertEquals("Two", all.getStringMetric("backup.Two.name"));
  }
View Full Code Here

    return "FixedRetryPolicy";
  }

  @Override
  public ReportEvent getMetrics() {
    ReportEvent rpt = new ReportEvent(getName());
    Attributes.setLong(rpt, A_MAX_ATTEMPTS, numRetries);
    Attributes.setLong(rpt, A_COUNT, retryCount);
    return rpt;
  }
View Full Code Here

    return "CappedExpBackoff";
  }

  @Override
  public ReportEvent getMetrics() {
    ReportEvent rpt = new ReportEvent(getName());
    rpt.setLongMetric(A_SLEEPCAP, sleepCap);
    rpt.setLongMetric(A_INITIAL, initialSleep);
    rpt.setLongMetric(A_COUNT, backoffCount);
    rpt.setLongMetric(A_CURRENTBACKOFF, sleepIncrement);
    rpt.setLongMetric(A_RETRYTIME, retryTime);
    return rpt;
  }
View Full Code Here

  @Test
  public void testInsistentOpenCancel() throws IOException,
      InterruptedException {
    EventSink fail4eva = mock(EventSink.Base.class);
    doThrow(new IOException("mock exception")).when(fail4eva).open();
    doReturn(new ReportEvent("stub")).when(fail4eva).getMetrics();

    // max 5s, backoff initially at 10ms
    BackoffPolicy bop = new CappedExponentialBackoff(10, 5000);
    final InsistentOpenDecorator<EventSink> insistent = new InsistentOpenDecorator<EventSink>(
        fail4eva, bop);
View Full Code Here

  public void testInsistentAppendCancel() throws IOException,
      InterruptedException {
    EventSink fail4eva = mock(EventSink.Base.class);
    final Event e = new EventImpl("foo".getBytes());
    doThrow(new IOException("mock exception")).when(fail4eva).append(e);
    doReturn(new ReportEvent("mock report")).when(fail4eva).getMetrics();
    doReturn("mock name").when(fail4eva).getName();

    // max 5s, backoff initially at 10ms
    BackoffPolicy bop = new CappedExponentialBackoff(10, 5000);
    final EventSink insistent = new InsistentAppendDecorator<EventSink>(
View Full Code Here

TOP

Related Classes of com.cloudera.flume.reporter.ReportEvent

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.