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 java.io.Closeable;
021import org.apache.yetus.audience.InterfaceAudience;
022
023/**
024 * This interface will be implemented to allow region server to push table metrics into
025 * MetricsRegionAggregateSource that will in turn push data to the Hadoop metrics system.
026 */
027@InterfaceAudience.Private
028public interface MetricsTableSource extends Comparable<MetricsTableSource>, Closeable {
029
030  String TABLE_SIZE = "tableSize";
031  String TABLE_SIZE_DESC = "Total size of the table in the region server";
032
033  String getTableName();
034
035  /**
036   * Close the table's metrics as all the region are closing.
037   */
038  @Override
039  void close();
040
041  void registerMetrics();
042
043  /**
044   * Get the aggregate source to which this reports.
045   */
046  MetricsTableAggregateSource getAggregateSource();
047
048  /**
049   * Update the split transaction time histogram
050   * @param t time it took, in milliseconds
051   */
052  void updateSplitTime(long t);
053
054  /**
055   * Increment number of a requested splits
056   */
057  void incrSplitRequest();
058
059  /**
060   * Increment number of successful splits
061   */
062  void incrSplitSuccess();
063
064  /**
065   * Update the flush time histogram
066   * @param t time it took, in milliseconds
067   */
068  void updateFlushTime(long t);
069
070  /**
071   * Update the flush memstore size histogram
072   * @param bytes the number of bytes in the memstore
073   */
074  void updateFlushMemstoreSize(long bytes);
075
076  /**
077   * Update the flush output file size histogram
078   * @param bytes the number of bytes in the output file
079   */
080  void updateFlushOutputSize(long bytes);
081
082  /**
083   * Update the compaction time histogram, both major and minor
084   * @param isMajor whether compaction is a major compaction
085   * @param t       time it took, in milliseconds
086   */
087  void updateCompactionTime(boolean isMajor, long t);
088
089  /**
090   * Update the compaction input number of files histogram
091   * @param isMajor whether compaction is a major compaction
092   * @param c       number of files
093   */
094  void updateCompactionInputFileCount(boolean isMajor, long c);
095
096  /**
097   * Update the compaction total input file size histogram
098   * @param isMajor whether compaction is a major compaction
099   * @param bytes   the number of bytes of the compaction input file
100   */
101  void updateCompactionInputSize(boolean isMajor, long bytes);
102
103  /**
104   * Update the compaction output number of files histogram
105   * @param isMajor whether compaction is a major compaction
106   * @param c       number of files
107   */
108  void updateCompactionOutputFileCount(boolean isMajor, long c);
109
110  /**
111   * Update the compaction total output file size
112   * @param isMajor whether compaction is a major compaction
113   * @param bytes   the number of bytes of the compaction input file
114   */
115  void updateCompactionOutputSize(boolean isMajor, long bytes);
116
117}