Package cloudtrace.instrument

Examples of cloudtrace.instrument.Span


          containsMetadataTablet = true;
     
      if (!containsMetadataTablet && us.queuedMutations.size() > 0)
        TabletServer.this.resourceManager.waitUntilCommitsAreEnabled();
     
      Span prep = Trace.start("prep");
      for (Entry<Tablet,? extends List<Mutation>> entry : us.queuedMutations.entrySet()) {
       
        Tablet tablet = entry.getKey();
        List<Mutation> mutations = entry.getValue();
        if (mutations.size() > 0) {
          try {
            if (updateMetrics.isEnabled())
              updateMetrics.add(TabletServerUpdateMetrics.mutationArraySize, mutations.size());
           
            CommitSession commitSession = tablet.prepareMutationsForCommit(mutations);
            if (commitSession == null) {
              if (us.currentTablet == tablet) {
                us.currentTablet = null;
              }
              us.failures.put(tablet.getExtent(), us.successfulCommits.get(tablet));
            } else {
              sendables.put(commitSession, mutations);
              mutationCount += mutations.size();
            }
           
          } catch (TConstraintViolationException e) {
            us.violations.add(e.getViolations());
            if (updateMetrics.isEnabled())
              updateMetrics.add(TabletServerUpdateMetrics.constraintViolations, 0);
           
            if (e.getNonViolators().size() > 0) {
              // only log and commit mutations if there were some that did not
              // violate constraints... this is what prepareMutationsForCommit()
              // expects
              sendables.put(e.getCommitSession(), e.getNonViolators());
            }
           
            mutationCount += mutations.size();
           
          } catch (HoldTimeoutException t) {
            error = t;
            log.debug("Giving up on mutations due to a long memory hold time");
            break;
          } catch (Throwable t) {
            error = t;
            log.error("Unexpected error preparing for commit", error);
            break;
          }
        }
      }
      prep.stop();
     
      Span wal = Trace.start("wal");
      long pt2 = System.currentTimeMillis();
      long avgPrepareTime = (long) ((pt2 - pt1) / (double) us.queuedMutations.size());
      us.prepareTimes.addStat(pt2 - pt1);
      if (updateMetrics.isEnabled())
        updateMetrics.add(TabletServerUpdateMetrics.commitPrep, (avgPrepareTime));
     
      if (error != null) {
        for (Entry<CommitSession,List<Mutation>> e : sendables.entrySet()) {
          e.getKey().abortCommit(e.getValue());
        }
        throw new RuntimeException(error);
      }
      try {
        while (true) {
          try {
            long t1 = System.currentTimeMillis();
           
            logger.logManyTablets(sendables);
           
            long t2 = System.currentTimeMillis();
            us.walogTimes.addStat(t2 - t1);
            if (updateMetrics.isEnabled())
              updateMetrics.add(TabletServerUpdateMetrics.waLogWriteTime, (t2 - t1));
           
            break;
          } catch (IOException ex) {
            log.warn("logging mutations failed, retrying");
          } catch (Throwable t) {
            log.error("Unknown exception logging mutations, counts for mutations in flight not decremented!", t);
            throw new RuntimeException(t);
          }
        }
       
        wal.stop();
       
        Span commit = Trace.start("commit");
        long t1 = System.currentTimeMillis();
        for (Entry<CommitSession,? extends List<Mutation>> entry : sendables.entrySet()) {
          CommitSession commitSession = entry.getKey();
          List<Mutation> mutations = entry.getValue();
         
          commitSession.commit(mutations);
         
          Tablet tablet = commitSession.getTablet();
         
          if (tablet == us.currentTablet) {
            // because constraint violations may filter out some mutations, for proper
            // accounting with the client code, need to increment the count based
            // on the original number of mutations from the client NOT the filtered number
            us.successfulCommits.increment(tablet, us.queuedMutations.get(tablet).size());
          }
        }
        long t2 = System.currentTimeMillis();
       
        long avgCommitTime = (long) ((t2 - t1) / (double) sendables.size());
       
        us.flushTime += (t2 - pt1);
        us.commitTimes.addStat(t2 - t1);
       
        if (updateMetrics.isEnabled())
          updateMetrics.add(TabletServerUpdateMetrics.commitTime, avgCommitTime);
        commit.stop();
      } finally {
        us.queuedMutations.clear();
        if (us.currentTablet != null) {
          us.queuedMutations.put(us.currentTablet, new ArrayList<Mutation>());
        }
View Full Code Here


     
      try {
        Mutation mutation = new Mutation(tmutation);
        List<Mutation> mutations = Collections.singletonList(mutation);
       
        Span prep = Trace.start("prep");
        CommitSession cs = tablet.prepareMutationsForCommit(mutations);
        prep.stop();
        if (cs == null) {
          throw new NotServingTabletException(tkeyExtent);
        }
       
        while (true) {
          try {
            Span wal = Trace.start("wal");
            logger.log(cs, cs.getWALogSeq(), mutation);
            wal.stop();
            break;
          } catch (IOException ex) {
            log.warn(ex, ex);
          }
        }
       
        Span commit = Trace.start("commit");
        cs.commit(mutations);
        commit.stop();
      } catch (TConstraintViolationException e) {
        throw new ConstraintViolationException(Translator.translate(e.getViolations().asList(), Translator.CVST));
      } finally {
        writeTracker.finishWrite(opid);
      }
View Full Code Here

   
    while (true) {
      if (sampler.next())
        Trace.on("gc");
     
      Span gcSpan = Trace.start("loop");
      tStart = System.currentTimeMillis();
      try {
        // STEP 1: gather candidates
        System.gc(); // make room
        candidateMemExceeded = false;
        checkForBulkProcessingFiles = false;
       
        Span candidatesSpan = Trace.start("getCandidates");
        status.current.started = System.currentTimeMillis();
        SortedSet<String> candidates = getCandidates();
        status.current.candidates = candidates.size();
        candidatesSpan.stop();
       
        // STEP 2: confirm deletes
        // WARNING: This line is EXTREMELY IMPORTANT.
        // You MUST confirm candidates are okay to delete
        Span confirmDeletesSpan = Trace.start("confirmDeletes");
        confirmDeletes(candidates);
        status.current.inUse = status.current.candidates - candidates.size();
        confirmDeletesSpan.stop();
       
        // STEP 3: delete files
        if (safemode) {
          if (verbose)
            System.out.println("SAFEMODE: There are " + candidates.size() + " data file candidates marked for deletion.\n"
                + "          Examine the log files to identify them.\n" + "          They can be removed by executing: bin/accumulo gc --offline\n"
                + "WARNING:  Do not run the garbage collector in offline mode unless you are positive\n"
                + "          that the accumulo METADATA table is in a clean state, or that accumulo\n"
                + "          has not yet been run, in the case of an upgrade.");
          log.info("SAFEMODE: Listing all data file candidates for deletion");
          for (String s : candidates)
            log.info("SAFEMODE: " + s);
          log.info("SAFEMODE: End candidates for deletion");
        } else {
          Span deleteSpan = Trace.start("deleteFiles");
          deleteFiles(candidates);
          log.info("Number of data file candidates for deletion: " + status.current.candidates);
          log.info("Number of data file candidates still in use: " + status.current.inUse);
          log.info("Number of successfully deleted data files: " + status.current.deleted);
          log.info("Number of data files delete failures: " + status.current.errors);
          deleteSpan.stop();
         
          // check bulk dirs we just to deleted files from to see if empty
          deleteEmptyBulkDirs(candidates);
        }
       
        status.current.finished = System.currentTimeMillis();
        status.last = status.current;
        status.current = new GcCycleStats();
       
      } catch (Exception e) {
        log.error(e, e);
      }
      tStop = System.currentTimeMillis();
      log.info(String.format("Collect cycle took %.2f seconds", ((tStop - tStart) / 1000.0)));
     
      if (offline)
        break;
     
      if (candidateMemExceeded) {
        log.info("Gathering of candidates was interrupted due to memory shortage. Bypassing cycle delay to collect the remaining candidates.");
        continue;
      }
     
      // Clean up any unused write-ahead logs
      Span waLogs = Trace.start("walogs");
      try {
        log.info("Beginning garbage collection of write-ahead logs");
        GarbageCollectWriteAheadLogs.collect(fs, status);
      } catch (Exception e) {
        log.error(e, e);
      }
      waLogs.stop();
      gcSpan.stop();
     
      Trace.off();
      try {
        log.debug("Sleeping for " + gcDelay + " milliseconds");
View Full Code Here

    timer.incrementStatusMinor();
   
    long count = 0;
   
    try {
      Span span = Trace.start("write");
      count = memTable.getNumEntries();
      DataFileValue stats = memTable.minorCompact(conf, fs, tmpDatafile, extent);
      span.stop();
      span = Trace.start("bringOnline");
      datafileManager.bringMinorCompactionOnline(tmpDatafile, newDatafile, stats, commitSession);
      span.stop();
      return stats;
    } catch (RuntimeException E) {
      failed = true;
      throw E;
    } catch (Error E) {
View Full Code Here

 
  private void compactLocalityGroup(String lgName, Set<ByteSequence> columnFamilies, boolean inclusive, Configuration conf, FileSystem fs,
      Set<String> filesToCompact, boolean propogateDeletes, KeyExtent extent, String compactTmpName, FileSKVWriter mfw, MajorCompactionStats majCStats)
      throws IOException, MajorCompactionCanceledException {
    ArrayList<FileSKVIterator> readers = new ArrayList<FileSKVIterator>(filesToCompact.size());
    Span span = Trace.start("compact");
    try {
      long entriesCompacted = 0;
      List<SortedKeyValueIterator<Key,Value>> iters = openMapDataFiles(lgName, conf, fs, filesToCompact, extent, readers);
      CountingIterator citr = new CountingIterator(new MultiIterator(iters, extent.toDataRange()));
      DeletingIterator delIter = new DeletingIterator(citr, propogateDeletes);
     
      IteratorEnvironment iterEnv = new TabletIteratorEnvironment(IteratorScope.majc, !propogateDeletes, acuTableConf);
     
      SortedKeyValueIterator<Key,Value> itr = IteratorUtil.loadIterators(IteratorScope.majc, delIter, extent, acuTableConf, iterEnv);
     
      itr.seek(extent.toDataRange(), columnFamilies, inclusive);
     
      if (!inclusive) {
        mfw.startDefaultLocalityGroup();
      } else {
        mfw.startNewLocalityGroup(lgName, columnFamilies);
      }
     
      Span write = Trace.start("write");
      try {
        while (itr.hasTop() && isCompactionEnabled()) {
          mfw.append(itr.getTopKey(), itr.getTopValue());
          itr.next();
          entriesCompacted++;
        }
       
        if (itr.hasTop() && !isCompactionEnabled()) {
          // cancel major compaction operation
          try {
            try {
              mfw.close();
            } catch (IOException e) {
              log.error(e, e);
            }
            fs.delete(new Path(compactTmpName), true);
          } catch (Exception e) {
            log.warn("Failed to delete Canceled major compaction output file " + compactTmpName, e);
          }
          throw new MajorCompactionCanceledException();
        }
       
      } finally {
        MajorCompactionStats lgMajcStats = new MajorCompactionStats(citr.getCount(), entriesCompacted);
        majCStats.add(lgMajcStats);
        write.stop();
      }
     
    } finally {
      // close sequence files opened
      for (FileSKVIterator reader : readers) {
View Full Code Here

      Set<String> smallestFiles = removeSmallest(filesToCompact, numToCompact);
     
      String fileName = fileNames.remove(0);
      String compactTmpName = fileName + "_tmp";
     
      Span span = Trace.start("compactFiles");
      try {
        MajorCompactionStats mcs = compactFiles(conf, fs, smallestFiles, filesToCompact.size() == 0 ? propogateDeletes : true, // always propagate
                                                                                                                               // deletes,
                                                                                                                               // unless last batch
            extent, compactTmpName);
        span.data("files", "" + smallestFiles.size());
        span.data("read", "" + mcs.entriesRead);
        span.data("written", "" + mcs.entriesWritten);
        majCStats.add(mcs);
       
        long size = FileOperations.getInstance().getFileSize(compactTmpName, fs, conf,
            AccumuloConfiguration.getTableConfiguration(HdfsZooInstance.getInstance().getInstanceID(), extent.getTableId().toString()));
       
        datafileManager.bringMajorCompactionOnline(smallestFiles, compactTmpName, fileName, new DataFileValue(size, mcs.entriesWritten));
       
        // when major compaction produces a file w/ zero entries, it will be deleted... do not want
        // to add the deleted file
        if (filesToCompact.size() > 0 && mcs.entriesWritten > 0) {
          filesToCompact.put(fileName, size);
        }
      } finally {
        span.stop();
      }
     
    }
   
    return majCStats;
View Full Code Here

  private MajorCompactionStats majorCompact(boolean idleCompaction) {
   
    MajorCompactionStats majCStats = null;
   
    // Always trace majC
    Span span = Trace.on("majorCompaction");
    try {
      synchronized (this) {
        // check that compaction is still needed - defer to splitting
        majorCompactionQueued = false;
       
        if (closing || closed || !needsMajorCompaction(idleCompaction) || majorCompactionInProgress || needsSplit()) {
          return null;
        }
       
        majorCompactionInProgress = true;
      }
     
      majCStats = _majorCompact(idleCompaction);
    } catch (MajorCompactionCanceledException mcce) {
      log.debug("Major compaction canceled, extent = " + getExtent());
      throw new RuntimeException(mcce);
    } catch (Throwable t) {
      log.error("MajC Failed, extent = " + getExtent());
      log.error("MajC Failed, message = " + (t.getMessage() == null ? t.getClass().getName() : t.getMessage()), t);
      throw new RuntimeException(t);
    } finally {
      // ensure we always reset boolean, even
      // when an exception is thrown
      synchronized (this) {
        majorCompactionInProgress = false;
        this.notifyAll();
      }
      Span curr = Trace.currentTrace();
      curr.data("extent", "" + getExtent());
      curr.data("read", "" + majCStats.entriesRead);
      curr.data("written", "" + majCStats.entriesWritten);
      span.stop();
    }
   
    return majCStats;
  }
View Full Code Here

   
    TreeSet<String> waitForScansToFinish(Set<String> pathsToWaitFor, boolean blockNewScans, long maxWaitTime) {
      long startTime = System.currentTimeMillis();
      TreeSet<String> inUse = new TreeSet<String>();
     
      Span waitForScans = Trace.start("waitForScans");
      synchronized (Tablet.this) {
        if (blockNewScans) {
          if (reservationsBlocked)
            throw new IllegalStateException();
         
          reservationsBlocked = true;
        }
       
        for (String path : pathsToWaitFor) {
          while (fileScanReferenceCounts.get(path) > 0 && System.currentTimeMillis() - startTime < maxWaitTime) {
            try {
              Tablet.this.wait(100);
            } catch (InterruptedException e) {
              log.warn(e, e);
            }
          }
        }
       
        for (String path : pathsToWaitFor) {
          if (fileScanReferenceCounts.get(path) > 0)
            inUse.add(path);
        }
       
        if (blockNewScans) {
          reservationsBlocked = false;
          Tablet.this.notifyAll();
        }
       
      }
      waitForScans.stop();
      return inUse;
    }
View Full Code Here

    }
   
    public void run() {
      minorCompactionWaitingToStart = false;
      minorCompactionInProgress = true;
      Span minorCompaction = Trace.on("minorCompaction");
      try {
        Span span = Trace.start("waitForCommits");
        synchronized (Tablet.this) {
          commitSession.waitForCommitsToFinish();
        }
        span.stop();
        span = Trace.start("start");
        while (true) {
          try {
            tabletServer.minorCompactionStarted(commitSession, commitSession.getWALogSeq() + 1, newMapfileLocation);
            break;
          } catch (IOException e) {
            log.warn("Failed to write to write ahead log " + e.getMessage(), e);
          }
        }
        span.stop();
        span = Trace.start("compact");
        this.stats = minorCompact(conf, fs, tabletMemory.getMinCMemTable(), newMapfileLocation + "_tmp", newMapfileLocation, true, queued, commitSession);
        span.stop();
      } catch (Throwable t) {
        log.error("Unknown error during minor compaction for extent: " + getExtent(), t);
        throw new RuntimeException(t);
      } finally {
        minorCompactionInProgress = false;
View Full Code Here

    }
   
    public void run() {
      minorCompactionWaitingToStart = false;
      minorCompactionInProgress = true;
      Span minorCompaction = Trace.on("minorCompaction");
      try {
        Span span = Trace.start("waitForCommits");
        synchronized (Tablet.this) {
          commitSession.waitForCommitsToFinish();
        }
        span.stop();
        span = Trace.start("start");
        while (true) {
          try {
            tabletServer.minorCompactionStarted(commitSession, commitSession.getWALogSeq() + 1, newMapfileLocation);
            break;
          } catch (IOException e) {
            log.warn("Failed to write to write ahead log " + e.getMessage(), e);
          }
        }
        span.stop();
        span = Trace.start("compact");
        this.stats = minorCompact(conf, fs, tabletMemory.getMinCMemTable(), newMapfileLocation + "_tmp", newMapfileLocation, true, queued, commitSession);
        span.stop();
      } catch (Throwable t) {
        log.error("Unknown error during minor compaction for extent: " + getExtent(), t);
        throw new RuntimeException(t);
      } finally {
        minorCompactionInProgress = false;
View Full Code Here

TOP

Related Classes of cloudtrace.instrument.Span

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.