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 java.util.concurrent.TimeUnit; 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 032 implements 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}