Package com.cloudera.util

Examples of com.cloudera.util.Benchmark


    b2.done();
  }

  @Test
  public void testReadFormat() throws IOException {
    Benchmark b = new Benchmark("log4j format read");
    b.mark("begin");

    Log4jTextFileSource txt = new Log4jTextFileSource(HADOOP_DATA[0]);
    txt.open();
    MemorySinkSource mem = new MemorySinkSource();
    mem.open();
    EventUtil.dumpAll(txt, mem);
    txt.close();
    b.mark("log4j_disk_loaded");
    b.done();
  }
View Full Code Here


public class PerfHdfsIO implements ExamplePerfData {

  @Test
  public void testCopy() throws IOException {

    Benchmark b = new Benchmark("hdfs seqfile copy");
    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("localdisk_write_started");

    EventUtil.dumpAll(mem, sink);

    b.mark("local_disk_write done");

    sink.close();

    FlumeConfiguration conf = FlumeConfiguration.get();
    Path src = new Path(tmp.getAbsolutePath());
    Path dst = new Path("hdfs://localhost/testfile");
    FileSystem hdfs = dst.getFileSystem(conf);
    hdfs.deleteOnExit(dst);

    b.mark("hdfs_copy_started");
    hdfs.copyFromLocalFile(src, dst);
    b.mark("hdfs_copy_done");
    hdfs.close();
    b.done();
  }
View Full Code Here

  }

  @Test
  public void testDirectWrite() throws IOException {

    Benchmark b = new Benchmark("hdfs 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");

    FlumeConfiguration conf = FlumeConfiguration.get();
    Path path = new Path("hdfs://localhost/testfile");
    FileSystem hdfs = path.getFileSystem(conf);
    hdfs.deleteOnExit(path);

    Writer w = SequenceFile.createWriter(hdfs, conf, path,
        WriteableEventKey.class, WriteableEvent.class);
    b.mark("hdfs_fileopen_started");

    Event e = null;
    while ((e = mem.next()) != null) {
      // writing
      w.append(new WriteableEventKey(e), new WriteableEvent(e));
    }
    w.close();
    b.mark("seqfile_hdfs_write");

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

    String tag = new String(tagbytes, CharEncUtils.RAW);

    if (Arrays.equals(bench, BenchmarkInjectDecorator.BENCH_START)) {
      StringWriter out = new StringWriter();
      PrintWriter pw = new PrintWriter(out);
      Benchmark b = new Benchmark(tag, pw, pw);
      b.mark("benchmarkStart");
      benchmarks.put(tag, new Pair<Benchmark, StringWriter>(b, out));
    } else if (Arrays.equals(bench, BenchmarkInjectDecorator.BENCH_FIRST)) {
      Benchmark b = benchmarks.get(tag).getLeft();
      b.mark("benchmarkFirst");
    } else if (Arrays.equals(bench, BenchmarkInjectDecorator.BENCH_STOP)) {
      Benchmark b = benchmarks.get(tag).getLeft();
      b.mark("benchmarkDone");
      b.done();

      ReportEvent rpt = getReport();
      LOG.info(rpt.toText());
      reportSink.append(rpt);

    } else if (Arrays.equals(bench, BenchmarkInjectDecorator.BENCH_ERROR)) {
      Benchmark b = benchmarks.get(tag).getLeft();
      b.mark("benchmarkError");
      b.done();
      LOG.info(getReport().toText());

      ReportEvent rpt = getReport();
      LOG.info(rpt.toText());
      reportSink.append(rpt);
View Full Code Here

*/
public class TextToCollector {
  static void core(CommandLine cmd) throws IOException {
    String[] argv = cmd.getArgs();

    Benchmark b = new Benchmark();

    b.mark("init");
    FlumeConfiguration conf = FlumeConfiguration.get();
    ThriftEventSink tes = new ThriftEventSink(conf.getCollectorHost(), conf
        .getCollectorPort(), false);
    tes.open();

    MemorySinkSource mem = cmd.hasOption("m") ? new MemorySinkSource() : null;

    for (String f : argv) {
      EventSource src = null;
      if (cmd.hasOption("l")) {
        b.mark("log4jtext");
        src = new Log4jTextFileSource(f);
      } else if (cmd.hasOption("t")) {
        b.mark("random access text");
        src = new TextFileSource(f);
      } else {
        b.mark("buffered reader text");
        src = new TextReaderSource(f);
      }
      src.open();

      b.mark("fileread");
      if (mem != null) {

        EventUtil.dumpAll(src, mem);
      } else {
        EventUtil.dumpAll(src, tes);
      }
      src.close();
    }

    b.mark("memdump");
    if (mem != null) {
      EventUtil.dumpAll(mem, tes);
    }

    b.mark("done");

    b.done();
    tes.close();

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