diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Table.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Table.java index fab439cdb6..d48428d3ee 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Table.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Table.java @@ -24,6 +24,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; +import org.apache.commons.lang3.NotImplementedException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.CompareOperator; import org.apache.hadoop.hbase.HTableDescriptor; @@ -94,7 +95,9 @@ public interface Table extends Closeable { * @return true if the specified Get matches one or more keys, false if not * @throws IOException e */ - boolean exists(Get get) throws IOException; + default boolean exists(Get get) throws IOException { + throw new NotImplementedException("Add an implementation!"); + } /** * Test for the existence of columns in the table, as specified by the Gets. @@ -111,7 +114,9 @@ public interface Table extends Closeable { * @return Array of boolean. True if the specified Get matches one or more keys, false if not. * @throws IOException e */ - boolean[] exists(List gets) throws IOException; + default boolean[] exists(List gets) throws IOException { + throw new NotImplementedException("Add an implementation!"); + } /** * Test for the existence of columns in the table, as specified by the Gets. @@ -145,16 +150,20 @@ public interface Table extends Closeable { * @throws IOException * @since 0.90.0 */ - void batch(final List actions, final Object[] results) throws IOException, - InterruptedException; + default void batch(final List actions, final Object[] results) throws IOException, + InterruptedException { + throw new NotImplementedException("Add an implementation!"); + } /** * Same as {@link #batch(List, Object[])}, but with a callback. * @since 0.96.0 */ - void batchCallback( - final List actions, final Object[] results, final Batch.Callback callback - ) throws IOException, InterruptedException; + default void batchCallback( + final List actions, final Object[] results, final Batch.Callback callback) + throws IOException, InterruptedException { + throw new NotImplementedException("Add an implementation!"); + } /** * Extracts certain cells from a given row. @@ -165,7 +174,9 @@ public interface Table extends Closeable { * @throws IOException if a remote or network exception occurs. * @since 0.20.0 */ - Result get(Get get) throws IOException; + default Result get(Get get) throws IOException { + throw new NotImplementedException("Add an implementation!"); + } /** * Extracts specified cells from the given rows, as a batch. @@ -184,7 +195,9 @@ public interface Table extends Closeable { * is no need, but this may change in the future. An * {@link IllegalArgumentException} will be thrown in this case. */ - Result[] get(List gets) throws IOException; + default Result[] get(List gets) throws IOException { + throw new NotImplementedException("Add an implementation!"); + } /** * Returns a scanner on the current table as specified by the {@link Scan} @@ -197,7 +210,9 @@ public interface Table extends Closeable { * @throws IOException if a remote or network exception occurs. * @since 0.20.0 */ - ResultScanner getScanner(Scan scan) throws IOException; + default ResultScanner getScanner(Scan scan) throws IOException { + throw new NotImplementedException("Add an implementation!"); + } /** * Gets a scanner on the current table for the given family. @@ -207,7 +222,9 @@ public interface Table extends Closeable { * @throws IOException if a remote or network exception occurs. * @since 0.20.0 */ - ResultScanner getScanner(byte[] family) throws IOException; + default ResultScanner getScanner(byte[] family) throws IOException { + throw new NotImplementedException("Add an implementation!"); + } /** * Gets a scanner on the current table for the given family and qualifier. @@ -218,7 +235,9 @@ public interface Table extends Closeable { * @throws IOException if a remote or network exception occurs. * @since 0.20.0 */ - ResultScanner getScanner(byte[] family, byte[] qualifier) throws IOException; + default ResultScanner getScanner(byte[] family, byte[] qualifier) throws IOException { + throw new NotImplementedException("Add an implementation!"); + } /** @@ -228,7 +247,9 @@ public interface Table extends Closeable { * @throws IOException if a remote or network exception occurs. * @since 0.20.0 */ - void put(Put put) throws IOException; + default void put(Put put) throws IOException { + throw new NotImplementedException("Add an implementation!"); + } /** * Batch puts the specified data into the table. @@ -246,7 +267,9 @@ public interface Table extends Closeable { * @throws IOException if a remote or network exception occurs. * @since 0.20.0 */ - void put(List puts) throws IOException; + default void put(List puts) throws IOException { + throw new NotImplementedException("Add an implementation!"); + } /** * Atomically checks if a row/family/qualifier value matches the expected @@ -263,8 +286,10 @@ public interface Table extends Closeable { * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #checkAndMutate(byte[], byte[])} */ @Deprecated - boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, - byte[] value, Put put) throws IOException; + default boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, byte[] value, Put put) + throws IOException { + throw new NotImplementedException("Add an implementation!"); + } /** * Atomically checks if a row/family/qualifier value matches the expected @@ -287,8 +312,10 @@ public interface Table extends Closeable { * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #checkAndMutate(byte[], byte[])} */ @Deprecated - boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, - CompareFilter.CompareOp compareOp, byte[] value, Put put) throws IOException; + default boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, + CompareFilter.CompareOp compareOp, byte[] value, Put put) throws IOException { + throw new NotImplementedException("Add an implementation!"); + } /** * Atomically checks if a row/family/qualifier value matches the expected @@ -311,8 +338,10 @@ public interface Table extends Closeable { * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #checkAndMutate(byte[], byte[])} */ @Deprecated - boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, - byte[] value, Put put) throws IOException; + default boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, + byte[] value, Put put) throws IOException { + throw new NotImplementedException("Add an implementation!"); + } /** * Deletes the specified cells/row. @@ -321,7 +350,9 @@ public interface Table extends Closeable { * @throws IOException if a remote or network exception occurs. * @since 0.20.0 */ - void delete(Delete delete) throws IOException; + default void delete(Delete delete) throws IOException { + throw new NotImplementedException("Add an implementation!"); + } /** * Batch Deletes the specified cells/rows from the table. @@ -346,7 +377,9 @@ public interface Table extends Closeable { * but this may change in the future. An * {@link IllegalArgumentException} will be thrown * in this case. */ - void delete(List deletes) throws IOException; + default void delete(List deletes) throws IOException { + throw new NotImplementedException("Add an implementation!"); + } /** * Atomically checks if a row/family/qualifier value matches the expected @@ -363,8 +396,10 @@ public interface Table extends Closeable { * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #checkAndMutate(byte[], byte[])} */ @Deprecated - boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier, - byte[] value, Delete delete) throws IOException; + default boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier, + byte[] value, Delete delete) throws IOException { + throw new NotImplementedException("Add an implementation!"); + } /** * Atomically checks if a row/family/qualifier value matches the expected @@ -387,8 +422,10 @@ public interface Table extends Closeable { * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #checkAndMutate(byte[], byte[])} */ @Deprecated - boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier, - CompareFilter.CompareOp compareOp, byte[] value, Delete delete) throws IOException; + default boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier, + CompareFilter.CompareOp compareOp, byte[] value, Delete delete) throws IOException { + throw new NotImplementedException("Add an implementation!"); + } /** * Atomically checks if a row/family/qualifier value matches the expected @@ -411,8 +448,10 @@ public interface Table extends Closeable { * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #checkAndMutate(byte[], byte[])} */ @Deprecated - boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier, - CompareOperator op, byte[] value, Delete delete) throws IOException; + default boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier, + CompareOperator op, byte[] value, Delete delete) throws IOException { + throw new NotImplementedException("Add an implementation!"); + } /** * Atomically checks if a row/family/qualifier value matches the expected value. If it does, it @@ -427,7 +466,10 @@ public interface Table extends Closeable { * * */ - CheckAndMutateBuilder checkAndMutate(byte[] row, byte[] family); + default CheckAndMutateBuilder checkAndMutate(byte[] row, byte[] family) { + throw new NotImplementedException("Add an implementation!"); + } + /** * A helper class for sending checkAndMutate request. */ @@ -478,7 +520,6 @@ public interface Table extends Closeable { * @return true if the new mutation was executed, false otherwise. */ boolean thenMutate(RowMutations mutation) throws IOException; - } /** @@ -488,7 +529,9 @@ public interface Table extends Closeable { * @param rm object that specifies the set of mutations to perform atomically * @throws IOException */ - void mutateRow(final RowMutations rm) throws IOException; + default void mutateRow(final RowMutations rm) throws IOException { + throw new NotImplementedException("Add an implementation!"); + } /** * Appends values to one or more columns within a single row. @@ -502,7 +545,9 @@ public interface Table extends Closeable { * @throws IOException e * @return values of columns after the append operation (maybe null) */ - Result append(final Append append) throws IOException; + default Result append(final Append append) throws IOException { + throw new NotImplementedException("Add an implementation!"); + } /** * Increments one or more columns within a single row. @@ -516,7 +561,9 @@ public interface Table extends Closeable { * @throws IOException e * @return values of columns after the increment */ - Result increment(final Increment increment) throws IOException; + default Result increment(final Increment increment) throws IOException { + throw new NotImplementedException("Add an implementation!"); + } /** * See {@link #incrementColumnValue(byte[], byte[], byte[], long, Durability)} @@ -530,8 +577,10 @@ public interface Table extends Closeable { * @return The new value, post increment. * @throws IOException if a remote or network exception occurs. */ - long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, - long amount) throws IOException; + default long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount) + throws IOException { + throw new NotImplementedException("Add an implementation!"); + } /** * Atomically increments a column value. If the column value already exists @@ -550,8 +599,10 @@ public interface Table extends Closeable { * @return The new value, post increment. * @throws IOException if a remote or network exception occurs. */ - long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, - long amount, Durability durability) throws IOException; + default long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, + long amount, Durability durability) throws IOException { + throw new NotImplementedException("Add an implementation!"); + } /** * Releases any resources held or pending changes in internal buffers. @@ -559,7 +610,7 @@ public interface Table extends Closeable { * @throws IOException if a remote or network exception occurs. */ @Override - void close() throws IOException; + default void close() throws IOException {} /** * Creates and returns a {@link com.google.protobuf.RpcChannel} instance connected to the @@ -588,7 +639,9 @@ public interface Table extends Closeable { * @param row The row key used to identify the remote region location * @return A CoprocessorRpcChannel instance */ - CoprocessorRpcChannel coprocessorService(byte[] row); + default CoprocessorRpcChannel coprocessorService(byte[] row) { + throw new NotImplementedException("Add an implementation!"); + } /** * Creates an instance of the given {@link com.google.protobuf.Service} subclass for each table @@ -610,9 +663,11 @@ public interface Table extends Closeable { * org.apache.hadoop.hbase.client.coprocessor.Batch.Call#call} method * @return a map of result values keyed by region name */ - Map coprocessorService(final Class service, + default Map coprocessorService(final Class service, byte[] startKey, byte[] endKey, final Batch.Call callable) - throws ServiceException, Throwable; + throws ServiceException, Throwable { + throw new NotImplementedException("Add an implementation!"); + } /** * Creates an instance of the given {@link com.google.protobuf.Service} subclass for each table @@ -638,9 +693,11 @@ public interface Table extends Closeable { * @param Return type for the {@code callable} parameter's {@link * org.apache.hadoop.hbase.client.coprocessor.Batch.Call#call} method */ - void coprocessorService(final Class service, + default void coprocessorService(final Class service, byte[] startKey, byte[] endKey, final Batch.Call callable, - final Batch.Callback callback) throws ServiceException, Throwable; + final Batch.Callback callback) throws ServiceException, Throwable { + throw new NotImplementedException("Add an implementation!"); + } /** * Creates an instance of the given {@link com.google.protobuf.Service} subclass for each table @@ -666,9 +723,11 @@ public interface Table extends Closeable { * @throws Throwable * @return a map of result values keyed by region name */ - Map batchCoprocessorService( + default Map batchCoprocessorService( Descriptors.MethodDescriptor methodDescriptor, Message request, - byte[] startKey, byte[] endKey, R responsePrototype) throws ServiceException, Throwable; + byte[] startKey, byte[] endKey, R responsePrototype) throws ServiceException, Throwable { + throw new NotImplementedException("Add an implementation!"); + } /** * Creates an instance of the given {@link com.google.protobuf.Service} subclass for each table @@ -701,9 +760,12 @@ public interface Table extends Closeable { * @throws ServiceException * @throws Throwable */ - void batchCoprocessorService(Descriptors.MethodDescriptor methodDescriptor, - Message request, byte[] startKey, byte[] endKey, R responsePrototype, - Batch.Callback callback) throws ServiceException, Throwable; + default void batchCoprocessorService( + Descriptors.MethodDescriptor methodDescriptor, Message request, byte[] startKey, + byte[] endKey, R responsePrototype, Batch.Callback callback) + throws ServiceException, Throwable { + throw new NotImplementedException("Add an implementation!"); + } /** * Atomically checks if a row/family/qualifier value matches the expected value. @@ -726,8 +788,10 @@ public interface Table extends Closeable { * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #checkAndMutate(byte[], byte[])} */ @Deprecated - boolean checkAndMutate(byte[] row, byte[] family, byte[] qualifier, - CompareFilter.CompareOp compareOp, byte[] value, RowMutations mutation) throws IOException; + default boolean checkAndMutate(byte[] row, byte[] family, byte[] qualifier, + CompareFilter.CompareOp compareOp, byte[] value, RowMutations mutation) throws IOException { + throw new NotImplementedException("Add an implementation!"); + } /** * Atomically checks if a row/family/qualifier value matches the expected value. @@ -750,8 +814,10 @@ public interface Table extends Closeable { * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #checkAndMutate(byte[], byte[])} */ @Deprecated - boolean checkAndMutate(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, - byte[] value, RowMutations mutation) throws IOException; + default boolean checkAndMutate(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, + byte[] value, RowMutations mutation) throws IOException { + throw new NotImplementedException("Add an implementation!"); + } /** * Get timeout of each rpc request in this Table instance. It will be overridden by a more @@ -761,7 +827,9 @@ public interface Table extends Closeable { * @param unit the unit of time the timeout to be represented in * @return rpc timeout in the specified time unit */ - long getRpcTimeout(TimeUnit unit); + default long getRpcTimeout(TimeUnit unit) { + throw new NotImplementedException("Add an implementation!"); + } /** * Get timeout (millisecond) of each rpc request in this Table instance. @@ -771,7 +839,9 @@ public interface Table extends Closeable { * {@link #getWriteRpcTimeout(TimeUnit)} instead */ @Deprecated - int getRpcTimeout(); + default int getRpcTimeout() { + throw new NotImplementedException("Add an implementation!"); + } /** * Set timeout (millisecond) of each rpc request in operations of this Table instance, will @@ -786,14 +856,18 @@ public interface Table extends Closeable { * @deprecated Use setReadRpcTimeout or setWriteRpcTimeout instead */ @Deprecated - void setRpcTimeout(int rpcTimeout); + default void setRpcTimeout(int rpcTimeout) { + throw new NotImplementedException("Add an implementation!"); + } /** * Get timeout of each rpc read request in this Table instance. * @param unit the unit of time the timeout to be represented in * @return read rpc timeout in the specified time unit */ - long getReadRpcTimeout(TimeUnit unit); + default long getReadRpcTimeout(TimeUnit unit) { + throw new NotImplementedException("Add an implementation!"); + } /** * Get timeout (millisecond) of each rpc read request in this Table instance. @@ -801,7 +875,9 @@ public interface Table extends Closeable { * use {@link #getReadRpcTimeout(TimeUnit)} instead */ @Deprecated - int getReadRpcTimeout(); + default int getReadRpcTimeout() { + throw new NotImplementedException("Add an implementation!"); + } /** * Set timeout (millisecond) of each rpc read request in operations of this Table instance, will @@ -813,14 +889,18 @@ public interface Table extends Closeable { * @deprecated since 2.0.0, use {@link TableBuilder#setReadRpcTimeout} instead */ @Deprecated - void setReadRpcTimeout(int readRpcTimeout); + default void setReadRpcTimeout(int readRpcTimeout) { + throw new NotImplementedException("Add an implementation!"); + } /** * Get timeout of each rpc write request in this Table instance. * @param unit the unit of time the timeout to be represented in * @return write rpc timeout in the specified time unit */ - long getWriteRpcTimeout(TimeUnit unit); + default long getWriteRpcTimeout(TimeUnit unit) { + throw new NotImplementedException("Add an implementation!"); + } /** * Get timeout (millisecond) of each rpc write request in this Table instance. @@ -828,7 +908,9 @@ public interface Table extends Closeable { * use {@link #getWriteRpcTimeout(TimeUnit)} instead */ @Deprecated - int getWriteRpcTimeout(); + default int getWriteRpcTimeout() { + throw new NotImplementedException("Add an implementation!"); + } /** * Set timeout (millisecond) of each rpc write request in operations of this Table instance, will @@ -840,14 +922,18 @@ public interface Table extends Closeable { * @deprecated since 2.0.0, use {@link TableBuilder#setWriteRpcTimeout} instead */ @Deprecated - void setWriteRpcTimeout(int writeRpcTimeout); + default void setWriteRpcTimeout(int writeRpcTimeout) { + throw new NotImplementedException("Add an implementation!"); + } /** * Get timeout of each operation in Table instance. * @param unit the unit of time the timeout to be represented in * @return operation rpc timeout in the specified time unit */ - long getOperationTimeout(TimeUnit unit); + default long getOperationTimeout(TimeUnit unit) { + throw new NotImplementedException("Add an implementation!"); + } /** * Get timeout (millisecond) of each operation for in Table instance. @@ -855,7 +941,9 @@ public interface Table extends Closeable { * use {@link #getOperationTimeout(TimeUnit)} instead */ @Deprecated - int getOperationTimeout(); + default int getOperationTimeout() { + throw new NotImplementedException("Add an implementation!"); + } /** * Set timeout (millisecond) of each operation in this Table instance, will override the value @@ -869,5 +957,7 @@ public interface Table extends Closeable { * @deprecated since 2.0.0, use {@link TableBuilder#setOperationTimeout} instead */ @Deprecated - void setOperationTimeout(int operationTimeout); + default void setOperationTimeout(int operationTimeout) { + throw new NotImplementedException("Add an implementation!"); + } }