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.Region; 29 import org.apache.hadoop.hbase.regionserver.RegionServerServices; 30 31 /** 32 * Coordination operations for split transaction. The split operation should be coordinated at the 33 * following stages: 34 * 1. start - all preparation/initialization for split transaction should be done there. 35 * 2. waitForSplitTransaction - the coordination should perform all logic related to split 36 * transaction and wait till it's finished 37 * 3. completeSplitTransaction - all steps that are required to complete the transaction. 38 * Called after PONR (point of no return) 39 */ 40 @InterfaceAudience.Private 41 public interface SplitTransactionCoordination { 42 43 /** 44 * Dummy interface for split transaction details. 45 */ 46 public static interface SplitTransactionDetails { 47 } 48 49 SplitTransactionDetails getDefaultDetails(); 50 51 52 /** 53 * init coordination for split transaction 54 * @param parent region to be created as offline 55 * @param serverName server event originates from 56 * @param hri_a daughter region 57 * @param hri_b daughter region 58 * @throws IOException 59 */ 60 void startSplitTransaction(HRegion parent, ServerName serverName, 61 HRegionInfo hri_a, HRegionInfo hri_b) throws IOException; 62 63 /** 64 * Wait while coordination process the transaction 65 * @param services Used to online/offline regions. 66 * @param parent region 67 * @param hri_a daughter region 68 * @param hri_b daughter region 69 * @param std split transaction details 70 * @throws IOException 71 */ 72 void waitForSplitTransaction(final RegionServerServices services, 73 Region parent, HRegionInfo hri_a, HRegionInfo hri_b, SplitTransactionDetails std) 74 throws IOException; 75 76 /** 77 * Finish off split transaction 78 * @param services Used to online/offline regions. 79 * @param first daughter region 80 * @param second daughter region 81 * @param std split transaction details 82 * @param parent 83 * @throws IOException If thrown, transaction failed. Call 84 * {@link org.apache.hadoop.hbase.regionserver.SplitTransaction#rollback( 85 * Server, RegionServerServices)} 86 */ 87 void completeSplitTransaction(RegionServerServices services, Region first, 88 Region second, SplitTransactionDetails std, Region parent) throws IOException; 89 90 /** 91 * clean the split transaction 92 * @param hri node to delete 93 */ 94 void clean(final HRegionInfo hri); 95 96 /** 97 * Required by AssignmentManager 98 */ 99 int processTransition(HRegionInfo p, HRegionInfo hri_a, HRegionInfo hri_b, 100 ServerName sn, SplitTransactionDetails std) throws IOException; 101 }