View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  package org.apache.hadoop.hbase.regionserver;
20  
21  import org.apache.hadoop.conf.Configuration;
22  import org.apache.hadoop.hbase.classification.InterfaceAudience;
23  
24  @InterfaceAudience.Private
25  public class MetricsUserAggregateFactory {
26    private MetricsUserAggregateFactory() {
27  
28    }
29    public static final String METRIC_USER_ENABLED_CONF = "hbase.regionserver.user.metrics.enabled";
30    public static final boolean DEFAULT_METRIC_USER_ENABLED_CONF = true;
31  
32    public static MetricsUserAggregate getMetricsUserAggregate(Configuration conf) {
33      if (conf.getBoolean(METRIC_USER_ENABLED_CONF, DEFAULT_METRIC_USER_ENABLED_CONF)) {
34        return new MetricsUserAggregateImpl(conf);
35      } else {
36        //NoOpMetricUserAggregate
37        return new MetricsUserAggregate() {
38          @Override public void updatePut(long t) {
39  
40          }
41  
42          @Override public void updateDelete(long t) {
43  
44          }
45  
46          @Override public void updateGet(long t) {
47  
48          }
49  
50          @Override public void updateIncrement(long t) {
51  
52          }
53  
54          @Override public void updateAppend(long t) {
55  
56          }
57  
58          @Override public void updateReplay(long t) {
59  
60          }
61  
62          @Override public void updateScanTime(long t) {
63  
64          }
65        };
66      }
67    }
68  
69  }