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