001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to you under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.hadoop.hbase.regionserver;
018
019import org.apache.hadoop.hbase.CompatibilitySingletonFactory;
020import org.apache.hadoop.hbase.TableName;
021import org.apache.hadoop.hbase.metrics.MetricRegistries;
022import org.apache.yetus.audience.InterfaceAudience;
023
024/**
025 * Captures operation metrics by table. Separates metrics collection for table metrics away from
026 * {@link MetricsRegionServer} for encapsulation and ease of testing.
027 */
028@InterfaceAudience.Private
029public class RegionServerTableMetrics {
030
031  private final MetricsTableLatencies latencies;
032  private final MetricsTableQueryMeter queryMeter;
033
034  public RegionServerTableMetrics() {
035    latencies = CompatibilitySingletonFactory.getInstance(MetricsTableLatencies.class);
036    queryMeter = new MetricsTableQueryMeterImpl(MetricRegistries.global().
037      get(((MetricsTableLatenciesImpl) latencies).getMetricRegistryInfo()).get());
038  }
039
040  public void updatePut(TableName table, long time) {
041    latencies.updatePut(table.getNameAsString(), time);
042  }
043
044  public void updatePutBatch(TableName table, long time) {
045    latencies.updatePutBatch(table.getNameAsString(), time);
046  }
047
048  public void updateGet(TableName table, long time) {
049    latencies.updateGet(table.getNameAsString(), time);
050  }
051
052  public void updateIncrement(TableName table, long time) {
053    latencies.updateIncrement(table.getNameAsString(), time);
054  }
055
056  public void updateAppend(TableName table, long time) {
057    latencies.updateAppend(table.getNameAsString(), time);
058  }
059
060  public void updateDelete(TableName table, long time) {
061    latencies.updateDelete(table.getNameAsString(), time);
062  }
063
064  public void updateDeleteBatch(TableName table, long time) {
065    latencies.updateDeleteBatch(table.getNameAsString(), time);
066  }
067
068  public void updateScanTime(TableName table, long time) {
069    latencies.updateScanTime(table.getNameAsString(), time);
070  }
071
072  public void updateScanSize(TableName table, long size) {
073    latencies.updateScanSize(table.getNameAsString(), size);
074  }
075
076  public void updateTableReadQueryMeter(TableName table, long count) {
077    queryMeter.updateTableReadQueryMeter(table, count);
078  }
079
080  public void updateTableReadQueryMeter(TableName table) {
081    queryMeter.updateTableReadQueryMeter(table);
082  }
083
084  public void updateTableWriteQueryMeter(TableName table, long count) {
085    queryMeter.updateTableWriteQueryMeter(table, count);
086  }
087
088  public void updateTableWriteQueryMeter(TableName table) {
089    queryMeter.updateTableWriteQueryMeter(table);
090  }
091}