Package com.cloudera.flume.core

Examples of com.cloudera.flume.core.EventSource


    sink.close();
    assertEquals(0, wal.getWritingTags().size());
    assertEquals(1, wal.getLoggedTags().size());

    // logged values can transition to the sending state by getting a sender.
    EventSource curSource = wal.getUnsentSource();
    // no state change
    assertEquals(0, wal.getWritingTags().size());
    assertEquals(0, wal.getLoggedTags().size());
    assertEquals(1, wal.getSendingTags().size());

    // open changes state
    curSource.open();
    assertEquals(0, wal.getLoggedTags().size());
    assertEquals(1, wal.getSendingTags().size());

    // read next event
    Event e = null;
    ConsoleEventSink console = new ConsoleEventSink();
    while ((e = curSource.next()) != null) {
      console.append(e);
    }
    curSource.close();
    assertEquals(0, wal.getSendingTags().size());
  }
View Full Code Here


    corrupt.deleteOnExit();

    // check now, and any age is too old.
    File commit = new File(tmpdir, "committed");
    commit.deleteOnExit();
    EventSource src = new SeqfileEventSource(corrupt.getAbsolutePath());

    try {
      src.open(); // expect IOException
    } catch (IOException e) {
      throw e;
    } finally {
      FileUtil.rmr(tmpdir);
    }
View Full Code Here

  }

  @Test
  public void testOpenClose() throws IOException, TException,
      InterruptedException {
    EventSource src = ScribeEventSource.builder().build("45872");
    for (int i = 0; i < 10; ++i) {
      src.open();
      src.close();
    }
    src.open();

    // Open the client connection
    TTransport transport = new TSocket("localhost", 45872);
    transport = new TFramedTransport(transport);
    // scribe clients do not use strict write
    TProtocol protocol = new TBinaryProtocol(transport, false, false);
    transport.open();
    scribe.Client client = new scribe.Client(protocol);

    // Note - there is a tiny possibility of a race here, which is why we retry
    for (int i = 0; i < 3; ++i) {
      if (client.getStatus() != fb_status.ALIVE) {
        Thread.sleep(500);
      } else {
        break;
      }
    }
    assertEquals("ScribeEventSource did not come up in time!", fb_status.ALIVE,
        client.getStatus());
    src.close();
  }
View Full Code Here

  public void testBuildTextSource() throws IOException, FlumeSpecException,
      InterruptedException {
    Context ctx = LogicalNodeContext.testingContext();

    // 25 lines of 100 bytes of ascii
    EventSource src = srcfact.getSource(ctx, "asciisynth", "25", "100");
    src.open();
    Event e = null;
    int cnt = 0;
    while ((e = src.next()) != null) {
      System.out.println(e);
      cnt++;
    }
    src.close();
    assertEquals(LINES, cnt);
  }
View Full Code Here

    Context ctx = LogicalNodeContext.testingContext();

    EventSink snk = fact.getSink(ctx, "console");
    snk.open();

    EventSource src = srcfact.getSource(ctx, "asciisynth", "25", "100");
    src.open();

    DirectDriver conn = new DirectDriver(src, snk);
    conn.start();

    conn.join(Long.MAX_VALUE);

    snk.close();
    src.close();
  }
View Full Code Here

  @Test
  public void testDecorator() throws IOException, FlumeSpecException,
      InterruptedException {
    Context ctx = LogicalNodeContext.testingContext();
    EventSource src = srcfact.getSource(ctx, "asciisynth", "25", "100");
    src.open();

    EventSinkDecorator<EventSink> deco =

    fact.getDecorator(new Context(), "intervalSampler", "5");
    EventSink snk = fact.getSink(new Context(), "counter", "name");
View Full Code Here

  public void testRpcSourceSinksInit() throws FlumeSpecException {
    FlumeConfiguration.get().set(FlumeConfiguration.EVENT_RPC_TYPE, "garbage");
    Context ctx = LogicalNodeContext.testingContext();

    // making sure default is Thrift
    EventSource rpcSrc = srcfact.getSource(ctx, "rpcSource", "31337");
    EventSink rpcSink = fact.getSink(new Context(), "rpcSink", "0.0.0.0",
        "31337");
    assertEquals(ThriftEventSource.class, rpcSrc.getClass());
    assertEquals(ThriftEventSink.class, rpcSink.getClass());

    // make sure initializing to Thrift indeed gives us ThriftEvent sources and
    // sinks.
    FlumeConfiguration.get().set(FlumeConfiguration.EVENT_RPC_TYPE, "THRIFT");
    rpcSrc = srcfact.getSource(ctx, "rpcSource", "31337");
    rpcSink = fact.getSink(new Context(), "rpcSink", "0.0.0.0", "31337");
    assertEquals(ThriftEventSource.class, rpcSrc.getClass());
    assertEquals(ThriftEventSink.class, rpcSink.getClass());

    // make sure initializing to Avro indeed gives us AvroEvent sources and
    // sinks.
    FlumeConfiguration.get().set(FlumeConfiguration.EVENT_RPC_TYPE, "AVRO");
    rpcSrc = srcfact.getSource(ctx, "rpcSource", "31337");
    rpcSink = fact.getSink(new Context(), "rpcSink", "0.0.0.0", "31337");
    assertEquals(AvroEventSource.class, rpcSrc.getClass());
    assertEquals(AvroEventSink.class, rpcSink.getClass());
  }
View Full Code Here

      InterruptedException, FlumeSpecException {
    FlumeConfiguration.get().set(FlumeConfiguration.EVENT_RPC_TYPE, rpcType);
    Log.info("Testing a more complicated pipeline with a " + rpcType
        + " network connection in the middle");
    Context ctx = LogicalNodeContext.testingContext();
    EventSource rpcSrc = srcfact.getSource(ctx, "rpcSource", "31337");
    EventSink rpcSink = fact.getSink(ctx, "rpcSink", "0.0.0.0", "31337");
    // Rpcsrc needs to be started before the Rpcsink can connect to it.
    rpcSrc.open();
    rpcSink.open();

    Thread.sleep(100); // need some time to open the connector.

    EventSink counter = fact.getSink(ctx, "counter", "count");
    EventSource txtsrc = srcfact.getSource(ctx, "asciisynth", "25", "100");
    counter.open();
    txtsrc.open();

    DirectDriver svrconn = new DirectDriver(rpcSrc, counter);
    svrconn.start();

    DirectDriver cliconn = new DirectDriver(txtsrc, rpcSink);
    cliconn.start();

    cliconn.join(Long.MAX_VALUE);
    Thread.sleep(250);

    svrconn.stop();
    rpcSink.close();
    rpcSrc.close();

    counter.close();
    txtsrc.close();

    LOG.info("read " + ((CounterSink) counter).getCount() + " lines");
    assertEquals(LINES, ((CounterSink) counter).getCount());
    assertNull(cliconn.getError());
    assertNull(svrconn.getError());
View Full Code Here

                .testingContext(), dfoMan, new TimeTrigger(100), 50);

            ReportManager.get().add(cnt1);
            // make each parallel instance send a slightly different number of
            // messages.
            EventSource src = new NoNlASCIISynthSource(events + idx, 100);

            src.open();
            snk.open();

            started.countDown();

            EventUtil.dumpAll(src, snk);
            src.close();
            snk.close(); // this triggers a flush of current file!?
            FileUtil.rmr(f1);
          } catch (Exception e) {
            LOG.error(e, e);
          } finally {
View Full Code Here

   *
   * @throws InterruptedException
   */
  @Test
  public void testAvroSend() throws IOException, InterruptedException {
    EventSource txt = new NoNlASCIISynthSource(25, 100);
    txt.open();
    MemorySinkSource mem = new MemorySinkSource();
    mem.open();
    EventUtil.dumpAll(txt, mem);
    txt.close();

    FlumeConfiguration conf = FlumeConfiguration.get();
    final AvroEventSource tes = new AvroEventSource(conf.getCollectorPort() + 1);
    tes.open();

View Full Code Here

TOP

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

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.