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 package org.apache.hadoop.hbase.coprocessor; 20 21 import java.io.IOException; 22 import java.util.List; 23 24 import org.apache.hadoop.hbase.Coprocessor; 25 import org.apache.hadoop.hbase.MetaMutationAnnotation; 26 import org.apache.hadoop.hbase.client.Mutation; 27 import org.apache.hadoop.hbase.regionserver.HRegion; 28 import org.apache.hadoop.hbase.replication.ReplicationEndpoint; 29 30 public interface RegionServerObserver extends Coprocessor { 31 32 /** 33 * Called before stopping region server. 34 * @param env An instance of RegionServerCoprocessorEnvironment 35 * @throws IOException Signals that an I/O exception has occurred. 36 */ 37 void preStopRegionServer( 38 final ObserverContext<RegionServerCoprocessorEnvironment> env) 39 throws IOException; 40 41 /** 42 * Called before the regions merge. 43 * Call {@link org.apache.hadoop.hbase.coprocessor.ObserverContext#bypass()} to skip the merge. 44 * @throws IOException if an error occurred on the coprocessor 45 * @param ctx 46 * @param regionA 47 * @param regionB 48 * @throws IOException 49 */ 50 void preMerge(final ObserverContext<RegionServerCoprocessorEnvironment> ctx, 51 final HRegion regionA, final HRegion regionB) throws IOException; 52 53 /** 54 * called after the regions merge. 55 * @param c 56 * @param regionA 57 * @param regionB 58 * @param mergedRegion 59 * @throws IOException 60 */ 61 void postMerge(final ObserverContext<RegionServerCoprocessorEnvironment> c, 62 final HRegion regionA, final HRegion regionB, final HRegion mergedRegion) throws IOException; 63 64 /** 65 * This will be called before PONR step as part of regions merge transaction. Calling 66 * {@link org.apache.hadoop.hbase.coprocessor.ObserverContext#bypass()} rollback the merge 67 * @param ctx 68 * @param regionA 69 * @param regionB 70 * @param metaEntries mutations to execute on hbase:meta atomically with regions merge updates. 71 * Any puts or deletes to execute on hbase:meta can be added to the mutations. 72 * @throws IOException 73 */ 74 void preMergeCommit(final ObserverContext<RegionServerCoprocessorEnvironment> ctx, 75 final HRegion regionA, final HRegion regionB, 76 @MetaMutationAnnotation List<Mutation> metaEntries) throws IOException; 77 78 /** 79 * This will be called after PONR step as part of regions merge transaction. 80 * @param ctx 81 * @param regionA 82 * @param regionB 83 * @param mergedRegion 84 * @throws IOException 85 */ 86 void postMergeCommit(final ObserverContext<RegionServerCoprocessorEnvironment> ctx, 87 final HRegion regionA, final HRegion regionB, final HRegion mergedRegion) throws IOException; 88 89 /** 90 * This will be called before the roll back of the regions merge. 91 * @param ctx 92 * @param regionA 93 * @param regionB 94 * @throws IOException 95 */ 96 void preRollBackMerge(final ObserverContext<RegionServerCoprocessorEnvironment> ctx, 97 final HRegion regionA, final HRegion regionB) throws IOException; 98 99 /** 100 * This will be called after the roll back of the regions merge. 101 * @param ctx 102 * @param regionA 103 * @param regionB 104 * @throws IOException 105 */ 106 void postRollBackMerge(final ObserverContext<RegionServerCoprocessorEnvironment> ctx, 107 final HRegion regionA, final HRegion regionB) throws IOException; 108 109 /** 110 * This will be called before executing user request to roll a region server WAL. 111 * @param ctx An instance of ObserverContext 112 * @throws IOException Signals that an I/O exception has occurred. 113 */ 114 void preRollWALWriterRequest(final ObserverContext<RegionServerCoprocessorEnvironment> ctx) 115 throws IOException; 116 117 /** 118 * This will be called after executing user request to roll a region server WAL. 119 * @param ctx An instance of ObserverContext 120 * @throws IOException Signals that an I/O exception has occurred. 121 */ 122 void postRollWALWriterRequest(final ObserverContext<RegionServerCoprocessorEnvironment> ctx) 123 throws IOException; 124 125 /** 126 * This will be called after the replication endpoint is instantiated. 127 * 128 * @param ctx 129 * @param endpoint 130 * - the base endpoint for replication 131 * @return the endpoint to use during replication. 132 */ 133 ReplicationEndpoint postCreateReplicationEndPoint( 134 ObserverContext<RegionServerCoprocessorEnvironment> ctx, ReplicationEndpoint endpoint); 135 136 }