1 /*
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 package org.apache.hadoop.hbase.coprocessor;
17
18 import java.io.IOException;
19
20 import org.apache.hadoop.hbase.classification.InterfaceAudience;
21 import org.apache.hadoop.hbase.classification.InterfaceStability;
22 import org.apache.hadoop.hbase.Coprocessor;
23 import org.apache.hadoop.hbase.HBaseInterfaceAudience;
24
25 import com.google.protobuf.Message;
26 import com.google.protobuf.Service;
27
28 /**
29 * Coprocessors implement this interface to observe and mediate endpoint invocations
30 * on a region.
31 */
32 @InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)
33 @InterfaceStability.Evolving
34 public interface EndpointObserver extends Coprocessor {
35
36 /**
37 * Called before an Endpoint service method is invoked.
38 * The request message can be altered by returning a new instance. Throwing an
39 * exception will abort the invocation.
40 * Calling {@link org.apache.hadoop.hbase.coprocessor.ObserverContext#bypass()} has no
41 * effect in this hook.
42 * @param ctx the environment provided by the region server
43 * @param service the endpoint service
44 * @param methodName the invoked service method
45 * @param request the request message
46 * @return the possibly modified message
47 * @throws IOException
48 */
49 Message preEndpointInvocation(ObserverContext<RegionCoprocessorEnvironment> ctx, Service service,
50 String methodName, Message request) throws IOException;
51
52 /**
53 * Called after an Endpoint service method is invoked. The response message can be
54 * altered using the builder.
55 * @param ctx the environment provided by the region server
56 * @param service the endpoint service
57 * @param methodName the invoked service method
58 * @param request the request message
59 * @param responseBuilder the response message builder
60 * @throws IOException
61 */
62 void postEndpointInvocation(ObserverContext<RegionCoprocessorEnvironment> ctx, Service service,
63 String methodName, Message request, Message.Builder responseBuilder) throws IOException;
64
65 }