Package com.cloudera.flume.reporter

Examples of com.cloudera.flume.reporter.ReportEvent


  /**
   * Get reportable data from the Avro event source.
   */
  @Override
  synchronized public ReportEvent getMetrics() {
    ReportEvent rpt = super.getMetrics();
    rpt.setLongMetric(A_QUEUE_CAPACITY, q.size());
    rpt.setLongMetric(A_QUEUE_FREE, q.remainingCapacity());
    rpt.setLongMetric(A_ENQUEUED, enqueued.get());
    rpt.setLongMetric(A_DEQUEUED, dequeued.get());
    rpt.setLongMetric(A_BYTES_IN, bytesIn.get());
    return rpt;
  }
View Full Code Here


    }
  }

  @Override
  public ReportEvent getMetrics() {
    ReportEvent rpt = super.getMetrics();
    rpt.setStringMetric(A_SERVERHOST, host);
    rpt.setLongMetric(A_SERVERPORT, port);
    rpt.setLongMetric(A_SENTBYTES, sentBytes.get());
    return rpt;
  }
View Full Code Here

  }

  @Deprecated
  @Override
  public ReportEvent getReport() {
    ReportEvent rpt = super.getReport();
    rpt.setStringMetric(A_SERVERHOST, host);
    rpt.setLongMetric(A_SERVERPORT, port);
    rpt.setLongMetric(A_SENTBYTES, sentBytes.get());
    return rpt;
  }
View Full Code Here

  /**
   * {@inheritDoc}
   */
  @Override
  public ReportEvent getMetrics() {
    ReportEvent rpt = super.getMetrics();
    rpt.setStringMetric(A_SERVERHOST, host);
    rpt.setLongMetric(A_SERVERPORT, port);
    rpt.setLongMetric(A_SENTBYTES, sentBytes.get());
    return rpt;
  }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    @Override
    synchronized public ReportEvent getMetrics() {
      return new ReportEvent(getName());
    }
View Full Code Here

     * {@inheritDoc}
     */
    @Deprecated
    @Override
    public ReportEvent getReport() {
      ReportEvent rpt = new ReportEvent(getName());

      rpt.setStringMetric(R_TYPE, getName());
      rpt.setLongMetric(R_NUM_BYTES, numBytes);
      rpt.setLongMetric(R_NUM_EVENTS, numEvents);

      return rpt;
    }
View Full Code Here

    // TODO(henry): this test relies on real clocks, and shouldn't. See below.
    EventSink fail2x = mock(EventSink.Base.class);
    // two exceptions then some success
    doThrow(new IOException("mock2")).doThrow(new IOException("mock"))
        .doNothing().when(fail2x).open();
    doReturn(new ReportEvent("stub")).when(fail2x).getMetrics();

    // max 5s, backoff initially at 10ms

    // WARNING! This test relies on being able to sleep for ~10ms and be woken
    // up three times in a 5s period. Seems plausible! But if you are looking at
    // this comment, it's probably because the test is failing on a loaded
    // machine...
    BackoffPolicy bop = new CappedExponentialBackoff(10, 5000);
    InsistentOpenDecorator<EventSink> sink = new InsistentOpenDecorator<EventSink>(
        fail2x, bop);
    sink.open();
    sink.append(new EventImpl("test".getBytes()));
    sink.close();
    fail2x.getMetrics();

    ReportEvent rpt = sink.getMetrics();
    assertEquals(new Long(1), rpt
        .getLongMetric(InsistentOpenDecorator.A_REQUESTS));
    assertEquals(new Long(3), rpt
        .getLongMetric(InsistentOpenDecorator.A_ATTEMPTS));
    assertEquals(new Long(1), rpt
        .getLongMetric(InsistentOpenDecorator.A_SUCCESSES));
    assertEquals(new Long(2), rpt
        .getLongMetric(InsistentOpenDecorator.A_RETRIES));
    System.out.println(rpt.toText());
  }
View Full Code Here

  public void testInsistentRetry() {
    final MockClock m = new MockClock(0);

    EventSink failWhale = new EventSink.Base() {
      public ReportEvent getMetrics() {
        return new ReportEvent("failwhale-report");
      }

      @Override
      public void open() throws IOException {
        // Forward by 100ms, should cause IOD to try eleven times then give up
        m.forward(100);
        throw new IOException("fail open");
      }
    };

    Clock.setClock(m);
    // max 1s, backoff initially at 10ms, with a maxSingleSleep 1000ms and a
    // cumulative cap of 1000ms
    InsistentOpenDecorator<EventSink> sink = new InsistentOpenDecorator<EventSink>(
        failWhale, 1000, 10, 1000);

    try {
      sink.open();
    } catch (IOException e1) {

      ReportEvent rpt = sink.getMetrics();
      assertEquals(new Long(1), rpt
          .getLongMetric(InsistentOpenDecorator.A_REQUESTS));
      assertEquals(new Long(0), rpt
          .getLongMetric(InsistentOpenDecorator.A_SUCCESSES));

      // 11 attempts - one each at 100 * x for x in [0,1,2,3,4,5,6,7,8,9,10]
      // Retry trigger in IOD only fails when time > max, but passes when time =
      // max.
      assertEquals(new Long(11), rpt
          .getLongMetric(InsistentOpenDecorator.A_ATTEMPTS));
      assertEquals(new Long(11), rpt
          .getLongMetric(InsistentOpenDecorator.A_RETRIES));
      Clock.resetDefault();
      return; // success
    }
    fail("Ehr? Somehow the failwhale succeeded!");
View Full Code Here

      InterruptedException {
    // TODO(henry): this test relies on real clocks, and shouldn't. See below.
    EventSink fail4eva = mock(EventSink.Base.class);
    // two exceptions then some success
    doThrow(new IOException("mock")).when(fail4eva).open();
    doReturn(new ReportEvent("stub")).when(fail4eva).getMetrics();

    final CountDownLatch done = new CountDownLatch(1);

    // max 5s, backoff initially at 10ms
    BackoffPolicy bop = new CappedExponentialBackoff(10, 5000);
View Full Code Here

      FlumeSpecException, IOException, InterruptedException {
    ReportTestUtils.setupSinkFactory();

    EventSink snk = FlumeBuilder.buildSink(new ReportTestingContext(),
        "insistentOpen one");
    ReportEvent rpt = ReportUtil.getFlattenedReport(snk);
    LOG.info(ReportUtil.toJSONObject(rpt).toString());
    assertNotNull(rpt.getLongMetric(InsistentOpenDecorator.A_ATTEMPTS));
    assertNotNull(rpt.getLongMetric(InsistentOpenDecorator.A_GIVEUPS));
    assertNotNull(rpt.getLongMetric(InsistentOpenDecorator.A_REQUESTS));
    assertNotNull(rpt.getLongMetric(InsistentOpenDecorator.A_RETRIES));
    assertNotNull(rpt.getLongMetric(InsistentOpenDecorator.A_SUCCESSES));
    assertNotNull(rpt.getStringMetric("backoffPolicy.CappedExpBackoff.name"));
    assertEquals("One", rpt.getStringMetric("One.name"));

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