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.client.coprocessor;
21
22 import org.apache.hadoop.hbase.classification.InterfaceAudience;
23 import org.apache.hadoop.hbase.classification.InterfaceStability;
24
25 import java.io.IOException;
26
27 /**
28 * A collection of interfaces and utilities used for interacting with custom RPC
29 * interfaces exposed by Coprocessors.
30 */
31 @InterfaceAudience.Public
32 @InterfaceStability.Stable
33 public abstract class Batch {
34 /**
35 * Defines a unit of work to be executed.
36 *
37 * <p>
38 * When used with
39 * {@link org.apache.hadoop.hbase.client.HTable#coprocessorService(Class, byte[], byte[], org.apache.hadoop.hbase.client.coprocessor.Batch.Call)}
40 * the implementations {@link Batch.Call#call(Object)} method will be invoked
41 * with a proxy to each region's coprocessor {@link com.google.protobuf.Service} implementation.
42 * </p>
43 * @see org.apache.hadoop.hbase.client.coprocessor.Batch
44 * @see org.apache.hadoop.hbase.client.HTable#coprocessorService(byte[])
45 * @see org.apache.hadoop.hbase.client.HTable#coprocessorService(Class, byte[], byte[],
46 * org.apache.hadoop.hbase.client.coprocessor.Batch.Call)
47 * @param <T> the instance type to be passed to
48 * {@link Batch.Call#call(Object)}
49 * @param <R> the return type from {@link Batch.Call#call(Object)}
50 */
51 @InterfaceAudience.Public
52 @InterfaceStability.Stable
53 public interface Call<T,R> {
54 R call(T instance) throws IOException;
55 }
56
57 /**
58 * Defines a generic callback to be triggered for each {@link Batch.Call#call(Object)}
59 * result.
60 *
61 * <p>
62 * When used with
63 * {@link org.apache.hadoop.hbase.client.HTable#coprocessorService(Class, byte[], byte[], org.apache.hadoop.hbase.client.coprocessor.Batch.Call)}
64 * the implementation's {@link Batch.Callback#update(byte[], byte[], Object)}
65 * method will be called with the {@link Batch.Call#call(Object)} return value
66 * from each region in the selected range.
67 * </p>
68 * @param <R> the return type from the associated {@link Batch.Call#call(Object)}
69 * @see org.apache.hadoop.hbase.client.HTable#coprocessorService(Class, byte[], byte[], org.apache.hadoop.hbase.client.coprocessor.Batch.Call)
70 */
71 @InterfaceAudience.Public
72 @InterfaceStability.Stable
73 public interface Callback<R> {
74 void update(byte[] region, byte[] row, R result);
75 }
76 }