1 /** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20 package org.apache.hadoop.hbase.coordination; 21 22 import java.io.IOException; 23 24 import org.apache.hadoop.hbase.classification.InterfaceAudience; 25 import org.apache.hadoop.hbase.HRegionInfo; 26 import org.apache.hadoop.hbase.ServerName; 27 import org.apache.hadoop.hbase.regionserver.HRegion; 28 import org.apache.hadoop.hbase.regionserver.RegionServerServices; 29 30 /** 31 * Coordination operations for split transaction. The split operation should be coordinated at the 32 * following stages: 33 * 1. start - all preparation/initialization for split transaction should be done there. 34 * 2. waitForSplitTransaction - the coordination should perform all logic related to split 35 * transaction and wait till it's finished 36 * 3. completeSplitTransaction - all steps that are required to complete the transaction. 37 * Called after PONR (point of no return) 38 */ 39 @InterfaceAudience.Private 40 public interface SplitTransactionCoordination { 41 42 /** 43 * Dummy interface for split transaction details. 44 */ 45 public static interface SplitTransactionDetails { 46 } 47 48 SplitTransactionDetails getDefaultDetails(); 49 50 51 /** 52 * init coordination for split transaction 53 * @param parent region to be created as offline 54 * @param serverName server event originates from 55 * @param hri_a daughter region 56 * @param hri_b daughter region 57 * @throws IOException 58 */ 59 void startSplitTransaction(HRegion parent, ServerName serverName, 60 HRegionInfo hri_a, HRegionInfo hri_b) throws IOException; 61 62 /** 63 * Wait while coordination process the transaction 64 * @param services Used to online/offline regions. 65 * @param parent region 66 * @param hri_a daughter region 67 * @param hri_b daughter region 68 * @param std split transaction details 69 * @throws IOException 70 */ 71 void waitForSplitTransaction(final RegionServerServices services, 72 HRegion parent, HRegionInfo hri_a, HRegionInfo hri_b, SplitTransactionDetails std) 73 throws IOException; 74 75 /** 76 * Finish off split transaction 77 * @param services Used to online/offline regions. 78 * @param first daughter region 79 * @param second daughter region 80 * @param std split transaction details 81 * @param parent 82 * @throws IOException If thrown, transaction failed. Call 83 * {@link org.apache.hadoop.hbase.regionserver. 84 * SplitTransaction#rollback(Server, RegionServerServices)} 85 */ 86 void completeSplitTransaction(RegionServerServices services, HRegion first, 87 HRegion second, SplitTransactionDetails std, HRegion parent) throws IOException; 88 89 /** 90 * clean the split transaction 91 * @param hri node to delete 92 */ 93 void clean(final HRegionInfo hri); 94 95 /** 96 * Required by AssignmentManager 97 */ 98 int processTransition(HRegionInfo p, HRegionInfo hri_a, HRegionInfo hri_b, 99 ServerName sn, SplitTransactionDetails std) throws IOException; 100 }