Package org.apache.hadoop.hbase.trace

Examples of org.apache.hadoop.hbase.trace.SpanReceiverHost


    if (!masterRecovery) {
      // initialize master side coprocessors before we start handling requests
      status.setStatus("Initializing master coprocessors");
      this.cpHost = new MasterCoprocessorHost(this, this.conf);

      spanReceiverHost = new SpanReceiverHost(getConfiguration());
      spanReceiverHost.loadSpanReceivers();

      // start up all service threads.
      status.setStatus("Initializing master service threads");
      startServiceThreads();
View Full Code Here


    // First set the fs from configs.  In case we are on hadoop1
    FSUtils.setFsDefault(getConf(), FSUtils.getRootDir(getConf()));
    FileSystem fs = FileSystem.get(getConf());
    LOG.info("FileSystem: " + fs);

    SpanReceiverHost receiverHost = trace ? SpanReceiverHost.getInstance(getConf()) : null;
    TraceScope scope = Trace.startSpan("HLogPerfEval", trace ? Sampler.ALWAYS : Sampler.NEVER);

    try {
      if (rootRegionDir == null) {
        rootRegionDir = TEST_UTIL.getDataTestDirOnTestFS("HLogPerformanceEvaluation");
      }
      rootRegionDir = rootRegionDir.makeQualified(fs);
      cleanRegionRootDir(fs, rootRegionDir);
      // Initialize Table Descriptor
      HTableDescriptor htd = createHTableDescriptor(numFamilies);
      final long whenToRoll = roll;
      final HLog hlog = new FSHLog(fs, rootRegionDir, "wals", getConf()) {

        @Override
        public void postSync(final long timeInNanos, final int handlerSyncs) {
          super.postSync(timeInNanos, handlerSyncs);
          syncMeter.mark();
          syncHistogram.update(timeInNanos);
          syncCountHistogram.update(handlerSyncs);
        }

        @Override
        public long postAppend(final HLog.Entry entry, final long elapsedTime) {
          long size = super.postAppend(entry, elapsedTime);
          appendMeter.mark(size);
          return size;
        }
      };
      hlog.registerWALActionsListener(new WALActionsListener() {
        private int appends = 0;

        @Override
        public void visitLogEntryBeforeWrite(HTableDescriptor htd, HLogKey logKey,
            WALEdit logEdit) {
          this.appends++;
          if (this.appends % whenToRoll == 0) {
            LOG.info("Rolling after " + appends + " edits");
            // We used to do explicit call to rollWriter but changed it to a request
            // to avoid dead lock (there are less threads going on in this class than
            // in the regionserver -- regionserver does not have the issue).
            ((FSHLog)hlog).requestLogRoll();
          }
        }

        @Override
        public void visitLogEntryBeforeWrite(HRegionInfo info, HLogKey logKey, WALEdit logEdit) {
        }

        @Override
        public void preLogRoll(Path oldPath, Path newPath) throws IOException {
        }

        @Override
        public void preLogArchive(Path oldPath, Path newPath) throws IOException {
        }

        @Override
        public void postLogRoll(Path oldPath, Path newPath) throws IOException {
        }

        @Override
        public void postLogArchive(Path oldPath, Path newPath) throws IOException {
        }

        @Override
        public void logRollRequested() {
        }

        @Override
        public void logCloseRequested() {
        }
      });
      hlog.rollWriter();
      HRegion region = null;

      try {
        region = openRegion(fs, rootRegionDir, htd, hlog);
        ConsoleReporter.enable(this.metrics, 30, TimeUnit.SECONDS);
        long putTime =
          runBenchmark(Trace.wrap(
              new HLogPutBenchmark(region, htd, numIterations, noSync, syncInterval, traceFreq)),
            numThreads);
        logBenchmarkResult("Summary: threads=" + numThreads + ", iterations=" + numIterations +
          ", syncInterval=" + syncInterval, numIterations * numThreads, putTime);
       
        if (region != null) {
          closeRegion(region);
          region = null;
        }
        if (verify) {
          Path dir = ((FSHLog) hlog).getDir();
          long editCount = 0;
          FileStatus [] fsss = fs.listStatus(dir);
          if (fsss.length == 0) throw new IllegalStateException("No WAL found");
          for (FileStatus fss: fsss) {
            Path p = fss.getPath();
            if (!fs.exists(p)) throw new IllegalStateException(p.toString());
            editCount += verify(p, verbose);
          }
          long expected = numIterations * numThreads;
          if (editCount != expected) {
            throw new IllegalStateException("Counted=" + editCount + ", expected=" + expected);
          }
        }
      } finally {
        if (region != null) closeRegion(region);
        // Remove the root dir for this test region
        if (cleanup) cleanRegionRootDir(fs, rootRegionDir);
      }
    } finally {
      // We may be called inside a test that wants to keep on using the fs.
      if (!noclosefs) fs.close();
      scope.close();
      if (receiverHost != null) receiverHost.closeReceivers();
    }

    return(0);
  }
View Full Code Here

    // First set the fs from configs.  In case we are on hadoop1
    FSUtils.setFsDefault(getConf(), FSUtils.getRootDir(getConf()));
    FileSystem fs = FileSystem.get(getConf());
    LOG.info("FileSystem: " + fs);

    SpanReceiverHost receiverHost = trace ? SpanReceiverHost.getInstance(getConf()) : null;
    TraceScope scope = Trace.startSpan("HLogPerfEval", trace ? Sampler.ALWAYS : Sampler.NEVER);

    try {
      if (rootRegionDir == null) {
        rootRegionDir = TEST_UTIL.getDataTestDirOnTestFS("HLogPerformanceEvaluation");
      }
      rootRegionDir = rootRegionDir.makeQualified(fs);
      cleanRegionRootDir(fs, rootRegionDir);
      // Initialize Table Descriptor
      HTableDescriptor htd = createHTableDescriptor(numFamilies);
      final long whenToRoll = roll;
      final HLog hlog = new FSHLog(fs, rootRegionDir, "wals", getConf()) {

        @Override
        public void postSync(final long timeInNanos, final int handlerSyncs) {
          super.postSync(timeInNanos, handlerSyncs);
          syncMeter.mark();
          syncHistogram.update(timeInNanos);
          syncCountHistogram.update(handlerSyncs);
        }

        @Override
        public long postAppend(final HLog.Entry entry, final long elapsedTime) {
          long size = super.postAppend(entry, elapsedTime);
          appendMeter.mark(size);
          return size;
        }
      };
      hlog.registerWALActionsListener(new WALActionsListener() {
        private int appends = 0;

        @Override
        public void visitLogEntryBeforeWrite(HTableDescriptor htd, HLogKey logKey,
            WALEdit logEdit) {
          this.appends++;
          if (this.appends % whenToRoll == 0) {
            LOG.info("Rolling after " + appends + " edits");
            // We used to do explicit call to rollWriter but changed it to a request
            // to avoid dead lock (there are less threads going on in this class than
            // in the regionserver -- regionserver does not have the issue).
            ((FSHLog)hlog).requestLogRoll();
          }
        }

        @Override
        public void visitLogEntryBeforeWrite(HRegionInfo info, HLogKey logKey, WALEdit logEdit) {
        }

        @Override
        public void preLogRoll(Path oldPath, Path newPath) throws IOException {
        }

        @Override
        public void preLogArchive(Path oldPath, Path newPath) throws IOException {
        }

        @Override
        public void postLogRoll(Path oldPath, Path newPath) throws IOException {
        }

        @Override
        public void postLogArchive(Path oldPath, Path newPath) throws IOException {
        }

        @Override
        public void logRollRequested() {
        }

        @Override
        public void logCloseRequested() {
        }
      });
      hlog.rollWriter();
      HRegion region = null;

      try {
        region = openRegion(fs, rootRegionDir, htd, hlog);
        ConsoleReporter.enable(this.metrics, 30, TimeUnit.SECONDS);
        long putTime =
          runBenchmark(Trace.wrap(
              new HLogPutBenchmark(region, htd, numIterations, noSync, syncInterval, traceFreq)),
            numThreads);
        logBenchmarkResult("Summary: threads=" + numThreads + ", iterations=" + numIterations +
          ", syncInterval=" + syncInterval, numIterations * numThreads, putTime);
       
        if (region != null) {
          closeRegion(region);
          region = null;
        }
        if (verify) {
          Path dir = ((FSHLog) hlog).getDir();
          long editCount = 0;
          FileStatus [] fsss = fs.listStatus(dir);
          if (fsss.length == 0) throw new IllegalStateException("No WAL found");
          for (FileStatus fss: fsss) {
            Path p = fss.getPath();
            if (!fs.exists(p)) throw new IllegalStateException(p.toString());
            editCount += verify(p, verbose);
          }
          long expected = numIterations * numThreads;
          if (editCount != expected) {
            throw new IllegalStateException("Counted=" + editCount + ", expected=" + expected);
          }
        }
      } finally {
        if (region != null) closeRegion(region);
        // Remove the root dir for this test region
        if (cleanup) cleanRegionRootDir(fs, rootRegionDir);
      }
    } finally {
      // We may be called inside a test that wants to keep on using the fs.
      if (!noclosefs) fs.close();
      scope.close();
      if (receiverHost != null) receiverHost.closeReceivers();
    }

    return(0);
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.trace.SpanReceiverHost

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.