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 java.util.concurrent.TimeUnit; 020 021import org.apache.hadoop.hbase.metrics.BaseSourceImpl; 022import org.apache.hadoop.hbase.metrics.Counter; 023import org.apache.hadoop.hbase.metrics.Meter; 024import org.apache.hadoop.hbase.metrics.Timer; 025import org.apache.yetus.audience.InterfaceAudience; 026 027/** 028 * Implementation of {@link MetricsRegionServerQuotaSource}. 029 */ 030@InterfaceAudience.Private 031public class MetricsRegionServerQuotaSourceImpl extends BaseSourceImpl implements 032 MetricsRegionServerQuotaSource { 033 034 private final Meter tablesInViolationCounter; 035 private final Meter spaceQuotaSnapshotsReceived; 036 private final Timer fileSystemUtilizationChoreTimer; 037 private final Timer spaceQuotaRefresherChoreTimer; 038 private final Counter regionSizeReportCounter; 039 private final Timer regionSizeReportingChoreTimer; 040 041 public MetricsRegionServerQuotaSourceImpl() { 042 this(METRICS_NAME, METRICS_DESCRIPTION, METRICS_CONTEXT, METRICS_JMX_CONTEXT); 043 } 044 045 public MetricsRegionServerQuotaSourceImpl(String metricsName, String metricsDescription, 046 String metricsContext, String metricsJmxContext) { 047 super(metricsName, metricsDescription, metricsContext, metricsJmxContext); 048 049 tablesInViolationCounter = this.registry.meter(NUM_TABLES_IN_VIOLATION_NAME); 050 spaceQuotaSnapshotsReceived = this.registry.meter(NUM_SPACE_SNAPSHOTS_RECEIVED_NAME); 051 fileSystemUtilizationChoreTimer = this.registry.timer(FILE_SYSTEM_UTILIZATION_CHORE_TIME); 052 spaceQuotaRefresherChoreTimer = this.registry.timer(SPACE_QUOTA_REFRESHER_CHORE_TIME); 053 regionSizeReportCounter = this.registry.counter(NUM_REGION_SIZE_REPORT_NAME); 054 regionSizeReportingChoreTimer = registry.timer(REGION_SIZE_REPORTING_CHORE_TIME_NAME); 055 } 056 057 @Override 058 public void updateNumTablesInSpaceQuotaViolation(long tablesInViolation) { 059 this.tablesInViolationCounter.mark(tablesInViolation); 060 } 061 062 @Override 063 public void updateNumTableSpaceQuotaSnapshots(long numSnapshots) { 064 this.spaceQuotaSnapshotsReceived.mark(numSnapshots); 065 } 066 067 @Override 068 public void incrementSpaceQuotaFileSystemScannerChoreTime(long time) { 069 this.fileSystemUtilizationChoreTimer.updateMillis(time); 070 } 071 072 @Override 073 public void incrementSpaceQuotaRefresherChoreTime(long time) { 074 this.spaceQuotaRefresherChoreTimer.updateMillis(time); 075 } 076 077 @Override 078 public void incrementNumRegionSizeReportsSent(long numReportsSent) { 079 regionSizeReportCounter.increment(numReportsSent); 080 } 081 082 @Override 083 public void incrementRegionSizeReportingChoreTime(long time) { 084 regionSizeReportingChoreTimer.update(time, TimeUnit.MILLISECONDS); 085 } 086}