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 org.apache.hadoop.conf.Configuration;
021import org.apache.yetus.audience.InterfaceAudience;
022
023@InterfaceAudience.Private
024public class MetricsUserAggregateFactory {
025  private MetricsUserAggregateFactory() {
026
027  }
028
029  public static final String METRIC_USER_ENABLED_CONF = "hbase.regionserver.user.metrics.enabled";
030  public static final boolean DEFAULT_METRIC_USER_ENABLED_CONF = false;
031
032  public static MetricsUserAggregate getMetricsUserAggregate(Configuration conf) {
033    if (conf.getBoolean(METRIC_USER_ENABLED_CONF, DEFAULT_METRIC_USER_ENABLED_CONF)) {
034      return new MetricsUserAggregateImpl(conf);
035    } else {
036      // NoOpMetricUserAggregate
037      return new MetricsUserAggregate() {
038        @Override
039        public MetricsUserAggregateSource getSource() {
040          return null;
041        }
042
043        @Override
044        public void updatePut(long t) {
045
046        }
047
048        @Override
049        public void updateDelete(long t) {
050
051        }
052
053        @Override
054        public void updateGet(long t) {
055
056        }
057
058        @Override
059        public void updateIncrement(long t) {
060
061        }
062
063        @Override
064        public void updateAppend(long t) {
065
066        }
067
068        @Override
069        public void updateReplay(long t) {
070
071        }
072
073        @Override
074        public void updateScanTime(long t) {
075
076        }
077
078        @Override
079        public void updateFilteredReadRequests() {
080
081        }
082
083        @Override
084        public void updateReadRequestCount() {
085
086        }
087      };
088    }
089  }
090
091}