Package com.cloudera.flume.core

Examples of com.cloudera.flume.core.EventSink


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

    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++) {

        snk.open();
        System.out.println(i + " connections...");
      }
    } catch (IOException io) {
      System.out.println(io);
      b.mark("conns", i);
View Full Code Here


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

      EventSink snk = FlumeBuilder.buildSink(LogicalNodeContext.testingContext(),
          "thrift(\"0.0.0.0\",31337)");
      snk.open();
      System.out.println(i + " connections...");
      snk.close();
    }

    src.close();
    b.done();
  }
View Full Code Here

   */
  @Test
  public void testInsistentRetry() {
    final MockClock m = new MockClock(0);

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

      @Override
View Full Code Here

   */
  @Test
  public void testInsistentOpenCancel() throws IOException,
      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);
View Full Code Here

  @Test
  public void testInsistentOpenMetrics() throws JSONException,
      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));
View Full Code Here

        }

        if (argv.length >= 4) {
          ganglias = argv[3];
        }
        EventSink snk = new GangliaSink(ganglias, attr, units, t);
        return snk;

      }
    };
  }
View Full Code Here

  public void loadConfig(FlumeConfigData cfg) throws IOException,
      RuntimeException, FlumeSpecException {

    // got a newer configuration
    LOG.debug("Attempt to load config " + cfg);
    EventSink newSnk = null;
    EventSource newSrc = null;
    try {
      String errMsg = null;
      if (cfg.sinkConfig == null || cfg.sinkConfig.length() == 0) {
        errMsg = this.getName() + " - empty sink";
      }

      if (cfg.sourceConfig == null || cfg.sourceConfig.length() == 0) {
        errMsg = this.getName() + " - empty source";
      }

      if (errMsg != null) {
        LOG.info(errMsg);
        return; // Do nothing.
      }

      // TODO (jon) ERROR isn't quite right here -- the connection is in ERROR
      // but the previous connection is ok. Need to just add states to the
      // connections, and have each node maintain a list of connections.

      newSnk = FlumeBuilder.buildSink(ctx, cfg.sinkConfig);
      if (newSnk == null) {
        LOG.error("failed to create sink config: " + cfg.sinkConfig);
        state.state = NodeState.ERROR;
        return;
      }

      newSrc = FlumeBuilder.buildSource(ctx, cfg.sourceConfig);
      if (newSrc == null) {
        newSnk.close(); // close the open sink.
        LOG.error("failed to create sink config: " + cfg.sourceConfig);
        state.state = NodeState.ERROR;
        return;
      }
View Full Code Here

  @Test
  public void testInsistentAppendMetrics() throws JSONException,
      FlumeSpecException, IOException, InterruptedException {
    ReportTestUtils.setupSinkFactory();

    EventSink snk = FlumeBuilder.buildSink(new ReportTestingContext(),
        "insistentAppend one");
    ReportEvent rpt = ReportUtil.getFlattenedReport(snk);
    LOG.info(ReportUtil.toJSONObject(rpt).toString());
    assertNotNull(rpt.getLongMetric(InsistentAppendDecorator.A_ATTEMPTS));
    assertNotNull(rpt.getLongMetric(InsistentAppendDecorator.A_GIVEUPS));
View Full Code Here

   * Test insistent append metrics
   */
  @Test
  public void testTextFileMetrics() throws JSONException, FlumeSpecException,
      IOException, InterruptedException {
    EventSink snk = FlumeBuilder.buildSink(new ReportTestingContext(),
        "text(\"filename\")");
    ReportEvent rpt = ReportUtil.getFlattenedReport(snk);
    LOG.info(ReportUtil.toJSONObject(rpt).toString());
    assertNotNull(rpt.getLongMetric(ReportEvent.A_COUNT));
  }
View Full Code Here

      public EventSink build(Context context, String... argv) {
        if (argv.length != 1) {
          throw new IllegalArgumentException("need only a name argument");
        }

        EventSink snk = new CounterSink(argv[0]);

        if (context.getValue(ReportTestingContext.TESTING_REPORTS) != null) {
          ReportManager.get().add(snk);
        }
View Full Code Here

TOP

Related Classes of com.cloudera.flume.core.EventSink

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.