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.quotas; 019 020import java.util.Map.Entry; 021import org.apache.hadoop.hbase.client.RegionInfo; 022import org.apache.hadoop.hbase.io.HeapSize; 023import org.apache.yetus.audience.InterfaceAudience; 024 025/** 026 * An interface for concurrently storing and updating the size of a Region. 027 */ 028@InterfaceAudience.Private 029public interface RegionSizeStore extends Iterable<Entry<RegionInfo, RegionSize>>, HeapSize { 030 031 /** 032 * Returns the size for the give region if one exists. If no size exists, {@code null} is 033 * returned. 034 * @param regionInfo The region whose size is being fetched. 035 * @return The size in bytes of the region or null if no size is stored. 036 */ 037 RegionSize getRegionSize(RegionInfo regionInfo); 038 039 /** 040 * Atomically sets the given {@code size} for a region. 041 * @param regionInfo An identifier for a region. 042 * @param size The size in bytes of the region. 043 */ 044 void put(RegionInfo regionInfo, long size); 045 046 /** 047 * Atomically alter the size of a region. 048 * @param regionInfo The region to update. 049 * @param delta The change in size for the region, positive or negative. 050 */ 051 void incrementRegionSize(RegionInfo regionInfo, long delta); 052 053 /** 054 * Removes the mapping for the given key, returning the value if one exists in the store. 055 * @param regionInfo The key to remove from the store 056 * @return The value removed from the store if one exists, otherwise null. 057 */ 058 RegionSize remove(RegionInfo regionInfo); 059 060 /** 061 * Returns the number of entries in the store. 062 * @return The number of entries in the store. 063 */ 064 int size(); 065 066 /** 067 * Returns if the store is empty. 068 * @return true if there are no entries in the store, otherwise false. 069 */ 070 boolean isEmpty(); 071 072 /** 073 * Removes all entries from the store. 074 */ 075 void clear(); 076}