001/* 002 * 003 * Licensed to the Apache Software Foundation (ASF) under one 004 * or more contributor license agreements. See the NOTICE file 005 * distributed with this work for additional information 006 * regarding copyright ownership. The ASF licenses this file 007 * to you under the Apache License, Version 2.0 (the 008 * "License"); you may not use this file except in compliance 009 * with the License. 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, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 */ 019package org.apache.hadoop.hbase.master.normalizer; 020 021import java.util.List; 022import org.apache.hadoop.conf.Configurable; 023import org.apache.hadoop.hbase.HBaseIOException; 024import org.apache.hadoop.hbase.TableName; 025import org.apache.hadoop.hbase.client.RegionInfo; 026import org.apache.hadoop.hbase.master.MasterServices; 027import org.apache.hadoop.hbase.master.normalizer.NormalizationPlan.PlanType; 028import org.apache.yetus.audience.InterfaceAudience; 029import org.apache.yetus.audience.InterfaceStability; 030 031/** 032 * Performs "normalization" of regions of a table, making sure that suboptimal 033 * choice of split keys doesn't leave cluster in a situation when some regions are 034 * substantially larger than others for considerable amount of time. 035 * 036 * Users who want to use this feature could either use default {@link SimpleRegionNormalizer} 037 * or plug in their own implementation. Please note that overly aggressive normalization rules 038 * (attempting to make all regions perfectly equal in size) could potentially lead to 039 * "split/merge storms". 040 */ 041@InterfaceAudience.Private 042@InterfaceStability.Evolving 043public interface RegionNormalizer extends Configurable { 044 /** 045 * Set the master service. Must be called before first call to 046 * {@link #computePlansForTable(TableName)}. 047 * @param masterServices master services to use 048 */ 049 void setMasterServices(MasterServices masterServices); 050 051 /** 052 * Computes a list of normalizer actions to perform on the target table. This is the primary 053 * entry-point from the Master driving a normalization activity. 054 * @param table table to normalize 055 * @return A list of the normalization actions to perform, or an empty list 056 * if there's nothing to do. 057 */ 058 List<NormalizationPlan> computePlansForTable(TableName table) 059 throws HBaseIOException; 060 061 /** 062 * Notification for the case where plan couldn't be executed due to constraint violation, such as 063 * namespace quota 064 * @param hri the region which is involved in the plan 065 * @param type type of plan 066 */ 067 void planSkipped(RegionInfo hri, PlanType type); 068 069 /** 070 * @param type type of plan for which skipped count is to be returned 071 * @return the count of plans of specified type which were skipped 072 */ 073 long getSkippedCount(NormalizationPlan.PlanType type); 074}