001/* 002 * Copyright The Apache Software Foundation 003 * 004 * Licensed to the Apache Software Foundation (ASF) under one or more 005 * contributor license agreements. See the NOTICE file distributed with this 006 * work for additional information regarding copyright ownership. The ASF 007 * licenses this file to you under the Apache License, Version 2.0 (the 008 * "License"); you may not use this file except in compliance with the License. 009 * You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 015 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 016 * License for the specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.apache.hadoop.hbase.regionserver; 020 021import org.apache.hadoop.conf.Configuration; 022import org.apache.yetus.audience.InterfaceAudience; 023import org.apache.hadoop.hbase.CompatibilitySingletonFactory; 024 025 026/** 027 * This is the glue between the HRegion and whatever hadoop shim layer 028 * is loaded (hbase-hadoop1-compat or hbase-hadoop2-compat). 029 */ 030@InterfaceAudience.Private 031public class MetricsRegion { 032 private final MetricsRegionSource source; 033 private final MetricsUserAggregate userAggregate; 034 private MetricsRegionWrapper regionWrapper; 035 036 public MetricsRegion(final MetricsRegionWrapper wrapper, Configuration conf) { 037 source = CompatibilitySingletonFactory.getInstance(MetricsRegionServerSourceFactory.class) 038 .createRegion(wrapper); 039 this.regionWrapper = wrapper; 040 userAggregate = MetricsUserAggregateFactory.getMetricsUserAggregate(conf); 041 } 042 043 public void close() { 044 source.close(); 045 } 046 047 public void updatePut() { 048 source.updatePut(); 049 } 050 051 public void updateDelete() { 052 source.updateDelete(); 053 } 054 055 public void updateGet(final long t) { 056 source.updateGet(t); 057 } 058 059 public void updateScanTime(final long t) { 060 source.updateScanTime(t); 061 } 062 063 public void updateFilteredRecords(){ 064 userAggregate.updateFilteredReadRequests(); 065 } 066 public void updateAppend() { 067 source.updateAppend(); 068 } 069 070 public void updateIncrement() { 071 source.updateIncrement(); 072 } 073 074 MetricsRegionSource getSource() { 075 return source; 076 } 077 078 public MetricsRegionWrapper getRegionWrapper() { 079 return regionWrapper; 080 } 081 082 public void updateReadRequestCount() { 083 userAggregate.updateReadRequestCount(); 084 } 085}