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