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 */ 018 019package org.apache.hadoop.hbase.util.hbck; 020 021import java.io.IOException; 022import java.util.Collection; 023import org.apache.hadoop.hbase.util.HbckRegionInfo; 024import org.apache.hadoop.hbase.util.HbckTableInfo; 025import org.apache.yetus.audience.InterfaceAudience; 026 027/** 028 * This interface provides callbacks for handling particular table integrity 029 * invariant violations. This could probably be boiled down to handling holes 030 * and handling overlaps but currently preserves the older more specific error 031 * condition codes. 032 */ 033@InterfaceAudience.Private 034public interface TableIntegrityErrorHandler { 035 036 HbckTableInfo getTableInfo(); 037 038 /** 039 * Set the TableInfo used by all HRegionInfos fabricated by other callbacks 040 */ 041 void setTableInfo(HbckTableInfo ti); 042 043 /** 044 * Callback for handling case where a Table has a first region that does not 045 * have an empty start key. 046 * 047 * @param hi An HbckRegionInfo of the second region in a table. This should have 048 * a non-empty startkey, and can be used to fabricate a first region that 049 * has an empty start key. 050 */ 051 void handleRegionStartKeyNotEmpty(HbckRegionInfo hi) throws IOException; 052 053 /** 054 * Callback for handling case where a Table has a last region that does not 055 * have an empty end key. 056 * 057 * @param curEndKey The end key of the current last region. There should be a new region 058 * with start key as this and an empty end key. 059 */ 060 void handleRegionEndKeyNotEmpty(byte[] curEndKey) throws IOException; 061 062 /** 063 * Callback for handling a region that has the same start and end key. 064 * 065 * @param hi An HbckRegionInfo for a degenerate key. 066 */ 067 void handleDegenerateRegion(HbckRegionInfo hi) throws IOException; 068 069 /** 070 * Callback for handling two regions that have the same start key. This is 071 * a specific case of a region overlap. 072 * @param hi1 one of the overlapping HbckRegionInfo 073 * @param hi2 the other overlapping HbckRegionInfo 074 */ 075 void handleDuplicateStartKeys(HbckRegionInfo hi1, HbckRegionInfo hi2) throws IOException; 076 077 /** 078 * Callback for handling two regions that have the same regionID 079 * a specific case of a split 080 * @param hi1 one of the overlapping HbckRegionInfo 081 * @param hi2 the other overlapping HbckRegionInfo 082 */ 083 void handleSplit(HbckRegionInfo hi1, HbckRegionInfo hi2) throws IOException; 084 085 /** 086 * Callback for handling two reigons that overlap in some arbitrary way. 087 * This is a specific case of region overlap, and called for each possible 088 * pair. If two regions have the same start key, the handleDuplicateStartKeys 089 * method is called. 090 * @param hi1 one of the overlapping HbckRegionInfo 091 * @param hi2 the other overlapping HbckRegionInfo 092 */ 093 void handleOverlapInRegionChain(HbckRegionInfo hi1, HbckRegionInfo hi2) 094 throws IOException; 095 096 /** 097 * Callback for handling a region hole between two keys. 098 * @param holeStartKey key at the beginning of the region hole 099 * @param holeEndKey key at the end of the region hole 100 101 */ 102 void handleHoleInRegionChain(byte[] holeStartKey, byte[] holeEndKey) 103 throws IOException; 104 105 /** 106 * Callback for handling an group of regions that overlap. 107 * @param overlap Collection of overlapping regions. 108 */ 109 void handleOverlapGroup(Collection<HbckRegionInfo> overlap) throws IOException; 110}