2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to you under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 package org
.apache
.hadoop
.hbase
.regionserver
;
19 import org
.apache
.hadoop
.hbase
.CompatibilitySingletonFactory
;
20 import org
.apache
.hadoop
.hbase
.TableName
;
21 import org
.apache
.hadoop
.hbase
.metrics
.MetricRegistries
;
22 import org
.apache
.yetus
.audience
.InterfaceAudience
;
25 * Captures operation metrics by table. Separates metrics collection for table metrics away from
26 * {@link MetricsRegionServer} for encapsulation and ease of testing.
28 @InterfaceAudience.Private
29 public class RegionServerTableMetrics
{
31 private final MetricsTableLatencies latencies
;
32 private MetricsTableQueryMeter queryMeter
;
34 public RegionServerTableMetrics(boolean enableTableQueryMeter
) {
35 latencies
= CompatibilitySingletonFactory
.getInstance(MetricsTableLatencies
.class);
36 if (enableTableQueryMeter
) {
37 queryMeter
= new MetricsTableQueryMeterImpl(MetricRegistries
.global().
38 get(((MetricsTableLatenciesImpl
) latencies
).getMetricRegistryInfo()).get());
42 public void updatePut(TableName table
, long time
) {
43 latencies
.updatePut(table
.getNameAsString(), time
);
46 public void updatePutBatch(TableName table
, long time
) {
47 latencies
.updatePutBatch(table
.getNameAsString(), time
);
50 public void updateGet(TableName table
, long time
) {
51 latencies
.updateGet(table
.getNameAsString(), time
);
54 public void updateIncrement(TableName table
, long time
) {
55 latencies
.updateIncrement(table
.getNameAsString(), time
);
58 public void updateAppend(TableName table
, long time
) {
59 latencies
.updateAppend(table
.getNameAsString(), time
);
62 public void updateDelete(TableName table
, long time
) {
63 latencies
.updateDelete(table
.getNameAsString(), time
);
66 public void updateDeleteBatch(TableName table
, long time
) {
67 latencies
.updateDeleteBatch(table
.getNameAsString(), time
);
70 public void updateCheckAndDelete(TableName table
, long time
) {
71 latencies
.updateCheckAndDelete(table
.getNameAsString(), time
);
74 public void updateCheckAndPut(TableName table
, long time
) {
75 latencies
.updateCheckAndPut(table
.getNameAsString(), time
);
78 public void updateCheckAndMutate(TableName table
, long time
) {
79 latencies
.updateCheckAndMutate(table
.getNameAsString(), time
);
82 public void updateScanTime(TableName table
, long time
) {
83 latencies
.updateScanTime(table
.getNameAsString(), time
);
86 public void updateScanSize(TableName table
, long size
) {
87 latencies
.updateScanSize(table
.getNameAsString(), size
);
90 public void updateTableReadQueryMeter(TableName table
, long count
) {
91 if (queryMeter
!= null) {
92 queryMeter
.updateTableReadQueryMeter(table
, count
);
96 public void updateTableWriteQueryMeter(TableName table
, long count
) {
97 if (queryMeter
!= null) {
98 queryMeter
.updateTableWriteQueryMeter(table
, count
);
102 public void updateTableWriteQueryMeter(TableName table
) {
103 if (queryMeter
!= null) {
104 queryMeter
.updateTableWriteQueryMeter(table
);