View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
3    * agreements. See the NOTICE file distributed with this work for additional information regarding
4    * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
5    * "License"); you may not use this file except in compliance with the License. You may obtain a
6    * copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable
7    * law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
8    * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
9    * for the specific language governing permissions and limitations under the License.
10   */
11  
12  package org.apache.hadoop.hbase.coordination;
13  
14  import java.io.IOException;
15  
16  import org.apache.hadoop.hbase.classification.InterfaceAudience;
17  import org.apache.hadoop.hbase.HRegionInfo;
18  import org.apache.hadoop.hbase.ServerName;
19  import org.apache.hadoop.hbase.regionserver.HRegion;
20  import org.apache.hadoop.hbase.regionserver.RegionServerServices;
21  
22  /**
23   * Coordination operations for region merge transaction. The operation should be coordinated at the
24   * following stages:<br>
25   * 1. startRegionMergeTransaction - all preparation/initialization for merge region transaction<br>
26   * 2. waitForRegionMergeTransaction - wait until coordination complete all works related 
27   * to merge<br>
28   * 3. confirmRegionMergeTransaction - confirm that the merge could be completed and none of merging
29   * regions moved somehow<br>
30   * 4. completeRegionMergeTransaction - all steps that are required to complete the transaction.
31   * Called after PONR (point of no return) <br>
32   */
33  @InterfaceAudience.Private
34  public interface RegionMergeCoordination {
35  
36    RegionMergeDetails getDefaultDetails();
37  
38    /**
39     * Dummy interface for region merge transaction details.
40     */
41    public static interface RegionMergeDetails {
42    }
43  
44    /**
45     * Start the region merge transaction
46     * @param region region to be created as offline
47     * @param serverName server event originates from
48     * @throws IOException
49     */
50    void startRegionMergeTransaction(HRegionInfo region, ServerName serverName, HRegionInfo a,
51        HRegionInfo b) throws IOException;
52  
53    /**
54     * Get everything ready for region merge
55     * @throws IOException
56     */
57    void waitForRegionMergeTransaction(RegionServerServices services, HRegionInfo mergedRegionInfo,
58        HRegion region_a, HRegion region_b, RegionMergeDetails details) throws IOException;
59  
60    /**
61     * Confirm that the region merge can be performed
62     * @param merged region
63     * @param a merging region A
64     * @param b merging region B
65     * @param serverName server event originates from
66     * @param rmd region merge details
67     * @throws IOException If thrown, transaction failed.
68     */
69    void confirmRegionMergeTransaction(HRegionInfo merged, HRegionInfo a, HRegionInfo b,
70        ServerName serverName, RegionMergeDetails rmd) throws IOException;
71  
72    /**
73     * @param merged region
74     * @param a merging region A
75     * @param b merging region B
76     * @param serverName server event originates from
77     * @param rmd region merge details
78     * @throws IOException
79     */
80    void processRegionMergeRequest(HRegionInfo merged, HRegionInfo a, HRegionInfo b,
81        ServerName serverName, RegionMergeDetails rmd) throws IOException;
82  
83    /**
84     * Finish off merge transaction
85     * @param services Used to online/offline regions.
86     * @param merged region
87     * @param region_a merging region A
88     * @param region_b merging region B
89     * @param rmd region merge details
90     * @param mergedRegion
91     * @throws IOException If thrown, transaction failed. Call
92     *  {@link org.apache.hadoop.hbase.regionserver.RegionMergeTransaction#rollback(
93     *  Server, RegionServerServices)}
94     */
95    void completeRegionMergeTransaction(RegionServerServices services, HRegionInfo merged,
96        HRegion region_a, HRegion region_b, RegionMergeDetails rmd, HRegion mergedRegion)
97        throws IOException;
98  
99    /**
100    * This method is used during rollback
101    * @param merged region to be rolled back
102    */
103   void clean(HRegionInfo merged);
104 
105 }