001/**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.regionserver;
019
020import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.COMPACTED_INPUT_BYTES;
021import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.COMPACTED_INPUT_BYTES_DESC;
022import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.COMPACTED_OUTPUT_BYTES;
023import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.COMPACTED_OUTPUT_BYTES_DESC;
024import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.COMPACTION_INPUT_FILE_COUNT;
025import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.COMPACTION_INPUT_FILE_COUNT_DESC;
026import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.COMPACTION_INPUT_SIZE;
027import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.COMPACTION_INPUT_SIZE_DESC;
028import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.COMPACTION_OUTPUT_FILE_COUNT;
029import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.COMPACTION_OUTPUT_FILE_COUNT_DESC;
030import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.COMPACTION_OUTPUT_SIZE;
031import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.COMPACTION_OUTPUT_SIZE_DESC;
032import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.COMPACTION_TIME;
033import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.COMPACTION_TIME_DESC;
034import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.FLUSHED_MEMSTORE_BYTES;
035import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.FLUSHED_MEMSTORE_BYTES_DESC;
036import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.FLUSHED_OUTPUT_BYTES;
037import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.FLUSHED_OUTPUT_BYTES_DESC;
038import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.FLUSH_MEMSTORE_SIZE;
039import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.FLUSH_MEMSTORE_SIZE_DESC;
040import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.FLUSH_OUTPUT_SIZE;
041import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.FLUSH_OUTPUT_SIZE_DESC;
042import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.FLUSH_TIME;
043import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.FLUSH_TIME_DESC;
044import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.MAJOR_COMPACTED_INPUT_BYTES;
045import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.MAJOR_COMPACTED_INPUT_BYTES_DESC;
046import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.MAJOR_COMPACTED_OUTPUT_BYTES;
047import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.MAJOR_COMPACTED_OUTPUT_BYTES_DESC;
048import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.MAJOR_COMPACTION_INPUT_FILE_COUNT;
049import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.MAJOR_COMPACTION_INPUT_FILE_COUNT_DESC;
050import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.MAJOR_COMPACTION_INPUT_SIZE;
051import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.MAJOR_COMPACTION_INPUT_SIZE_DESC;
052import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.MAJOR_COMPACTION_OUTPUT_FILE_COUNT;
053import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.MAJOR_COMPACTION_OUTPUT_FILE_COUNT_DESC;
054import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.MAJOR_COMPACTION_OUTPUT_SIZE;
055import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.MAJOR_COMPACTION_OUTPUT_SIZE_DESC;
056import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.MAJOR_COMPACTION_TIME;
057import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.MAJOR_COMPACTION_TIME_DESC;
058import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.SPLIT_KEY;
059import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.SPLIT_REQUEST_DESC;
060import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.SPLIT_REQUEST_KEY;
061import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.SPLIT_SUCCESS_DESC;
062import static org.apache.hadoop.hbase.regionserver.MetricsRegionServerSource.SPLIT_SUCCESS_KEY;
063
064import java.util.Map;
065import java.util.Map.Entry;
066import java.util.concurrent.atomic.AtomicBoolean;
067
068import org.apache.hadoop.hbase.TableName;
069import org.apache.hadoop.hbase.metrics.Interns;
070import org.apache.hadoop.metrics2.MetricHistogram;
071import org.apache.hadoop.metrics2.MetricsRecordBuilder;
072import org.apache.hadoop.metrics2.lib.DynamicMetricsRegistry;
073import org.apache.hadoop.metrics2.lib.MutableFastCounter;
074import org.apache.yetus.audience.InterfaceAudience;
075import org.slf4j.Logger;
076import org.slf4j.LoggerFactory;
077
078@InterfaceAudience.Private
079public class MetricsTableSourceImpl implements MetricsTableSource {
080
081  private static final String _COLUMNFAMILY = "_columnfamily_";
082
083  private static final Logger LOG = LoggerFactory.getLogger(MetricsTableSourceImpl.class);
084
085  private AtomicBoolean closed = new AtomicBoolean(false);
086
087  // Non-final so that we can null out the wrapper
088  // This is just paranoia. We really really don't want to
089  // leak a whole table by way of keeping the
090  // tableWrapper around too long.
091  private MetricsTableWrapperAggregate tableWrapperAgg;
092  private final MetricsTableAggregateSourceImpl agg;
093  private final DynamicMetricsRegistry registry;
094  private final String tableNamePrefix;
095  private final String tableNamePrefixPart1;
096  private final String tableNamePrefixPart2;
097  private final TableName tableName;
098  private final int hashCode;
099
100  // split related metrics
101  private MutableFastCounter splitRequest;
102  private MutableFastCounter splitSuccess;
103  private MetricHistogram splitTimeHisto;
104
105  // flush related metrics
106  private MetricHistogram flushTimeHisto;
107  private MetricHistogram flushMemstoreSizeHisto;
108  private MetricHistogram flushOutputSizeHisto;
109  private MutableFastCounter flushedMemstoreBytes;
110  private MutableFastCounter flushedOutputBytes;
111
112  // compaction related metrics
113  private MetricHistogram compactionTimeHisto;
114  private MetricHistogram compactionInputFileCountHisto;
115  private MetricHistogram compactionInputSizeHisto;
116  private MetricHistogram compactionOutputFileCountHisto;
117  private MetricHistogram compactionOutputSizeHisto;
118  private MutableFastCounter compactedInputBytes;
119  private MutableFastCounter compactedOutputBytes;
120
121  private MetricHistogram majorCompactionTimeHisto;
122  private MetricHistogram majorCompactionInputFileCountHisto;
123  private MetricHistogram majorCompactionInputSizeHisto;
124  private MetricHistogram majorCompactionOutputFileCountHisto;
125  private MetricHistogram majorCompactionOutputSizeHisto;
126  private MutableFastCounter majorCompactedInputBytes;
127  private MutableFastCounter majorCompactedOutputBytes;
128
129  public MetricsTableSourceImpl(String tblName,
130      MetricsTableAggregateSourceImpl aggregate, MetricsTableWrapperAggregate tblWrapperAgg) {
131    LOG.debug("Creating new MetricsTableSourceImpl for table '{}'", tblName);
132    this.tableName = TableName.valueOf(tblName);
133    this.agg = aggregate;
134
135    this.tableWrapperAgg = tblWrapperAgg;
136    this.registry = agg.getMetricsRegistry();
137    this.tableNamePrefixPart1 = "Namespace_" + this.tableName.getNamespaceAsString() +
138            "_table_" + this.tableName.getQualifierAsString();
139    this.tableNamePrefixPart2 = "_metric_";
140    this.tableNamePrefix = tableNamePrefixPart1 +
141        tableNamePrefixPart2;
142    this.hashCode = this.tableName.hashCode();
143  }
144
145  @Override
146  public synchronized void registerMetrics() {
147    flushTimeHisto = registry.newTimeHistogram(tableNamePrefix + FLUSH_TIME, FLUSH_TIME_DESC);
148    flushMemstoreSizeHisto =
149        registry.newSizeHistogram(tableNamePrefix + FLUSH_MEMSTORE_SIZE, FLUSH_MEMSTORE_SIZE_DESC);
150    flushOutputSizeHisto =
151        registry.newSizeHistogram(tableNamePrefix + FLUSH_OUTPUT_SIZE, FLUSH_OUTPUT_SIZE_DESC);
152    flushedOutputBytes =
153        registry.newCounter(tableNamePrefix + FLUSHED_OUTPUT_BYTES, FLUSHED_OUTPUT_BYTES_DESC, 0L);
154    flushedMemstoreBytes = registry.newCounter(tableNamePrefix + FLUSHED_MEMSTORE_BYTES,
155      FLUSHED_MEMSTORE_BYTES_DESC, 0L);
156
157    compactionTimeHisto =
158        registry.newTimeHistogram(tableNamePrefix + COMPACTION_TIME, COMPACTION_TIME_DESC);
159    compactionInputFileCountHisto = registry.newHistogram(
160      tableNamePrefix + COMPACTION_INPUT_FILE_COUNT, COMPACTION_INPUT_FILE_COUNT_DESC);
161    compactionInputSizeHisto = registry.newSizeHistogram(tableNamePrefix + COMPACTION_INPUT_SIZE,
162      COMPACTION_INPUT_SIZE_DESC);
163    compactionOutputFileCountHisto = registry.newHistogram(
164      tableNamePrefix + COMPACTION_OUTPUT_FILE_COUNT, COMPACTION_OUTPUT_FILE_COUNT_DESC);
165    compactionOutputSizeHisto = registry.newSizeHistogram(tableNamePrefix + COMPACTION_OUTPUT_SIZE,
166      COMPACTION_OUTPUT_SIZE_DESC);
167    compactedInputBytes = registry.newCounter(tableNamePrefix + COMPACTED_INPUT_BYTES,
168      COMPACTED_INPUT_BYTES_DESC, 0L);
169    compactedOutputBytes = registry.newCounter(tableNamePrefix + COMPACTED_OUTPUT_BYTES,
170      COMPACTED_OUTPUT_BYTES_DESC, 0L);
171
172    majorCompactionTimeHisto = registry.newTimeHistogram(tableNamePrefix + MAJOR_COMPACTION_TIME,
173      MAJOR_COMPACTION_TIME_DESC);
174    majorCompactionInputFileCountHisto = registry.newHistogram(
175      tableNamePrefix + MAJOR_COMPACTION_INPUT_FILE_COUNT, MAJOR_COMPACTION_INPUT_FILE_COUNT_DESC);
176    majorCompactionInputSizeHisto = registry.newSizeHistogram(
177      tableNamePrefix + MAJOR_COMPACTION_INPUT_SIZE, MAJOR_COMPACTION_INPUT_SIZE_DESC);
178    majorCompactionOutputFileCountHisto =
179        registry.newHistogram(tableNamePrefix + MAJOR_COMPACTION_OUTPUT_FILE_COUNT,
180          MAJOR_COMPACTION_OUTPUT_FILE_COUNT_DESC);
181    majorCompactionOutputSizeHisto = registry.newSizeHistogram(
182      tableNamePrefix + MAJOR_COMPACTION_OUTPUT_SIZE, MAJOR_COMPACTION_OUTPUT_SIZE_DESC);
183    majorCompactedInputBytes = registry.newCounter(tableNamePrefix + MAJOR_COMPACTED_INPUT_BYTES,
184      MAJOR_COMPACTED_INPUT_BYTES_DESC, 0L);
185    majorCompactedOutputBytes = registry.newCounter(tableNamePrefix + MAJOR_COMPACTED_OUTPUT_BYTES,
186      MAJOR_COMPACTED_OUTPUT_BYTES_DESC, 0L);
187
188    splitTimeHisto = registry.newTimeHistogram(tableNamePrefix + SPLIT_KEY);
189    splitRequest = registry.newCounter(tableNamePrefix + SPLIT_REQUEST_KEY, SPLIT_REQUEST_DESC, 0L);
190    splitSuccess = registry.newCounter(tableNamePrefix + SPLIT_SUCCESS_KEY, SPLIT_SUCCESS_DESC, 0L);
191  }
192
193  private void deregisterMetrics() {
194    registry.removeHistogramMetrics(tableNamePrefix + FLUSH_TIME);
195    registry.removeHistogramMetrics(tableNamePrefix + FLUSH_MEMSTORE_SIZE);
196    registry.removeHistogramMetrics(tableNamePrefix + FLUSH_OUTPUT_SIZE);
197    registry.removeMetric(tableNamePrefix + FLUSHED_OUTPUT_BYTES);
198    registry.removeMetric(tableNamePrefix + FLUSHED_MEMSTORE_BYTES);
199    registry.removeHistogramMetrics(tableNamePrefix + COMPACTION_TIME);
200    registry.removeHistogramMetrics(tableNamePrefix + COMPACTION_INPUT_FILE_COUNT);
201    registry.removeHistogramMetrics(tableNamePrefix + COMPACTION_INPUT_SIZE);
202    registry.removeHistogramMetrics(tableNamePrefix + COMPACTION_OUTPUT_FILE_COUNT);
203    registry.removeHistogramMetrics(tableNamePrefix + COMPACTION_OUTPUT_SIZE);
204    registry.removeMetric(tableNamePrefix + COMPACTED_INPUT_BYTES);
205    registry.removeMetric(tableNamePrefix + COMPACTED_OUTPUT_BYTES);
206    registry.removeHistogramMetrics(tableNamePrefix + MAJOR_COMPACTION_TIME);
207    registry.removeHistogramMetrics(tableNamePrefix + MAJOR_COMPACTION_INPUT_FILE_COUNT);
208    registry.removeHistogramMetrics(tableNamePrefix + MAJOR_COMPACTION_INPUT_SIZE);
209    registry.removeHistogramMetrics(tableNamePrefix + MAJOR_COMPACTION_OUTPUT_FILE_COUNT);
210    registry.removeHistogramMetrics(tableNamePrefix + MAJOR_COMPACTION_OUTPUT_SIZE);
211    registry.removeMetric(tableNamePrefix + MAJOR_COMPACTED_INPUT_BYTES);
212    registry.removeMetric(tableNamePrefix + MAJOR_COMPACTED_OUTPUT_BYTES);
213    registry.removeHistogramMetrics(tableNamePrefix + SPLIT_KEY);
214    registry.removeMetric(tableNamePrefix + SPLIT_REQUEST_KEY);
215    registry.removeMetric(tableNamePrefix + SPLIT_SUCCESS_KEY);
216  }
217
218  @Override
219  public void close() {
220    boolean wasClosed = closed.getAndSet(true);
221
222    // Has someone else already closed this for us?
223    if (wasClosed) {
224      return;
225    }
226
227    // Before removing the metrics remove this table from the aggregate table bean.
228    // This should mean that it's unlikely that snapshot and close happen at the same time.
229    agg.deleteTableSource(tableName.getNameAsString());
230
231    // While it's un-likely that snapshot and close happen at the same time it's still possible.
232    // So grab the lock to ensure that all calls to snapshot are done before we remove the metrics
233    synchronized (this) {
234      if (LOG.isTraceEnabled()) {
235        LOG.trace("Removing table Metrics for table ");
236      }
237      deregisterMetrics();
238      tableWrapperAgg = null;
239    }
240  }
241  @Override
242  public MetricsTableAggregateSource getAggregateSource() {
243    return agg;
244  }
245
246  @Override
247  public int compareTo(MetricsTableSource source) {
248    if (!(source instanceof MetricsTableSourceImpl)) {
249      return -1;
250    }
251    MetricsTableSourceImpl impl = (MetricsTableSourceImpl) source;
252    return Long.compare(hashCode, impl.hashCode);
253  }
254
255  void snapshot(MetricsRecordBuilder mrb, boolean ignored) {
256    // If there is a close that started be double extra sure
257    // that we're not getting any locks and not putting data
258    // into the metrics that should be removed. So early out
259    // before even getting the lock.
260    if (closed.get()) {
261      return;
262    }
263
264    // Grab the read
265    // This ensures that removes of the metrics
266    // can't happen while we are putting them back in.
267    synchronized (this) {
268      // It's possible that a close happened between checking
269      // the closed variable and getting the lock.
270      if (closed.get()) {
271        return;
272      }
273
274      if (this.tableWrapperAgg != null) {
275        mrb.addCounter(Interns.info(tableNamePrefix + MetricsRegionServerSource.READ_REQUEST_COUNT,
276            MetricsRegionServerSource.READ_REQUEST_COUNT_DESC),
277            tableWrapperAgg.getReadRequestCount(tableName.getNameAsString()));
278        mrb.addCounter(
279            Interns.info(tableNamePrefix + MetricsRegionServerSource.FILTERED_READ_REQUEST_COUNT,
280                MetricsRegionServerSource.FILTERED_READ_REQUEST_COUNT_DESC),
281            tableWrapperAgg.getFilteredReadRequestCount(tableName.getNameAsString()));
282        mrb.addCounter(Interns.info(tableNamePrefix + MetricsRegionServerSource.WRITE_REQUEST_COUNT,
283            MetricsRegionServerSource.WRITE_REQUEST_COUNT_DESC),
284            tableWrapperAgg.getWriteRequestCount(tableName.getNameAsString()));
285        mrb.addCounter(Interns.info(tableNamePrefix + MetricsRegionServerSource.TOTAL_REQUEST_COUNT,
286            MetricsRegionServerSource.TOTAL_REQUEST_COUNT_DESC),
287            tableWrapperAgg.getTotalRequestsCount(tableName.getNameAsString()));
288        mrb.addGauge(Interns.info(tableNamePrefix + MetricsRegionServerSource.MEMSTORE_SIZE,
289            MetricsRegionServerSource.MEMSTORE_SIZE_DESC),
290            tableWrapperAgg.getMemStoreSize(tableName.getNameAsString()));
291        mrb.addGauge(Interns.info(tableNamePrefix + MetricsRegionServerSource.STOREFILE_COUNT,
292            MetricsRegionServerSource.STOREFILE_COUNT_DESC),
293            tableWrapperAgg.getNumStoreFiles(tableName.getNameAsString()));
294        mrb.addGauge(Interns.info(tableNamePrefix + MetricsRegionServerSource.STOREFILE_SIZE,
295            MetricsRegionServerSource.STOREFILE_SIZE_DESC),
296            tableWrapperAgg.getStoreFileSize(tableName.getNameAsString()));
297        mrb.addGauge(Interns.info(tableNamePrefix + MetricsTableSource.TABLE_SIZE,
298          MetricsTableSource.TABLE_SIZE_DESC),
299          tableWrapperAgg.getTableSize(tableName.getNameAsString()));
300        mrb.addGauge(Interns.info(tableNamePrefix + MetricsRegionServerSource.AVERAGE_REGION_SIZE,
301            MetricsRegionServerSource.AVERAGE_REGION_SIZE_DESC),
302            tableWrapperAgg.getAvgRegionSize(tableName.getNameAsString()));
303        mrb.addGauge(Interns.info(tableNamePrefix + MetricsRegionServerSource.REGION_COUNT,
304            MetricsRegionServerSource.REGION_COUNT_DESC),
305            tableWrapperAgg.getNumRegions(tableName.getNameAsString()));
306        mrb.addGauge(Interns.info(tableNamePrefix + MetricsRegionServerSource.STORE_COUNT,
307            MetricsRegionServerSource.STORE_COUNT_DESC),
308            tableWrapperAgg.getNumStores(tableName.getNameAsString()));
309        mrb.addGauge(Interns.info(tableNamePrefix + MetricsRegionServerSource.MAX_STORE_FILE_AGE,
310            MetricsRegionServerSource.MAX_STORE_FILE_AGE_DESC),
311            tableWrapperAgg.getMaxStoreFileAge(tableName.getNameAsString()));
312        mrb.addGauge(Interns.info(tableNamePrefix + MetricsRegionServerSource.MIN_STORE_FILE_AGE,
313            MetricsRegionServerSource.MIN_STORE_FILE_AGE_DESC),
314            tableWrapperAgg.getMinStoreFileAge(tableName.getNameAsString()));
315        mrb.addGauge(Interns.info(tableNamePrefix + MetricsRegionServerSource.AVG_STORE_FILE_AGE,
316            MetricsRegionServerSource.AVG_STORE_FILE_AGE_DESC),
317            tableWrapperAgg.getAvgStoreFileAge(tableName.getNameAsString()));
318        mrb.addGauge(Interns.info(tableNamePrefix + MetricsRegionServerSource.NUM_REFERENCE_FILES,
319            MetricsRegionServerSource.NUM_REFERENCE_FILES_DESC),
320            tableWrapperAgg.getNumReferenceFiles(tableName.getNameAsString()));
321        addGauge(mrb, tableWrapperAgg.getMemstoreOnlyRowReadsCount(tableName.getNameAsString()),
322          MetricsRegionSource.ROW_READS_ONLY_ON_MEMSTORE,
323          MetricsRegionSource.ROW_READS_ONLY_ON_MEMSTORE_DESC);
324        addGauge(mrb, tableWrapperAgg.getMixedRowReadsCount(tableName.getNameAsString()),
325          MetricsRegionSource.MIXED_ROW_READS,
326          MetricsRegionSource.MIXED_ROW_READS_ON_STORE_DESC);
327      }
328    }
329  }
330
331  private void addGauge(MetricsRecordBuilder mrb, Map<String, Long> metricMap, String metricName,
332      String metricDesc) {
333    if (metricMap != null) {
334      for (Entry<String, Long> entry : metricMap.entrySet()) {
335        // append 'store' and its name to the metric
336        mrb.addGauge(Interns.info(this.tableNamePrefixPart1 + _COLUMNFAMILY
337            + entry.getKey().split(MetricsTableWrapperAggregate.HASH)[1]
338            + this.tableNamePrefixPart2 + metricName,
339          metricDesc), entry.getValue());
340      }
341    }
342  }
343
344  @Override
345  public String getTableName() {
346    return tableName.getNameAsString();
347  }
348
349  @Override
350  public int hashCode() {
351    return hashCode;
352  }
353
354  @Override
355  public boolean equals(Object o) {
356    if (this == o) {
357      return true;
358    }
359
360    if (o == null || getClass() != o.getClass()) {
361      return false;
362    }
363
364    return (compareTo((MetricsTableSourceImpl) o) == 0);
365  }
366
367  public MetricsTableWrapperAggregate getTableWrapper() {
368    return tableWrapperAgg;
369  }
370
371  public String getTableNamePrefix() {
372    return tableNamePrefix;
373  }
374
375  @Override
376  public void incrSplitRequest() {
377    splitRequest.incr();
378  }
379
380  @Override
381  public void incrSplitSuccess() {
382    splitSuccess.incr();
383  }
384
385  @Override
386  public void updateSplitTime(long t) {
387    splitTimeHisto.add(t);
388  }
389
390  @Override
391  public void updateFlushTime(long t) {
392    flushTimeHisto.add(t);
393  }
394
395  @Override
396  public synchronized void updateFlushMemstoreSize(long bytes) {
397    flushMemstoreSizeHisto.add(bytes);
398    flushedMemstoreBytes.incr(bytes);
399  }
400
401  @Override
402  public synchronized void updateFlushOutputSize(long bytes) {
403    flushOutputSizeHisto.add(bytes);
404    flushedOutputBytes.incr(bytes);
405  }
406
407  @Override
408  public synchronized void updateCompactionTime(boolean isMajor, long t) {
409    compactionTimeHisto.add(t);
410    if (isMajor) {
411      majorCompactionTimeHisto.add(t);
412    }
413  }
414
415  @Override
416  public synchronized void updateCompactionInputFileCount(boolean isMajor, long c) {
417    compactionInputFileCountHisto.add(c);
418    if (isMajor) {
419      majorCompactionInputFileCountHisto.add(c);
420    }
421  }
422
423  @Override
424  public synchronized void updateCompactionInputSize(boolean isMajor, long bytes) {
425    compactionInputSizeHisto.add(bytes);
426    compactedInputBytes.incr(bytes);
427    if (isMajor) {
428      majorCompactionInputSizeHisto.add(bytes);
429      majorCompactedInputBytes.incr(bytes);
430    }
431  }
432
433  @Override
434  public synchronized void updateCompactionOutputFileCount(boolean isMajor, long c) {
435    compactionOutputFileCountHisto.add(c);
436    if (isMajor) {
437      majorCompactionOutputFileCountHisto.add(c);
438    }
439  }
440
441  @Override
442  public synchronized void updateCompactionOutputSize(boolean isMajor, long bytes) {
443    compactionOutputSizeHisto.add(bytes);
444    compactedOutputBytes.incr(bytes);
445    if (isMajor) {
446      majorCompactionOutputSizeHisto.add(bytes);
447      majorCompactedOutputBytes.incr(bytes);
448    }
449  }
450}