View Javadoc

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.client;
20  
21  import com.google.protobuf.Descriptors;
22  import com.google.protobuf.Message;
23  import com.google.protobuf.Service;
24  import com.google.protobuf.ServiceException;
25  
26  import org.apache.hadoop.classification.InterfaceAudience;
27  import org.apache.hadoop.classification.InterfaceStability;
28  import org.apache.hadoop.conf.Configuration;
29  import org.apache.hadoop.hbase.TableName;
30  import org.apache.hadoop.hbase.HTableDescriptor;
31  import org.apache.hadoop.hbase.KeyValue;
32  import org.apache.hadoop.hbase.client.coprocessor.Batch;
33  import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
34  import org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel;
35  
36  import java.io.Closeable;
37  import java.io.IOException;
38  import java.util.List;
39  import java.util.Map;
40  
41  /**
42   * Used to communicate with a single HBase table.
43   * Obtain an instance from an {@link HConnection}.
44   *
45   * @since 0.21.0
46   */
47  @InterfaceAudience.Public
48  @InterfaceStability.Stable
49  public interface HTableInterface extends Closeable {
50  
51    /**
52     * Gets the name of this table.
53     *
54     * @return the table name.
55     */
56    byte[] getTableName();
57  
58    /**
59     * Gets the fully qualified table name instance of this table.
60     */
61    TableName getName();
62  
63    /**
64     * Returns the {@link Configuration} object used by this instance.
65     * <p>
66     * The reference returned is not a copy, so any change made to it will
67     * affect this instance.
68     */
69    Configuration getConfiguration();
70  
71    /**
72     * Gets the {@link HTableDescriptor table descriptor} for this table.
73     * @throws IOException if a remote or network exception occurs.
74     */
75    HTableDescriptor getTableDescriptor() throws IOException;
76  
77    /**
78     * Test for the existence of columns in the table, as specified by the Get.
79     * <p>
80     *
81     * This will return true if the Get matches one or more keys, false if not.
82     * <p>
83     *
84     * This is a server-side call so it prevents any data from being transfered to
85     * the client.
86     *
87     * @param get the Get
88     * @return true if the specified Get matches one or more keys, false if not
89     * @throws IOException e
90     */
91    boolean exists(Get get) throws IOException;
92  
93    /**
94     * Test for the existence of columns in the table, as specified by the Gets.
95     * <p>
96     *
97     * This will return an array of booleans. Each value will be true if the related Get matches
98     * one or more keys, false if not.
99     * <p>
100    *
101    * This is a server-side call so it prevents any data from being transfered to
102    * the client.
103    *
104    * @param gets the Gets
105    * @return Array of Boolean true if the specified Get matches one or more keys, false if not
106    * @throws IOException e
107    */
108   Boolean[] exists(List<Get> gets) throws IOException;
109 
110   /**
111    * Method that does a batch call on Deletes, Gets, Puts, Increments and Appends.
112    * The ordering of execution of the actions is not defined. Meaning if you do a Put and a
113    * Get in the same {@link #batch} call, you will not necessarily be
114    * guaranteed that the Get returns what the Put had put.
115    *
116    * @param actions list of Get, Put, Delete, Increment, Append objects
117    * @param results Empty Object[], same size as actions. Provides access to partial
118    *                results, in case an exception is thrown. A null in the result array means that
119    *                the call for that action failed, even after retries
120    * @throws IOException
121    * @since 0.90.0
122    */
123   void batch(final List<? extends Row> actions, final Object[] results) throws IOException,
124       InterruptedException;
125 
126   /**
127    * Same as {@link #batch(List, Object[])}, but returns an array of
128    * results instead of using a results parameter reference.
129    *
130    * @param actions list of Get, Put, Delete, Increment, Append objects
131    * @return the results from the actions. A null in the return array means that
132    *         the call for that action failed, even after retries
133    * @throws IOException
134    * @since 0.90.0
135    * @deprecated If any exception is thrown by one of the actions, there is no way to
136    * retrieve the partially executed results. Use {@link #batch(List, Object[])} instead.
137    */
138   Object[] batch(final List<? extends Row> actions) throws IOException, InterruptedException;
139 
140   /**
141    * Same as {@link #batch(List, Object[])}, but with a callback.
142    * @since 0.96.0
143    */
144   <R> void batchCallback(
145     final List<? extends Row> actions, final Object[] results, final Batch.Callback<R> callback
146   )
147     throws IOException, InterruptedException;
148 
149 
150   /**
151    * Same as {@link #batch(List)}, but with a callback.
152    * @since 0.96.0
153    * @deprecated If any exception is thrown by one of the actions, there is no way to
154    * retrieve the partially executed results. Use
155    * {@link #batchCallback(List, Object[], org.apache.hadoop.hbase.client.coprocessor.Batch.Callback)}
156    * instead.
157    */
158   <R> Object[] batchCallback(
159     List<? extends Row> actions, Batch.Callback<R> callback
160   ) throws IOException,
161     InterruptedException;
162 
163   /**
164    * Extracts certain cells from a given row.
165    * @param get The object that specifies what data to fetch and from which row.
166    * @return The data coming from the specified row, if it exists.  If the row
167    * specified doesn't exist, the {@link Result} instance returned won't
168    * contain any {@link KeyValue}, as indicated by {@link Result#isEmpty()}.
169    * @throws IOException if a remote or network exception occurs.
170    * @since 0.20.0
171    */
172   Result get(Get get) throws IOException;
173 
174   /**
175    * Extracts certain cells from the given rows, in batch.
176    *
177    * @param gets The objects that specify what data to fetch and from which rows.
178    *
179    * @return The data coming from the specified rows, if it exists.  If the row
180    *         specified doesn't exist, the {@link Result} instance returned won't
181    *         contain any {@link KeyValue}, as indicated by {@link Result#isEmpty()}.
182    *         If there are any failures even after retries, there will be a null in
183    *         the results array for those Gets, AND an exception will be thrown.
184    * @throws IOException if a remote or network exception occurs.
185    *
186    * @since 0.90.0
187    */
188   Result[] get(List<Get> gets) throws IOException;
189 
190   /**
191    * Return the row that matches <i>row</i> exactly,
192    * or the one that immediately precedes it.
193    *
194    * @param row A row key.
195    * @param family Column family to include in the {@link Result}.
196    * @throws IOException if a remote or network exception occurs.
197    * @since 0.20.0
198    * 
199    * @deprecated As of version 0.92 this method is deprecated without
200    * replacement. Since version 0.96+, you can use reversed scan.
201    * getRowOrBefore is used internally to find entries in hbase:meta and makes
202    * various assumptions about the table (which are true for hbase:meta but not
203    * in general) to be efficient.
204    */
205   Result getRowOrBefore(byte[] row, byte[] family) throws IOException;
206 
207   /**
208    * Returns a scanner on the current table as specified by the {@link Scan}
209    * object.
210    * Note that the passed {@link Scan}'s start row and caching properties
211    * maybe changed.
212    *
213    * @param scan A configured {@link Scan} object.
214    * @return A scanner.
215    * @throws IOException if a remote or network exception occurs.
216    * @since 0.20.0
217    */
218   ResultScanner getScanner(Scan scan) throws IOException;
219 
220   /**
221    * Gets a scanner on the current table for the given family.
222    *
223    * @param family The column family to scan.
224    * @return A scanner.
225    * @throws IOException if a remote or network exception occurs.
226    * @since 0.20.0
227    */
228   ResultScanner getScanner(byte[] family) throws IOException;
229 
230   /**
231    * Gets a scanner on the current table for the given family and qualifier.
232    *
233    * @param family The column family to scan.
234    * @param qualifier The column qualifier to scan.
235    * @return A scanner.
236    * @throws IOException if a remote or network exception occurs.
237    * @since 0.20.0
238    */
239   ResultScanner getScanner(byte[] family, byte[] qualifier) throws IOException;
240 
241 
242   /**
243    * Puts some data in the table.
244    * <p>
245    * If {@link #isAutoFlush isAutoFlush} is false, the update is buffered
246    * until the internal buffer is full.
247    * @param put The data to put.
248    * @throws IOException if a remote or network exception occurs.
249    * @since 0.20.0
250    */
251   void put(Put put) throws IOException;
252 
253   /**
254    * Puts some data in the table, in batch.
255    * <p>
256    * If {@link #isAutoFlush isAutoFlush} is false, the update is buffered
257    * until the internal buffer is full.
258    * <p>
259    * This can be used for group commit, or for submitting user defined
260    * batches.  The writeBuffer will be periodically inspected while the List
261    * is processed, so depending on the List size the writeBuffer may flush
262    * not at all, or more than once.
263    * @param puts The list of mutations to apply. The batch put is done by
264    * aggregating the iteration of the Puts over the write buffer
265    * at the client-side for a single RPC call.
266    * @throws IOException if a remote or network exception occurs.
267    * @since 0.20.0
268    */
269   void put(List<Put> puts) throws IOException;
270 
271   /**
272    * Atomically checks if a row/family/qualifier value matches the expected
273    * value. If it does, it adds the put.  If the passed value is null, the check
274    * is for the lack of column (ie: non-existance)
275    *
276    * @param row to check
277    * @param family column family to check
278    * @param qualifier column qualifier to check
279    * @param value the expected value
280    * @param put data to put if check succeeds
281    * @throws IOException e
282    * @return true if the new put was executed, false otherwise
283    */
284   boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier,
285       byte[] value, Put put) throws IOException;
286 
287   boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier,
288       CompareOp compareOp, byte[] value, Put put) throws IOException;
289   /**
290    * Deletes the specified cells/row.
291    *
292    * @param delete The object that specifies what to delete.
293    * @throws IOException if a remote or network exception occurs.
294    * @since 0.20.0
295    */
296   void delete(Delete delete) throws IOException;
297 
298   /**
299    * Deletes the specified cells/rows in bulk.
300    * @param deletes List of things to delete.  List gets modified by this
301    * method (in particular it gets re-ordered, so the order in which the elements
302    * are inserted in the list gives no guarantee as to the order in which the
303    * {@link Delete}s are executed).
304    * @throws IOException if a remote or network exception occurs. In that case
305    * the {@code deletes} argument will contain the {@link Delete} instances
306    * that have not be successfully applied.
307    * @since 0.20.1
308    */
309   void delete(List<Delete> deletes) throws IOException;
310 
311   /**
312    * Atomically checks if a row/family/qualifier value matches the expected
313    * value. If it does, it adds the delete.  If the passed value is null, the
314    * check is for the lack of column (ie: non-existance)
315    *
316    * @param row to check
317    * @param family column family to check
318    * @param qualifier column qualifier to check
319    * @param value the expected value
320    * @param delete data to delete if check succeeds
321    * @throws IOException e
322    * @return true if the new delete was executed, false otherwise
323    */
324   boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier,
325       byte[] value, Delete delete) throws IOException;
326 
327   boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier,
328       CompareOp compareOp, byte[] value, Delete delete) throws IOException;
329 
330   /**
331    * Performs multiple mutations atomically on a single row. Currently
332    * {@link Put} and {@link Delete} are supported.
333    *
334    * @param rm object that specifies the set of mutations to perform atomically
335    * @throws IOException
336    */
337   void mutateRow(final RowMutations rm) throws IOException;
338 
339   /**
340    * Appends values to one or more columns within a single row.
341    * <p>
342    * This operation does not appear atomic to readers.  Appends are done
343    * under a single row lock, so write operations to a row are synchronized, but
344    * readers do not take row locks so get and scan operations can see this
345    * operation partially completed.
346    *
347    * @param append object that specifies the columns and amounts to be used
348    *                  for the increment operations
349    * @throws IOException e
350    * @return values of columns after the append operation (maybe null)
351    */
352   Result append(final Append append) throws IOException;
353 
354   /**
355    * Increments one or more columns within a single row.
356    * <p>
357    * This operation does not appear atomic to readers.  Increments are done
358    * under a single row lock, so write operations to a row are synchronized, but
359    * readers do not take row locks so get and scan operations can see this
360    * operation partially completed.
361    *
362    * @param increment object that specifies the columns and amounts to be used
363    *                  for the increment operations
364    * @throws IOException e
365    * @return values of columns after the increment
366    */
367   Result increment(final Increment increment) throws IOException;
368 
369   /**
370    * See {@link #incrementColumnValue(byte[], byte[], byte[], long, Durability)}
371    * <p>
372    * The {@link Durability} is defaulted to {@link Durability#SYNC_WAL}.
373    * @param row The row that contains the cell to increment.
374    * @param family The column family of the cell to increment.
375    * @param qualifier The column qualifier of the cell to increment.
376    * @param amount The amount to increment the cell with (or decrement, if the
377    * amount is negative).
378    * @return The new value, post increment.
379    * @throws IOException if a remote or network exception occurs.
380    */
381   long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier,
382       long amount) throws IOException;
383 
384   /**
385    * Atomically increments a column value. If the column value already exists
386    * and is not a big-endian long, this could throw an exception. If the column
387    * value does not yet exist it is initialized to <code>amount</code> and
388    * written to the specified column.
389    *
390    * <p>Setting durability to {@link Durability#SKIP_WAL} means that in a fail
391    * scenario you will lose any increments that have not been flushed.
392    * @param row The row that contains the cell to increment.
393    * @param family The column family of the cell to increment.
394    * @param qualifier The column qualifier of the cell to increment.
395    * @param amount The amount to increment the cell with (or decrement, if the
396    * amount is negative).
397    * @param durability The persistence guarantee for this increment.
398    * @return The new value, post increment.
399    * @throws IOException if a remote or network exception occurs.
400    */
401   long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier,
402       long amount, Durability durability) throws IOException;
403 
404   /**
405    * @deprecated Use {@link #incrementColumnValue(byte[], byte[], byte[], long, Durability)}
406    */
407   @Deprecated
408   long incrementColumnValue(final byte [] row, final byte [] family,
409       final byte [] qualifier, final long amount, final boolean writeToWAL)
410   throws IOException;
411 
412   /**
413    * Tells whether or not 'auto-flush' is turned on.
414    *
415    * @return {@code true} if 'auto-flush' is enabled (default), meaning
416    * {@link Put} operations don't get buffered/delayed and are immediately
417    * executed.
418    */
419   boolean isAutoFlush();
420 
421   /**
422    * Executes all the buffered {@link Put} operations.
423    * <p>
424    * This method gets called once automatically for every {@link Put} or batch
425    * of {@link Put}s (when <code>put(List<Put>)</code> is used) when
426    * {@link #isAutoFlush} is {@code true}.
427    * @throws IOException if a remote or network exception occurs.
428    */
429   void flushCommits() throws IOException;
430 
431   /**
432    * Releases any resources held or pending changes in internal buffers.
433    *
434    * @throws IOException if a remote or network exception occurs.
435    */
436   void close() throws IOException;
437 
438   /**
439    * Creates and returns a {@link com.google.protobuf.RpcChannel} instance connected to the
440    * table region containing the specified row.  The row given does not actually have
441    * to exist.  Whichever region would contain the row based on start and end keys will
442    * be used.  Note that the {@code row} parameter is also not passed to the
443    * coprocessor handler registered for this protocol, unless the {@code row}
444    * is separately passed as an argument in the service request.  The parameter
445    * here is only used to locate the region used to handle the call.
446    *
447    * <p>
448    * The obtained {@link com.google.protobuf.RpcChannel} instance can be used to access a published
449    * coprocessor {@link com.google.protobuf.Service} using standard protobuf service invocations:
450    * </p>
451    *
452    * <div style="background-color: #cccccc; padding: 2px">
453    * <blockquote><pre>
454    * CoprocessorRpcChannel channel = myTable.coprocessorService(rowkey);
455    * MyService.BlockingInterface service = MyService.newBlockingStub(channel);
456    * MyCallRequest request = MyCallRequest.newBuilder()
457    *     ...
458    *     .build();
459    * MyCallResponse response = service.myCall(null, request);
460    * </pre></blockquote></div>
461    *
462    * @param row The row key used to identify the remote region location
463    * @return A CoprocessorRpcChannel instance
464    */
465   @InterfaceAudience.Private // TODO add coproc audience level  
466   CoprocessorRpcChannel coprocessorService(byte[] row);
467 
468   /**
469    * Creates an instance of the given {@link com.google.protobuf.Service} subclass for each table
470    * region spanning the range from the {@code startKey} row to {@code endKey} row (inclusive),
471    * and invokes the passed {@link org.apache.hadoop.hbase.client.coprocessor.Batch.Call#call}
472    * method with each {@link Service}
473    * instance.
474    *
475    * @param service the protocol buffer {@code Service} implementation to call
476    * @param startKey start region selection with region containing this row.  If {@code null}, the
477    *                 selection will start with the first table region.
478    * @param endKey select regions up to and including the region containing this row.
479    *               If {@code null}, selection will continue through the last table region.
480    * @param callable this instance's
481    *                 {@link org.apache.hadoop.hbase.client.coprocessor.Batch.Call#call}
482    *                 method will be invoked once per table region, using the {@link Service}
483    *                 instance connected to that region.
484    * @param <T> the {@link Service} subclass to connect to
485    * @param <R> Return type for the {@code callable} parameter's
486    * {@link org.apache.hadoop.hbase.client.coprocessor.Batch.Call#call} method
487    * @return a map of result values keyed by region name
488    */
489   @InterfaceAudience.Private // TODO add coproc audience level
490   <T extends Service, R> Map<byte[],R> coprocessorService(final Class<T> service,
491       byte[] startKey, byte[] endKey, final Batch.Call<T,R> callable)
492       throws ServiceException, Throwable;
493 
494   /**
495    * Creates an instance of the given {@link com.google.protobuf.Service} subclass for each table
496    * region spanning the range from the {@code startKey} row to {@code endKey} row (inclusive),
497    * and invokes the passed {@link org.apache.hadoop.hbase.client.coprocessor.Batch.Call#call}
498    * method with each {@link Service} instance.
499    *
500    * <p>
501    * The given
502    * {@link org.apache.hadoop.hbase.client.coprocessor.Batch.Callback#update(byte[], byte[], Object)}
503    * method will be called with the return value from each region's
504    * {@link org.apache.hadoop.hbase.client.coprocessor.Batch.Call#call} invocation.
505    *</p>
506    *
507    * @param service the protocol buffer {@code Service} implementation to call
508    * @param startKey start region selection with region containing this row.  If {@code null}, the
509    *                 selection will start with the first table region.
510    * @param endKey select regions up to and including the region containing this row.
511    *               If {@code null}, selection will continue through the last table region.
512    * @param callable this instance's
513    *                 {@link org.apache.hadoop.hbase.client.coprocessor.Batch.Call#call} method
514    *                 will be invoked once per table region, using the {@link Service} instance
515    *                 connected to that region.
516    * @param callback
517    * @param <T> the {@link Service} subclass to connect to
518    * @param <R> Return type for the {@code callable} parameter's
519    * {@link org.apache.hadoop.hbase.client.coprocessor.Batch.Call#call} method
520    */
521   @InterfaceAudience.Private // TODO add coproc audience level
522   <T extends Service, R> void coprocessorService(final Class<T> service,
523       byte[] startKey, byte[] endKey, final Batch.Call<T,R> callable,
524       final Batch.Callback<R> callback) throws ServiceException, Throwable;
525 
526   /**
527    * See {@link #setAutoFlush(boolean, boolean)}
528    *
529    * @param autoFlush
530    *          Whether or not to enable 'auto-flush'.
531    * @deprecated in 0.96. When called with setAutoFlush(false), this function also
532    *  set clearBufferOnFail to true, which is unexpected but kept for historical reasons.
533    *  Replace it with setAutoFlush(false, false) if this is exactly what you want, or by
534    *  {@link #setAutoFlushTo(boolean)} for all other cases.
535    */
536   @Deprecated
537   void setAutoFlush(boolean autoFlush);
538 
539   /**
540    * Turns 'auto-flush' on or off.
541    * <p>
542    * When enabled (default), {@link Put} operations don't get buffered/delayed
543    * and are immediately executed. Failed operations are not retried. This is
544    * slower but safer.
545    * <p>
546    * Turning off {@code #autoFlush} means that multiple {@link Put}s will be
547    * accepted before any RPC is actually sent to do the write operations. If the
548    * application dies before pending writes get flushed to HBase, data will be
549    * lost.
550    * <p>
551    * When you turn {@code #autoFlush} off, you should also consider the
552    * {@code #clearBufferOnFail} option. By default, asynchronous {@link Put}
553    * requests will be retried on failure until successful. However, this can
554    * pollute the writeBuffer and slow down batching performance. Additionally,
555    * you may want to issue a number of Put requests and call
556    * {@link #flushCommits()} as a barrier. In both use cases, consider setting
557    * clearBufferOnFail to true to erase the buffer after {@link #flushCommits()}
558    * has been called, regardless of success.
559    * <p>
560    * In other words, if you call {@code #setAutoFlush(false)}; HBase will retry N time for each
561    *  flushCommit, including the last one when closing the table. This is NOT recommended,
562    *  most of the time you want to call {@code #setAutoFlush(false, true)}.
563    *
564    * @param autoFlush
565    *          Whether or not to enable 'auto-flush'.
566    * @param clearBufferOnFail
567    *          Whether to keep Put failures in the writeBuffer. If autoFlush is true, then
568    *          the value of this parameter is ignored and clearBufferOnFail is set to true.
569    *          Setting clearBufferOnFail to false is deprecated since 0.96.
570    * @deprecated in 0.99 since setting clearBufferOnFail is deprecated. Use
571    *  {@link #setAutoFlushTo(boolean)}} instead.
572    * @see #flushCommits
573    */
574   @Deprecated
575   void setAutoFlush(boolean autoFlush, boolean clearBufferOnFail);
576 
577   /**
578    * Set the autoFlush behavior, without changing the value of {@code clearBufferOnFail}
579    */
580   void setAutoFlushTo(boolean autoFlush);
581 
582   /**
583    * Returns the maximum size in bytes of the write buffer for this HTable.
584    * <p>
585    * The default value comes from the configuration parameter
586    * {@code hbase.client.write.buffer}.
587    * @return The size of the write buffer in bytes.
588    */
589   long getWriteBufferSize();
590 
591   /**
592    * Sets the size of the buffer in bytes.
593    * <p>
594    * If the new size is less than the current amount of data in the
595    * write buffer, the buffer gets flushed.
596    * @param writeBufferSize The new write buffer size, in bytes.
597    * @throws IOException if a remote or network exception occurs.
598    */
599   void setWriteBufferSize(long writeBufferSize) throws IOException;
600 
601   /**
602    * Creates an instance of the given {@link com.google.protobuf.Service} subclass for each table
603    * region spanning the range from the {@code startKey} row to {@code endKey} row (inclusive), all
604    * the invocations to the same region server will be batched into one call. The coprocessor
605    * service is invoked according to the service instance, method name and parameters.
606    * 
607    * @param methodDescriptor
608    *          the descriptor for the protobuf service method to call.
609    * @param request
610    *          the method call parameters
611    * @param startKey
612    *          start region selection with region containing this row. If {@code null}, the
613    *          selection will start with the first table region.
614    * @param endKey
615    *          select regions up to and including the region containing this row. If {@code null},
616    *          selection will continue through the last table region.
617    * @param responsePrototype
618    *          the proto type of the response of the method in Service.
619    * @param <R>
620    *          the response type for the coprocessor Service method
621    * @throws ServiceException
622    * @throws Throwable
623    * @return a map of result values keyed by region name
624    */
625   @InterfaceAudience.Private
626   <R extends Message> Map<byte[], R> batchCoprocessorService(
627       Descriptors.MethodDescriptor methodDescriptor, Message request,
628       byte[] startKey, byte[] endKey, R responsePrototype) throws ServiceException, Throwable;
629 
630   /**
631    * Creates an instance of the given {@link com.google.protobuf.Service} subclass for each table
632    * region spanning the range from the {@code startKey} row to {@code endKey} row (inclusive), all
633    * the invocations to the same region server will be batched into one call. The coprocessor
634    * service is invoked according to the service instance, method name and parameters.
635    * 
636    * <p>
637    * The given
638    * {@link org.apache.hadoop.hbase.client.coprocessor.Batch.Callback#update(byte[],byte[],Object)}
639    * method will be called with the return value from each region's invocation.
640    * </p>
641    * 
642    * @param methodDescriptor
643    *          the descriptor for the protobuf service method to call.
644    * @param request
645    *          the method call parameters
646    * @param startKey
647    *          start region selection with region containing this row. If {@code null}, the
648    *          selection will start with the first table region.
649    * @param endKey
650    *          select regions up to and including the region containing this row. If {@code null},
651    *          selection will continue through the last table region.
652    * @param responsePrototype
653    *          the proto type of the response of the method in Service.
654    * @param callback
655    *          callback to invoke with the response for each region
656    * @param <R>
657    *          the response type for the coprocessor Service method
658    * @throws ServiceException
659    * @throws Throwable
660    */
661   @InterfaceAudience.Private
662   <R extends Message> void batchCoprocessorService(Descriptors.MethodDescriptor methodDescriptor,
663       Message request, byte[] startKey, byte[] endKey, R responsePrototype,
664       Batch.Callback<R> callback) throws ServiceException, Throwable;
665 }