001/**
002 *
003 * Licensed to the Apache Software Foundation (ASF) under one
004 * or more contributor license agreements.  See the NOTICE file
005 * distributed with this work for additional information
006 * regarding copyright ownership.  The ASF licenses this file
007 * to you under the Apache License, Version 2.0 (the
008 * "License"); you may not use this file except in compliance
009 * with the License.  You may obtain a copy of the License at
010 *
011 *     http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 */
019package org.apache.hadoop.hbase.client;
020
021import java.io.Closeable;
022import java.io.IOException;
023import java.util.List;
024import java.util.Map;
025import java.util.concurrent.TimeUnit;
026
027import org.apache.hadoop.conf.Configuration;
028import org.apache.hadoop.hbase.CompareOperator;
029import org.apache.hadoop.hbase.HTableDescriptor;
030import org.apache.hadoop.hbase.TableName;
031import org.apache.yetus.audience.InterfaceAudience;
032import org.apache.hadoop.hbase.client.coprocessor.Batch;
033import org.apache.hadoop.hbase.filter.CompareFilter;
034import org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel;
035
036import com.google.protobuf.Descriptors;
037import com.google.protobuf.Message;
038import com.google.protobuf.Service;
039import com.google.protobuf.ServiceException;
040
041/**
042 * Used to communicate with a single HBase table.
043 * Obtain an instance from a {@link Connection} and call {@link #close()} afterwards.
044 *
045 * <p>Table can be used to get, put, delete or scan data from a table.
046 * @see ConnectionFactory
047 * @see Connection
048 * @see Admin
049 * @see RegionLocator
050 * @since 0.99.0
051 */
052@InterfaceAudience.Public
053public interface Table extends Closeable {
054  /**
055   * Gets the fully qualified table name instance of this table.
056   */
057  TableName getName();
058
059  /**
060   * Returns the {@link org.apache.hadoop.conf.Configuration} object used by this instance.
061   * <p>
062   * The reference returned is not a copy, so any change made to it will
063   * affect this instance.
064   */
065  Configuration getConfiguration();
066
067  /**
068   * Gets the {@link org.apache.hadoop.hbase.HTableDescriptor table descriptor} for this table.
069   * @throws java.io.IOException if a remote or network exception occurs.
070   * @deprecated since 2.0 version and will be removed in 3.0 version.
071   *             use {@link #getDescriptor()}
072   */
073  @Deprecated
074  HTableDescriptor getTableDescriptor() throws IOException;
075
076  /**
077   * Gets the {@link org.apache.hadoop.hbase.client.TableDescriptor table descriptor} for this table.
078   * @throws java.io.IOException if a remote or network exception occurs.
079   */
080  TableDescriptor getDescriptor() throws IOException;
081
082  /**
083   * Test for the existence of columns in the table, as specified by the Get.
084   * <p>
085   *
086   * This will return true if the Get matches one or more keys, false if not.
087   * <p>
088   *
089   * This is a server-side call so it prevents any data from being transfered to
090   * the client.
091   *
092   * @param get the Get
093   * @return true if the specified Get matches one or more keys, false if not
094   * @throws IOException e
095   */
096  boolean exists(Get get) throws IOException;
097
098  /**
099   * Test for the existence of columns in the table, as specified by the Gets.
100   * <p>
101   *
102   * This will return an array of booleans. Each value will be true if the related Get matches
103   * one or more keys, false if not.
104   * <p>
105   *
106   * This is a server-side call so it prevents any data from being transferred to
107   * the client.
108   *
109   * @param gets the Gets
110   * @return Array of boolean.  True if the specified Get matches one or more keys, false if not.
111   * @throws IOException e
112   */
113  boolean[] exists(List<Get> gets) throws IOException;
114
115  /**
116   * Test for the existence of columns in the table, as specified by the Gets.
117   * This will return an array of booleans. Each value will be true if the related Get matches
118   * one or more keys, false if not.
119   * This is a server-side call so it prevents any data from being transferred to
120   * the client.
121   *
122   * @param gets the Gets
123   * @return Array of boolean.  True if the specified Get matches one or more keys, false if not.
124   * @throws IOException e
125   * @deprecated since 2.0 version and will be removed in 3.0 version.
126   *             use {@link #exists(List)}
127   */
128  @Deprecated
129  default boolean[] existsAll(List<Get> gets) throws IOException {
130    return exists(gets);
131  }
132
133  /**
134   * Method that does a batch call on Deletes, Gets, Puts, Increments, Appends, RowMutations.
135   * The ordering of execution of the actions is not defined. Meaning if you do a Put and a
136   * Get in the same {@link #batch} call, you will not necessarily be
137   * guaranteed that the Get returns what the Put had put.
138   *
139   * @param actions list of Get, Put, Delete, Increment, Append, RowMutations.
140   * @param results Empty Object[], same size as actions. Provides access to partial
141   *                results, in case an exception is thrown. A null in the result array means that
142   *                the call for that action failed, even after retries. The order of the objects
143   *                in the results array corresponds to the order of actions in the request list.
144   * @throws IOException
145   * @since 0.90.0
146   */
147  void batch(final List<? extends Row> actions, final Object[] results) throws IOException,
148    InterruptedException;
149
150  /**
151   * Same as {@link #batch(List, Object[])}, but with a callback.
152   * @since 0.96.0
153   */
154  <R> void batchCallback(
155    final List<? extends Row> actions, final Object[] results, final Batch.Callback<R> callback
156  ) throws IOException, InterruptedException;
157
158  /**
159   * Extracts certain cells from a given row.
160   * @param get The object that specifies what data to fetch and from which row.
161   * @return The data coming from the specified row, if it exists.  If the row
162   * specified doesn't exist, the {@link Result} instance returned won't
163   * contain any {@link org.apache.hadoop.hbase.KeyValue}, as indicated by {@link Result#isEmpty()}.
164   * @throws IOException if a remote or network exception occurs.
165   * @since 0.20.0
166   */
167  Result get(Get get) throws IOException;
168
169  /**
170   * Extracts specified cells from the given rows, as a batch.
171   *
172   * @param gets The objects that specify what data to fetch and from which rows.
173   * @return The data coming from the specified rows, if it exists.  If the row specified doesn't
174   * exist, the {@link Result} instance returned won't contain any {@link
175   * org.apache.hadoop.hbase.Cell}s, as indicated by {@link Result#isEmpty()}. If there are any
176   * failures even after retries, there will be a <code>null</code> in the results' array for those
177   * Gets, AND an exception will be thrown. The ordering of the Result array corresponds to the order
178   * of the list of passed in Gets.
179   * @throws IOException if a remote or network exception occurs.
180   * @since 0.90.0
181   * @apiNote {@link #put(List)} runs pre-flight validations on the input list on client.
182   * Currently {@link #get(List)} doesn't run any validations on the client-side, currently there
183   * is no need, but this may change in the future. An
184   * {@link IllegalArgumentException} will be thrown in this case.
185   */
186  Result[] get(List<Get> gets) throws IOException;
187
188  /**
189   * Returns a scanner on the current table as specified by the {@link Scan}
190   * object.
191   * Note that the passed {@link Scan}'s start row and caching properties
192   * maybe changed.
193   *
194   * @param scan A configured {@link Scan} object.
195   * @return A scanner.
196   * @throws IOException if a remote or network exception occurs.
197   * @since 0.20.0
198   */
199  ResultScanner getScanner(Scan scan) throws IOException;
200
201  /**
202   * Gets a scanner on the current table for the given family.
203   *
204   * @param family The column family to scan.
205   * @return A scanner.
206   * @throws IOException if a remote or network exception occurs.
207   * @since 0.20.0
208   */
209  ResultScanner getScanner(byte[] family) throws IOException;
210
211  /**
212   * Gets a scanner on the current table for the given family and qualifier.
213   *
214   * @param family The column family to scan.
215   * @param qualifier The column qualifier to scan.
216   * @return A scanner.
217   * @throws IOException if a remote or network exception occurs.
218   * @since 0.20.0
219   */
220  ResultScanner getScanner(byte[] family, byte[] qualifier) throws IOException;
221
222
223  /**
224   * Puts some data in the table.
225   *
226   * @param put The data to put.
227   * @throws IOException if a remote or network exception occurs.
228   * @since 0.20.0
229   */
230  void put(Put put) throws IOException;
231
232  /**
233   * Batch puts the specified data into the table.
234   * <p>
235   * This can be used for group commit, or for submitting user defined batches. Before sending
236   * a batch of mutations to the server, the client runs a few validations on the input list. If an
237   * error is found, for example, a mutation was supplied but was missing it's column an
238   * {@link IllegalArgumentException} will be thrown and no mutations will be applied. If there
239   * are any failures even after retries, a {@link RetriesExhaustedWithDetailsException} will be
240   * thrown. RetriesExhaustedWithDetailsException contains lists of failed mutations and
241   * corresponding remote exceptions. The ordering of mutations and exceptions in the
242   * encapsulating exception corresponds to the order of the input list of Put requests.
243   *
244   * @param puts The list of mutations to apply.
245   * @throws IOException if a remote or network exception occurs.
246   * @since 0.20.0
247   */
248  void put(List<Put> puts) throws IOException;
249
250  /**
251   * Atomically checks if a row/family/qualifier value matches the expected
252   * value. If it does, it adds the put.  If the passed value is null, the check
253   * is for the lack of column (ie: non-existance)
254   *
255   * @param row to check
256   * @param family column family to check
257   * @param qualifier column qualifier to check
258   * @param value the expected value
259   * @param put data to put if check succeeds
260   * @throws IOException e
261   * @return true if the new put was executed, false otherwise
262   */
263  boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier,
264    byte[] value, Put put) throws IOException;
265
266  /**
267   * Atomically checks if a row/family/qualifier value matches the expected
268   * value. If it does, it adds the put.  If the passed value is null, the check
269   * is for the lack of column (ie: non-existence)
270   *
271   * The expected value argument of this call is on the left and the current
272   * value of the cell is on the right side of the comparison operator.
273   *
274   * Ie. eg. GREATER operator means expected value > existing <=> add the put.
275   *
276   * @param row to check
277   * @param family column family to check
278   * @param qualifier column qualifier to check
279   * @param compareOp comparison operator to use
280   * @param value the expected value
281   * @param put data to put if check succeeds
282   * @throws IOException e
283   * @return true if the new put was executed, false otherwise
284   * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use
285   *  {@link #checkAndPut(byte[], byte[], byte[], CompareOperator, byte[], Put)}}
286   */
287  @Deprecated
288  boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier,
289    CompareFilter.CompareOp compareOp, byte[] value, Put put) throws IOException;
290
291  /**
292   * Atomically checks if a row/family/qualifier value matches the expected
293   * value. If it does, it adds the put.  If the passed value is null, the check
294   * is for the lack of column (ie: non-existence)
295   *
296   * The expected value argument of this call is on the left and the current
297   * value of the cell is on the right side of the comparison operator.
298   *
299   * Ie. eg. GREATER operator means expected value > existing <=> add the put.
300   *
301   * @param row to check
302   * @param family column family to check
303   * @param qualifier column qualifier to check
304   * @param op comparison operator to use
305   * @param value the expected value
306   * @param put data to put if check succeeds
307   * @throws IOException e
308   * @return true if the new put was executed, false otherwise
309   */
310  boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier,
311                      CompareOperator op, byte[] value, Put put) throws IOException;
312
313  /**
314   * Deletes the specified cells/row.
315   *
316   * @param delete The object that specifies what to delete.
317   * @throws IOException if a remote or network exception occurs.
318   * @since 0.20.0
319   */
320  void delete(Delete delete) throws IOException;
321
322  /**
323   * Batch Deletes the specified cells/rows from the table.
324   * <p>
325   * If a specified row does not exist, {@link Delete} will report as though sucessful
326   * delete; no exception will be thrown. If there are any failures even after retries,
327   * a * {@link RetriesExhaustedWithDetailsException} will be thrown.
328   * RetriesExhaustedWithDetailsException contains lists of failed {@link Delete}s and
329   * corresponding remote exceptions.
330   *
331   * @param deletes List of things to delete. The input list gets modified by this
332   * method. All successfully applied {@link Delete}s in the list are removed (in particular it
333   * gets re-ordered, so the order in which the elements are inserted in the list gives no
334   * guarantee as to the order in which the {@link Delete}s are executed).
335   * @throws IOException if a remote or network exception occurs. In that case
336   * the {@code deletes} argument will contain the {@link Delete} instances
337   * that have not be successfully applied.
338   * @since 0.20.1
339   * @apiNote In 3.0.0 version, the input list {@code deletes} will no longer be modified. Also,
340   * {@link #put(List)} runs pre-flight validations on the input list on client. Currently
341   * {@link #delete(List)} doesn't run validations on the client, there is no need currently,
342   * but this may change in the future. An * {@link IllegalArgumentException} will be thrown
343   * in this case.
344   */
345  void delete(List<Delete> deletes) throws IOException;
346
347  /**
348   * Atomically checks if a row/family/qualifier value matches the expected
349   * value. If it does, it adds the delete.  If the passed value is null, the
350   * check is for the lack of column (ie: non-existance)
351   *
352   * @param row to check
353   * @param family column family to check
354   * @param qualifier column qualifier to check
355   * @param value the expected value
356   * @param delete data to delete if check succeeds
357   * @throws IOException e
358   * @return true if the new delete was executed, false otherwise
359   */
360  boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier,
361    byte[] value, Delete delete) throws IOException;
362
363  /**
364   * Atomically checks if a row/family/qualifier value matches the expected
365   * value. If it does, it adds the delete.  If the passed value is null, the
366   * check is for the lack of column (ie: non-existence)
367   *
368   * The expected value argument of this call is on the left and the current
369   * value of the cell is on the right side of the comparison operator.
370   *
371   * Ie. eg. GREATER operator means expected value > existing <=> add the delete.
372   *
373   * @param row to check
374   * @param family column family to check
375   * @param qualifier column qualifier to check
376   * @param compareOp comparison operator to use
377   * @param value the expected value
378   * @param delete data to delete if check succeeds
379   * @throws IOException e
380   * @return true if the new delete was executed, false otherwise
381   * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use
382   *  {@link #checkAndDelete(byte[], byte[], byte[], byte[], Delete)}
383   */
384  @Deprecated
385  boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier,
386    CompareFilter.CompareOp compareOp, byte[] value, Delete delete) throws IOException;
387
388  /**
389   * Atomically checks if a row/family/qualifier value matches the expected
390   * value. If it does, it adds the delete.  If the passed value is null, the
391   * check is for the lack of column (ie: non-existence)
392   *
393   * The expected value argument of this call is on the left and the current
394   * value of the cell is on the right side of the comparison operator.
395   *
396   * Ie. eg. GREATER operator means expected value > existing <=> add the delete.
397   *
398   * @param row to check
399   * @param family column family to check
400   * @param qualifier column qualifier to check
401   * @param op comparison operator to use
402   * @param value the expected value
403   * @param delete data to delete if check succeeds
404   * @throws IOException e
405   * @return true if the new delete was executed, false otherwise
406   */
407  boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier,
408                         CompareOperator op, byte[] value, Delete delete) throws IOException;
409
410  /**
411   * Performs multiple mutations atomically on a single row. Currently
412   * {@link Put} and {@link Delete} are supported.
413   *
414   * @param rm object that specifies the set of mutations to perform atomically
415   * @throws IOException
416   */
417  void mutateRow(final RowMutations rm) throws IOException;
418
419  /**
420   * Appends values to one or more columns within a single row.
421   * <p>
422   * This operation guaranteed atomicity to readers. Appends are done
423   * under a single row lock, so write operations to a row are synchronized, and
424   * readers are guaranteed to see this operation fully completed.
425   *
426   * @param append object that specifies the columns and amounts to be used
427   *                  for the increment operations
428   * @throws IOException e
429   * @return values of columns after the append operation (maybe null)
430   */
431  Result append(final Append append) throws IOException;
432
433  /**
434   * Increments one or more columns within a single row.
435   * <p>
436   * This operation ensures atomicity to readers. Increments are done
437   * under a single row lock, so write operations to a row are synchronized, and
438   * readers are guaranteed to see this operation fully completed.
439   *
440   * @param increment object that specifies the columns and amounts to be used
441   *                  for the increment operations
442   * @throws IOException e
443   * @return values of columns after the increment
444   */
445  Result increment(final Increment increment) throws IOException;
446
447  /**
448   * See {@link #incrementColumnValue(byte[], byte[], byte[], long, Durability)}
449   * <p>
450   * The {@link Durability} is defaulted to {@link Durability#SYNC_WAL}.
451   * @param row The row that contains the cell to increment.
452   * @param family The column family of the cell to increment.
453   * @param qualifier The column qualifier of the cell to increment.
454   * @param amount The amount to increment the cell with (or decrement, if the
455   * amount is negative).
456   * @return The new value, post increment.
457   * @throws IOException if a remote or network exception occurs.
458   */
459  long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier,
460    long amount) throws IOException;
461
462  /**
463   * Atomically increments a column value. If the column value already exists
464   * and is not a big-endian long, this could throw an exception. If the column
465   * value does not yet exist it is initialized to <code>amount</code> and
466   * written to the specified column.
467   *
468   * <p>Setting durability to {@link Durability#SKIP_WAL} means that in a fail
469   * scenario you will lose any increments that have not been flushed.
470   * @param row The row that contains the cell to increment.
471   * @param family The column family of the cell to increment.
472   * @param qualifier The column qualifier of the cell to increment.
473   * @param amount The amount to increment the cell with (or decrement, if the
474   * amount is negative).
475   * @param durability The persistence guarantee for this increment.
476   * @return The new value, post increment.
477   * @throws IOException if a remote or network exception occurs.
478   */
479  long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier,
480    long amount, Durability durability) throws IOException;
481
482  /**
483   * Releases any resources held or pending changes in internal buffers.
484   *
485   * @throws IOException if a remote or network exception occurs.
486   */
487  @Override
488  void close() throws IOException;
489
490  /**
491   * Creates and returns a {@link com.google.protobuf.RpcChannel} instance connected to the
492   * table region containing the specified row.  The row given does not actually have
493   * to exist.  Whichever region would contain the row based on start and end keys will
494   * be used.  Note that the {@code row} parameter is also not passed to the
495   * coprocessor handler registered for this protocol, unless the {@code row}
496   * is separately passed as an argument in the service request.  The parameter
497   * here is only used to locate the region used to handle the call.
498   *
499   * <p>
500   * The obtained {@link com.google.protobuf.RpcChannel} instance can be used to access a published
501   * coprocessor {@link com.google.protobuf.Service} using standard protobuf service invocations:
502   * </p>
503   *
504   * <div style="background-color: #cccccc; padding: 2px">
505   * <blockquote><pre>
506   * CoprocessorRpcChannel channel = myTable.coprocessorService(rowkey);
507   * MyService.BlockingInterface service = MyService.newBlockingStub(channel);
508   * MyCallRequest request = MyCallRequest.newBuilder()
509   *     ...
510   *     .build();
511   * MyCallResponse response = service.myCall(null, request);
512   * </pre></blockquote></div>
513   *
514   * @param row The row key used to identify the remote region location
515   * @return A CoprocessorRpcChannel instance
516   */
517  CoprocessorRpcChannel coprocessorService(byte[] row);
518
519  /**
520   * Creates an instance of the given {@link com.google.protobuf.Service} subclass for each table
521   * region spanning the range from the {@code startKey} row to {@code endKey} row (inclusive), and
522   * invokes the passed {@link org.apache.hadoop.hbase.client.coprocessor.Batch.Call#call} method
523   * with each {@link com.google.protobuf.Service} instance.
524   *
525   * @param service the protocol buffer {@code Service} implementation to call
526   * @param startKey start region selection with region containing this row.  If {@code null}, the
527   * selection will start with the first table region.
528   * @param endKey select regions up to and including the region containing this row. If {@code
529   * null}, selection will continue through the last table region.
530   * @param callable this instance's {@link org.apache.hadoop.hbase.client.coprocessor.Batch
531   * .Call#call}
532   * method will be invoked once per table region, using the {@link com.google.protobuf.Service}
533   * instance connected to that region.
534   * @param <T> the {@link com.google.protobuf.Service} subclass to connect to
535   * @param <R> Return type for the {@code callable} parameter's {@link
536   * org.apache.hadoop.hbase.client.coprocessor.Batch.Call#call} method
537   * @return a map of result values keyed by region name
538   */
539  <T extends Service, R> Map<byte[],R> coprocessorService(final Class<T> service,
540    byte[] startKey, byte[] endKey, final Batch.Call<T,R> callable)
541    throws ServiceException, Throwable;
542
543  /**
544   * Creates an instance of the given {@link com.google.protobuf.Service} subclass for each table
545   * region spanning the range from the {@code startKey} row to {@code endKey} row (inclusive), and
546   * invokes the passed {@link org.apache.hadoop.hbase.client.coprocessor.Batch.Call#call} method
547   * with each {@link Service} instance.
548   *
549   * <p> The given {@link org.apache.hadoop.hbase.client.coprocessor.Batch.Callback#update(byte[],
550   * byte[], Object)} method will be called with the return value from each region's {@link
551   * org.apache.hadoop.hbase.client.coprocessor.Batch.Call#call} invocation. </p>
552   *
553   * @param service the protocol buffer {@code Service} implementation to call
554   * @param startKey start region selection with region containing this row.  If {@code null}, the
555   * selection will start with the first table region.
556   * @param endKey select regions up to and including the region containing this row. If {@code
557   * null}, selection will continue through the last table region.
558   * @param callable this instance's {@link org.apache.hadoop.hbase.client.coprocessor.Batch
559   * .Call#call}
560   * method will be invoked once per table region, using the {@link Service} instance connected to
561   * that region.
562   * @param callback
563   * @param <T> the {@link Service} subclass to connect to
564   * @param <R> Return type for the {@code callable} parameter's {@link
565   * org.apache.hadoop.hbase.client.coprocessor.Batch.Call#call} method
566   */
567  <T extends Service, R> void coprocessorService(final Class<T> service,
568    byte[] startKey, byte[] endKey, final Batch.Call<T,R> callable,
569    final Batch.Callback<R> callback) throws ServiceException, Throwable;
570
571  /**
572   * Creates an instance of the given {@link com.google.protobuf.Service} subclass for each table
573   * region spanning the range from the {@code startKey} row to {@code endKey} row (inclusive), all
574   * the invocations to the same region server will be batched into one call. The coprocessor
575   * service is invoked according to the service instance, method name and parameters.
576   *
577   * @param methodDescriptor
578   *          the descriptor for the protobuf service method to call.
579   * @param request
580   *          the method call parameters
581   * @param startKey
582   *          start region selection with region containing this row. If {@code null}, the
583   *          selection will start with the first table region.
584   * @param endKey
585   *          select regions up to and including the region containing this row. If {@code null},
586   *          selection will continue through the last table region.
587   * @param responsePrototype
588   *          the proto type of the response of the method in Service.
589   * @param <R>
590   *          the response type for the coprocessor Service method
591   * @throws ServiceException
592   * @throws Throwable
593   * @return a map of result values keyed by region name
594   */
595  <R extends Message> Map<byte[], R> batchCoprocessorService(
596    Descriptors.MethodDescriptor methodDescriptor, Message request,
597    byte[] startKey, byte[] endKey, R responsePrototype) throws ServiceException, Throwable;
598
599  /**
600   * Creates an instance of the given {@link com.google.protobuf.Service} subclass for each table
601   * region spanning the range from the {@code startKey} row to {@code endKey} row (inclusive), all
602   * the invocations to the same region server will be batched into one call. The coprocessor
603   * service is invoked according to the service instance, method name and parameters.
604   *
605   * <p>
606   * The given
607   * {@link org.apache.hadoop.hbase.client.coprocessor.Batch.Callback#update(byte[],byte[],Object)}
608   * method will be called with the return value from each region's invocation.
609   * </p>
610   *
611   * @param methodDescriptor
612   *          the descriptor for the protobuf service method to call.
613   * @param request
614   *          the method call parameters
615   * @param startKey
616   *          start region selection with region containing this row. If {@code null}, the
617   *          selection will start with the first table region.
618   * @param endKey
619   *          select regions up to and including the region containing this row. If {@code null},
620   *          selection will continue through the last table region.
621   * @param responsePrototype
622   *          the proto type of the response of the method in Service.
623   * @param callback
624   *          callback to invoke with the response for each region
625   * @param <R>
626   *          the response type for the coprocessor Service method
627   * @throws ServiceException
628   * @throws Throwable
629   */
630  <R extends Message> void batchCoprocessorService(Descriptors.MethodDescriptor methodDescriptor,
631    Message request, byte[] startKey, byte[] endKey, R responsePrototype,
632    Batch.Callback<R> callback) throws ServiceException, Throwable;
633
634  /**
635   * Atomically checks if a row/family/qualifier value matches the expected value.
636   * If it does, it performs the row mutations.  If the passed value is null, the check
637   * is for the lack of column (ie: non-existence)
638   *
639   * The expected value argument of this call is on the left and the current
640   * value of the cell is on the right side of the comparison operator.
641   *
642   * Ie. eg. GREATER operator means expected value > existing <=> perform row mutations.
643   *
644   * @param row to check
645   * @param family column family to check
646   * @param qualifier column qualifier to check
647   * @param compareOp the comparison operator
648   * @param value the expected value
649   * @param mutation  mutations to perform if check succeeds
650   * @throws IOException e
651   * @return true if the new put was executed, false otherwise
652   * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use
653   * {@link #checkAndMutate(byte[], byte[], byte[], CompareOperator, byte[], RowMutations)}
654   */
655  @Deprecated
656  boolean checkAndMutate(byte[] row, byte[] family, byte[] qualifier,
657      CompareFilter.CompareOp compareOp, byte[] value, RowMutations mutation) throws IOException;
658
659  /**
660   * Atomically checks if a row/family/qualifier value matches the expected value.
661   * If it does, it performs the row mutations.  If the passed value is null, the check
662   * is for the lack of column (ie: non-existence)
663   *
664   * The expected value argument of this call is on the left and the current
665   * value of the cell is on the right side of the comparison operator.
666   *
667   * Ie. eg. GREATER operator means expected value > existing <=> perform row mutations.
668   *
669   * @param row to check
670   * @param family column family to check
671   * @param qualifier column qualifier to check
672   * @param op the comparison operator
673   * @param value the expected value
674   * @param mutation  mutations to perform if check succeeds
675   * @throws IOException e
676   * @return true if the new put was executed, false otherwise
677   */
678  boolean checkAndMutate(byte[] row, byte[] family, byte[] qualifier, CompareOperator op,
679                         byte[] value, RowMutations mutation) throws IOException;
680
681  /**
682   * Get timeout of each rpc request in this Table instance. It will be overridden by a more
683   * specific rpc timeout config such as readRpcTimeout or writeRpcTimeout.
684   * @see #getReadRpcTimeout(TimeUnit)
685   * @see #getWriteRpcTimeout(TimeUnit)
686   * @param unit the unit of time the timeout to be represented in
687   * @return rpc timeout in the specified time unit
688   */
689  long getRpcTimeout(TimeUnit unit);
690
691  /**
692   * Get timeout (millisecond) of each rpc request in this Table instance.
693   *
694   * @return Currently configured read timeout
695   * @deprecated use {@link #getReadRpcTimeout(TimeUnit)} or
696   *             {@link #getWriteRpcTimeout(TimeUnit)} instead
697   */
698  @Deprecated
699  int getRpcTimeout();
700
701  /**
702   * Set timeout (millisecond) of each rpc request in operations of this Table instance, will
703   * override the value of hbase.rpc.timeout in configuration.
704   * If a rpc request waiting too long, it will stop waiting and send a new request to retry until
705   * retries exhausted or operation timeout reached.
706   * <p>
707   * NOTE: This will set both the read and write timeout settings to the provided value.
708   *
709   * @param rpcTimeout the timeout of each rpc request in millisecond.
710   *
711   * @deprecated Use setReadRpcTimeout or setWriteRpcTimeout instead
712   */
713  @Deprecated
714  void setRpcTimeout(int rpcTimeout);
715
716  /**
717   * Get timeout of each rpc read request in this Table instance.
718   * @param unit the unit of time the timeout to be represented in
719   * @return read rpc timeout in the specified time unit
720   */
721  long getReadRpcTimeout(TimeUnit unit);
722
723  /**
724   * Get timeout (millisecond) of each rpc read request in this Table instance.
725   * @deprecated since 2.0 and will be removed in 3.0 version
726   *             use {@link #getReadRpcTimeout(TimeUnit)} instead
727   */
728  @Deprecated
729  int getReadRpcTimeout();
730
731  /**
732   * Set timeout (millisecond) of each rpc read request in operations of this Table instance, will
733   * override the value of hbase.rpc.read.timeout in configuration.
734   * If a rpc read request waiting too long, it will stop waiting and send a new request to retry
735   * until retries exhausted or operation timeout reached.
736   *
737   * @param readRpcTimeout the timeout for read rpc request in milliseconds
738   * @deprecated since 2.0.0, use {@link TableBuilder#setReadRpcTimeout} instead
739   */
740  @Deprecated
741  void setReadRpcTimeout(int readRpcTimeout);
742
743  /**
744   * Get timeout of each rpc write request in this Table instance.
745   * @param unit the unit of time the timeout to be represented in
746   * @return write rpc timeout in the specified time unit
747   */
748  long getWriteRpcTimeout(TimeUnit unit);
749
750  /**
751   * Get timeout (millisecond) of each rpc write request in this Table instance.
752   * @deprecated since 2.0 and will be removed in 3.0 version
753   *             use {@link #getWriteRpcTimeout(TimeUnit)} instead
754   */
755  @Deprecated
756  int getWriteRpcTimeout();
757
758  /**
759   * Set timeout (millisecond) of each rpc write request in operations of this Table instance, will
760   * override the value of hbase.rpc.write.timeout in configuration.
761   * If a rpc write request waiting too long, it will stop waiting and send a new request to retry
762   * until retries exhausted or operation timeout reached.
763   *
764   * @param writeRpcTimeout the timeout for write rpc request in milliseconds
765   * @deprecated since 2.0.0, use {@link TableBuilder#setWriteRpcTimeout} instead
766   */
767  @Deprecated
768  void setWriteRpcTimeout(int writeRpcTimeout);
769
770  /**
771   * Get timeout of each operation in Table instance.
772   * @param unit the unit of time the timeout to be represented in
773   * @return operation rpc timeout in the specified time unit
774   */
775  long getOperationTimeout(TimeUnit unit);
776
777  /**
778   * Get timeout (millisecond) of each operation for in Table instance.
779   * @deprecated since 2.0 and will be removed in 3.0 version
780   *             use {@link #getOperationTimeout(TimeUnit)} instead
781   */
782  @Deprecated
783  int getOperationTimeout();
784
785  /**
786   * Set timeout (millisecond) of each operation in this Table instance, will override the value
787   * of hbase.client.operation.timeout in configuration.
788   * Operation timeout is a top-level restriction that makes sure a blocking method will not be
789   * blocked more than this. In each operation, if rpc request fails because of timeout or
790   * other reason, it will retry until success or throw a RetriesExhaustedException. But if the
791   * total time being blocking reach the operation timeout before retries exhausted, it will break
792   * early and throw SocketTimeoutException.
793   * @param operationTimeout the total timeout of each operation in millisecond.
794   * @deprecated since 2.0.0, use {@link TableBuilder#setOperationTimeout} instead
795   */
796  @Deprecated
797  void setOperationTimeout(int operationTimeout);
798}