Package com.cloudera.util

Examples of com.cloudera.util.Benchmark


*/
public class PerfSyslogFormats implements ExamplePerfData {

  @Test
  public void testSyslogFormat() throws IOException, EventExtractException {
    Benchmark b = new Benchmark("Syslog format + nullsink");
    b.mark("begin");
    TextFileSource txt = new TextFileSource(SYSLOG_LOG); // 23244 entires
    txt.open();
    MemorySinkSource mem = new MemorySinkSource();
    mem.open();
    EventUtil.dumpAll(txt, mem);
    txt.close();

    b.mark("disk_loaded");
    Event e = null;
    NullSink sink = new NullSink();
    SyslogEntryFormat syslog = new SyslogEntryFormat();
    while ((e = mem.next()) != null) {
      Event e2 = syslog.extract(new String(e.getBody()), 2009);
      sink.append(e2);
    }
    sink.close();
    b.mark("warmup done");

    e = null;
    mem.open();
    while ((e = mem.next()) != null) {
      Event e2 = syslog.extract(new String(e.getBody()), 2009);
      sink.append(e2);
    }
    sink.close();
    b.mark("sample dump done");

    e = null;
    mem.open();
    CounterSink sink2 = new CounterSink("counter");

    while ((e = mem.next()) != null) {
      Event e2 = syslog.extract(new String(e.getBody()), 2009);
      sink2.append(e2);
    }
    sink2.close();
    b.mark("count done", sink2.getCount());

    b.done();
  }
View Full Code Here


*/
public class PerfReportSinks implements ExamplePerfData {

  @Test
  public void testNullSink() throws IOException {
    Benchmark b = new Benchmark("nullsink");
    b.mark("begin");
    TextFileSource txt = new TextFileSource(HADOOP_DATA[0]);
    txt.open();
    MemorySinkSource mem = new MemorySinkSource();
    mem.open();
    EventUtil.dumpAll(txt, mem);

    b.mark("disk_loaded");

    EventSink nullsnk = new NullSink();
    EventUtil.dumpAll(mem, nullsnk);
    b.mark("nullsink done");

    b.done();
  }
View Full Code Here

    b.done();
  }

  @Test
  public void testCountSink() throws IOException {
    Benchmark b = new Benchmark("nullsink");
    b.mark("begin");
    TextFileSource txt = new TextFileSource(HADOOP_DATA[0]);
    txt.open();
    MemorySinkSource mem = new MemorySinkSource();
    mem.open();
    EventUtil.dumpAll(txt, mem);

    b.mark("disk_loaded");

    CounterSink snk = new CounterSink("counter");
    EventUtil.dumpAll(mem, snk);
    b.mark(snk.getName() + " done", snk.getCount());

    b.done();
  }
View Full Code Here

    b.done();
  }

  @Test
  public void testHadoopRegexes() throws IOException {
    Benchmark b = new Benchmark("hadoop_regexes");
    b.mark("begin");
    TextFileSource txt = new TextFileSource(HADOOP_DATA[0]);
    txt.open();
    MemorySinkSource mem = new MemorySinkSource();
    mem.open();
    EventUtil.dumpAll(txt, mem);

    b.mark("disk_loaded");

    SimpleRegexReporterBuilder bld = new SimpleRegexReporterBuilder(
        HADOOP_REGEXES);

    Collection<RegexGroupHistogramSink> sinks = bld.load();
    MultiReporter snk = new MultiReporter("hadoop_regex_sinks", sinks);
    snk.open();
    b.mark("filters_loaded", new File(HADOOP_REGEXES).getName(), sinks.size());

    EventUtil.dumpAll(mem, snk);
    b.mark(snk.getName() + " done");

    b.done();
  }
View Full Code Here

    b.done();
  }

  @Test
  public void testHadoopRegexes11() throws IOException {
    Benchmark b = new Benchmark("hadoop_regexes");
    b.mark("begin");
    TextFileSource txt = new TextFileSource(HADOOP_DATA[0]);
    txt.open();
    MemorySinkSource mem = new MemorySinkSource();
    mem.open();
    EventUtil.dumpAll(txt, mem);

    b.mark("disk_loaded");

    SimpleRegexReporterBuilder bld = new SimpleRegexReporterBuilder(
        HADOOP_REGEXES_11);

    Collection<RegexGroupHistogramSink> sinks = bld.load();
    MultiReporter snk = new MultiReporter("hadoop_regex_sinks", sinks);
    snk.open();
    b.mark("filters_loaded", new File(HADOOP_REGEXES_11).getName(), sinks
        .size());

    EventUtil.dumpAll(mem, snk);
    b.mark(snk.getName() + " done");

    b.done();
  }
View Full Code Here

   * mem -> ThriftEventSink -> ThriftEventSource -> NullSink
   */
  @Test
  public void testThriftSend() throws IOException {

    Benchmark b = new Benchmark("nullsink");

    b.mark("begin");

    TextFileSource txt = new TextFileSource(HADOOP_DATA[0]);
    txt.open();
    MemorySinkSource mem = new MemorySinkSource();
    mem.open();
    EventUtil.dumpAll(txt, mem);
    txt.close();
    b.mark("disk_loaded");

    FlumeConfiguration conf = FlumeConfiguration.get();
    final ThriftEventSource tes = new ThriftEventSource(conf.getCollectorPort());
    tes.open();
    // need to drain the sink otherwise its queue will fill up with events!
    Thread drain = new Thread("drain") {
      public void run() {
        try {
          EventUtil.dumpAll(tes, new NullSink());
        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
    };
    drain.start(); // drain the sink.
    b.mark("receiver_started");

    final ThriftEventSink snk = new ThriftEventSink("0.0.0.0", conf
        .getCollectorPort());
    snk.open();
    b.mark("sink_started");

    EventUtil.dumpAll(mem, snk);
    b.mark("thrift sink to thrift source done");

    tes.close();
    snk.close();
    drain.interrupt();
    b.done();
  }
View Full Code Here

   * mem -> ThriftEventSink -> ThriftEventSource -> NullSink
   **/
  @Test
  public void testThriftSendMulti() throws IOException, InterruptedException {

    Benchmark b = new Benchmark("nullsink");
    b.mark("begin");

    TextFileSource txt = new TextFileSource(HADOOP_DATA[0]);
    txt.open();
    MemorySinkSource mem = new MemorySinkSource();
    mem.open();
    EventUtil.dumpAll(txt, mem);
    txt.close();
    b.mark("disk_loaded");

    FlumeConfiguration conf = FlumeConfiguration.get();
    final ThriftEventSource tes = new ThriftEventSource(conf.getCollectorPort());
    tes.open();
    // need to drain the sink otherwise its queue will fill up with events!
    Thread drain = new Thread("drain") {
      public void run() {
        try {
          EventUtil.dumpAll(tes, new NullSink());
        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
    };
    drain.start(); // drain the sink.
    b.mark("receiver_started");

    final ThriftEventSink snk = new ThriftEventSink("0.0.0.0", conf
        .getCollectorPort());

    Thread t = new Thread() {
      public void run() {
        try {
          snk.open();
        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
    };
    t.start();
    b.mark("sink_started");

    EventUtil.dumpAll(mem, snk);
    b.mark("thrift sink to thrift source done");

    Thread.sleep(1000);
    tes.close();
    snk.close();
    t.interrupt();
    drain.interrupt();
    b.done();
  }
View Full Code Here

   * mem -> ThriftRawEventSink -> ThriftEventSource -> NullSink
   */
  @Test
  public void testThriftRawSend() throws IOException {

    Benchmark b = new Benchmark("nullsink");

    b.mark("begin");

    TextFileSource txt = new TextFileSource(HADOOP_DATA[0]);
    txt.open();
    MemorySinkSource mem = new MemorySinkSource();
    mem.open();
    EventUtil.dumpAll(txt, mem);
    txt.close();
    b.mark("disk_loaded");

    FlumeConfiguration conf = FlumeConfiguration.get();
    final ThriftEventSource tes = new ThriftEventSource(conf.getCollectorPort());
    tes.open();
    // need to drain the sink otherwise its queue will fill up with events!
    Thread drain = new Thread("drain") {
      public void run() {
        try {
          EventUtil.dumpAll(tes, new NullSink());
        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
    };
    drain.start(); // drain the sink.
    b.mark("receiver_started");

    final ThriftEventSink snk = new ThriftEventSink("0.0.0.0", conf
        .getCollectorPort());
    snk.open();
    b.mark("sink_started");

    EventUtil.dumpAll(mem, snk);
    b.mark("thrift sink to thrift source done");

    tes.close();
    snk.close();
    drain.interrupt();
    b.done();
  }
View Full Code Here

*/
public class PerfGrepReportSinks implements ExamplePerfData {

  @Test
  public void testHadoopGrep() throws IOException {
    Benchmark b = new Benchmark("hadoop_greps");
    b.mark("begin");

    MultiGrepReporterBuilder bld = new MultiGrepReporterBuilder(HADOOP_GREP);

    MultiGrepReporterSink<String> snk = bld.load().iterator().next();
    snk.open();
    b.mark("filters_loaded", new File(HADOOP_GREP).getName());

    TextFileSource txt = new TextFileSource(HADOOP_DATA[0]);
    txt.open();
    MemorySinkSource mem = new MemorySinkSource();
    mem.open();
    EventUtil.dumpAll(txt, mem);

    b.mark("disk_loaded");

    EventUtil.dumpAll(mem, snk);
    b.mark(snk.getName() + " done");

    Histogram<String> histo = snk.getHistogram();
    System.out.println(histo);
   
    // from grep | wc
    Assert.assertEquals(230659, histo.get("NullPointerException"));
    Assert.assertEquals(2916, histo.get("ConnectException"));
    Assert.assertEquals(230663, histo.get("Lost tracker"));
    Assert.assertEquals(166834, histo.get("mapred.TaskTracker: Resending"));
   
   
    b.done();
  }
View Full Code Here

*/
public class PerfDiskIO implements ExamplePerfData {

  @Test
  public void testWrite() throws IOException {
    Benchmark b = new Benchmark("seqfile write");
    b.mark("begin");

    TextFileSource txt = new TextFileSource(HADOOP_DATA[0]);
    txt.open();
    MemorySinkSource mem = new MemorySinkSource();
    mem.open();
    EventUtil.dumpAll(txt, mem);
    txt.close();
    b.mark("disk_loaded");

    File tmp = File.createTempFile("test", "tmp");
    tmp.deleteOnExit();
    SeqfileEventSink sink = new SeqfileEventSink(tmp);
    sink.open();
    b.mark("receiver_started");

    EventUtil.dumpAll(mem, sink);

    b.mark("seqfile_disk_write");

    sink.close();
    b.mark("seqfile size", tmp.length());
    b.done();

    // //////// second phase using the file written in previous phase.
    Benchmark b2 = new Benchmark("seqfile_disk_read");
    b2.mark("begin");

    SeqfileEventSource seq = new SeqfileEventSource(tmp.getAbsolutePath());
    seq.open();
    MemorySinkSource mem2 = new MemorySinkSource();
    EventUtil.dumpAll(seq, mem2);
    seq.close();
    b2.mark("seqfile_loaded");

    b2.done();
  }
View Full Code Here

TOP

Related Classes of com.cloudera.util.Benchmark

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.