Ejemplo n.º 1
0
    @Override
    public Void call() throws IOException {
      IOException toThrow = null;
      StatisticsCollectionRunTracker collectionTracker =
          StatisticsCollectionRunTracker.getInstance(config);
      final HRegionInfo regionInfo = region.getRegionInfo();
      try {
        // update the statistics table
        // Just verify if this if fine
        ArrayList<Mutation> mutations = new ArrayList<Mutation>();

        if (LOG.isDebugEnabled()) {
          LOG.debug(
              "Deleting the stats for the region "
                  + regionInfo.getRegionNameAsString()
                  + " as part of major compaction");
        }
        stats.deleteStats(region, tracker, family, mutations);
        if (LOG.isDebugEnabled()) {
          LOG.debug(
              "Adding new stats for the region "
                  + regionInfo.getRegionNameAsString()
                  + " as part of major compaction");
        }
        stats.addStats(tracker, family, mutations);
        if (LOG.isDebugEnabled()) {
          LOG.debug(
              "Committing new stats for the region "
                  + regionInfo.getRegionNameAsString()
                  + " as part of major compaction");
        }
        stats.commitStats(mutations);
      } catch (IOException e) {
        LOG.error("Failed to update statistics table!", e);
        toThrow = e;
      } finally {
        try {
          collectionTracker.removeCompactingRegion(regionInfo);
          stats.close(); // close the writer
          tracker.close(); // close the tracker
        } catch (IOException e) {
          if (toThrow == null) toThrow = e;
          LOG.error("Error while closing the stats table", e);
        } finally {
          // close the delegate scanner
          try {
            delegate.close();
          } catch (IOException e) {
            if (toThrow == null) toThrow = e;
            LOG.error("Error while closing the scanner", e);
          } finally {
            if (toThrow != null) {
              throw toThrow;
            }
          }
        }
      }
      return null;
    }
Ejemplo n.º 2
0
 @Override
 public void close() throws IOException {
   boolean async = config.getBoolean(COMMIT_STATS_ASYNC, DEFAULT_COMMIT_STATS_ASYNC);
   StatisticsCollectionRunTracker collectionTracker =
       StatisticsCollectionRunTracker.getInstance(config);
   StatisticsScannerCallable callable = new StatisticsScannerCallable();
   if (!async) {
     callable.call();
   } else {
     collectionTracker.runTask(callable);
   }
 }
Ejemplo n.º 3
0
 public StatisticsScanner(
     StatisticsCollector tracker,
     StatisticsWriter stats,
     RegionCoprocessorEnvironment env,
     InternalScanner delegate,
     ImmutableBytesPtr family) {
   this.tracker = tracker;
   this.stats = stats;
   this.delegate = delegate;
   this.region = env.getRegion();
   this.family = family;
   this.config = env.getConfiguration();
   StatisticsCollectionRunTracker.getInstance(config).addCompactingRegion(region.getRegionInfo());
 }