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 reigons that overlap in some arbitrary way.
78 * This is a specific case of region overlap, and called for each possible
79 * pair. If two regions have the same start key, the handleDuplicateStartKeys
80 * method is called.
81 * @param hi1 one of the overlapping HbckInfo
82 * @param hi2 the other overlapping HbckInfo
83 */
84 void handleOverlapInRegionChain(HbckInfo hi1, HbckInfo hi2)
85 throws IOException;
86
87 /**
88 * Callback for handling a region hole between two keys.
89 * @param holeStartKey key at the beginning of the region hole
90 * @param holeEndKey key at the end of the region hole
91
92 */
93 void handleHoleInRegionChain(byte[] holeStartKey, byte[] holeEndKey)
94 throws IOException;
95
96 /**
97 * Callback for handling an group of regions that overlap.
98 * @param overlap Collection of overlapping regions.
99 */
100 void handleOverlapGroup(Collection<HbckInfo> overlap) throws IOException;
101 }