View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  package org.apache.hadoop.hbase.util.hbck;
20  
21  import java.io.IOException;
22  import java.util.Collection;
23  
24  import org.apache.hadoop.hbase.util.HBaseFsck.HbckInfo;
25  import org.apache.hadoop.hbase.util.HBaseFsck.TableInfo;
26  
27  /**
28   * This interface provides callbacks for handling particular table integrity
29   * invariant violations.  This could probably be boiled down to handling holes
30   * and handling overlaps but currently preserves the older more specific error
31   * condition codes.
32   */
33  public interface TableIntegrityErrorHandler {
34  
35    TableInfo getTableInfo();
36  
37    /**
38     * Set the TableInfo used by all HRegionInfos fabricated by other callbacks
39     */
40    void setTableInfo(TableInfo ti);
41  
42    /**
43     * Callback for handling case where a Table has a first region that does not
44     * have an empty start key.
45     *
46     * @param hi An HbckInfo of the second region in a table.  This should have
47     *    a non-empty startkey, and can be used to fabricate a first region that
48     *    has an empty start key.
49     */
50    void handleRegionStartKeyNotEmpty(HbckInfo hi) throws IOException;
51    
52    /**
53     * Callback for handling case where a Table has a last region that does not
54     * have an empty end key.
55     *
56     * @param curEndKey The end key of the current last region. There should be a new region
57     *    with start key as this and an empty end key.
58     */
59    void handleRegionEndKeyNotEmpty(byte[] curEndKey) throws IOException;
60  
61    /**
62     * Callback for handling a region that has the same start and end key.
63     *
64     * @param hi An HbckInfo for a degenerate key.
65     */
66    void handleDegenerateRegion(HbckInfo hi) throws IOException;
67  
68    /**
69     * Callback for handling two regions that have the same start key.  This is
70     * a specific case of a region overlap.
71     * @param hi1 one of the overlapping HbckInfo 
72     * @param hi2 the other overlapping HbckInfo
73     */
74    void handleDuplicateStartKeys(HbckInfo hi1, HbckInfo hi2) throws IOException;
75  
76    /**
77     * Callback for handling two regions that have the same regionID
78     * a specific case of a split
79     * @param hi1 one of the overlapping HbckInfo
80     * @param hi2 the other overlapping HbckInfo
81     */
82    void handleSplit(HbckInfo hi1, HbckInfo hi2) throws IOException;
83  
84    /**
85     * Callback for handling two reigons that overlap in some arbitrary way.
86     * This is a specific case of region overlap, and called for each possible
87     * pair. If two regions have the same start key, the handleDuplicateStartKeys
88     * method is called.
89     * @param hi1 one of the overlapping HbckInfo
90     * @param hi2 the other overlapping HbckInfo
91     */
92    void handleOverlapInRegionChain(HbckInfo hi1, HbckInfo hi2)
93        throws IOException;
94  
95    /**
96     * Callback for handling a region hole between two keys.
97     * @param holeStartKey key at the beginning of the region hole
98     * @param holeEndKey key at the end of the region hole
99     
100    */
101   void handleHoleInRegionChain(byte[] holeStartKey, byte[] holeEndKey)
102       throws IOException;
103 
104   /**
105    * Callback for handling an group of regions that overlap.
106    * @param overlap Collection of overlapping regions.
107    */
108   void handleOverlapGroup(Collection<HbckInfo> overlap) throws IOException;
109 }