@InterfaceAudience.Private class TableOverAsyncTable extends Object implements Table
AsyncTable
.Modifier and Type | Class and Description |
---|---|
private static class |
TableOverAsyncTable.RegionCoprocessorRpcChannel |
private static interface |
TableOverAsyncTable.StubCall<R> |
Table.CheckAndMutateBuilder, Table.CheckAndMutateWithFilterBuilder
Modifier and Type | Field and Description |
---|---|
private AsyncConnectionImpl |
conn |
private static org.slf4j.Logger |
LOG |
private ConcurrentMapUtils.IOExceptionSupplier<ExecutorService> |
poolSupplier |
private AsyncTable<?> |
table |
Constructor and Description |
---|
TableOverAsyncTable(AsyncConnectionImpl conn,
AsyncTable<?> table,
ConcurrentMapUtils.IOExceptionSupplier<ExecutorService> poolSupplier) |
Modifier and Type | Method and Description |
---|---|
Result |
append(Append append)
Appends values to one or more columns within a single row.
|
void |
batch(List<? extends Row> actions,
Object[] results)
Method that does a batch call on Deletes, Gets, Puts, Increments, Appends, RowMutations.
|
<R> void |
batchCallback(List<? extends Row> actions,
Object[] results,
Batch.Callback<R> callback)
Same as
Table.batch(List, Object[]) , but with a callback. |
<R extends org.apache.hbase.thirdparty.com.google.protobuf.Message> |
batchCoprocessorService(org.apache.hbase.thirdparty.com.google.protobuf.Descriptors.MethodDescriptor methodDescriptor,
org.apache.hbase.thirdparty.com.google.protobuf.Message request,
byte[] startKey,
byte[] endKey,
R responsePrototype,
Batch.Callback<R> callback)
Creates an instance of the given
Service subclass for each table region spanning the
range from the startKey row to endKey row (inclusive), all the invocations to
the same region server will be batched into one call. |
Table.CheckAndMutateBuilder |
checkAndMutate(byte[] row,
byte[] family)
Atomically checks if a row/family/qualifier value matches the expected value.
|
Table.CheckAndMutateWithFilterBuilder |
checkAndMutate(byte[] row,
Filter filter)
Atomically checks if a row matches the specified filter.
|
CheckAndMutateResult |
checkAndMutate(CheckAndMutate checkAndMutate)
checkAndMutate that atomically checks if a row matches the specified condition.
|
List<CheckAndMutateResult> |
checkAndMutate(List<CheckAndMutate> checkAndMutates)
Batch version of checkAndMutate.
|
void |
close()
Releases any resources held or pending changes in internal buffers.
|
TableOverAsyncTable.RegionCoprocessorRpcChannel |
coprocessorService(byte[] row)
Creates and returns a
RpcChannel
instance connected to the table region containing the specified row. |
<T extends org.apache.hbase.thirdparty.com.google.protobuf.Service,R> |
coprocessorService(Class<T> service,
byte[] startKey,
byte[] endKey,
Batch.Call<T,R> callable,
Batch.Callback<R> callback)
Creates an instance of the given
Service subclass for each table region spanning the
range from the startKey row to endKey row (inclusive), and invokes the passed
Batch.Call.call(T) method with each
Service instance. |
private <R> void |
coprocessorService(String serviceName,
byte[] startKey,
byte[] endKey,
Batch.Callback<R> callback,
TableOverAsyncTable.StubCall<R> call) |
void |
delete(Delete delete)
Deletes the specified cells/row.
|
void |
delete(List<Delete> deletes)
Batch Deletes the specified cells/rows from the table.
|
boolean |
exists(Get get)
Test for the existence of columns in the table, as specified by the Get.
|
boolean[] |
exists(List<Get> gets)
Test for the existence of columns in the table, as specified by the Gets.
|
Result |
get(Get get)
Extracts certain cells from a given row.
|
Result[] |
get(List<Get> gets)
Extracts specified cells from the given rows, as a batch.
|
org.apache.hadoop.conf.Configuration |
getConfiguration()
Returns the
Configuration object used by this instance. |
TableDescriptor |
getDescriptor()
Gets the
table descriptor for this
table. |
private Pair<List<byte[]>,List<HRegionLocation>> |
getKeysAndRegionsInRange(byte[] startKey,
byte[] endKey,
boolean includeEndKey)
Get the corresponding start keys and regions for an arbitrary range of keys.
|
private Pair<List<byte[]>,List<HRegionLocation>> |
getKeysAndRegionsInRange(byte[] startKey,
byte[] endKey,
boolean includeEndKey,
boolean reload)
Get the corresponding start keys and regions for an arbitrary range of keys.
|
TableName |
getName()
Gets the fully qualified table name instance of this table.
|
long |
getOperationTimeout(TimeUnit unit)
Get timeout of each operation in Table instance.
|
long |
getReadRpcTimeout(TimeUnit unit)
Get timeout of each rpc read request in this Table instance.
|
RegionLocator |
getRegionLocator()
Gets the
RegionLocator for this table. |
Map<String,byte[]> |
getRequestAttributes()
Get the attributes to be submitted with requests
|
long |
getRpcTimeout(TimeUnit unit)
Get timeout of each rpc request in this Table instance.
|
ResultScanner |
getScanner(byte[] family)
Gets a scanner on the current table for the given family.
|
ResultScanner |
getScanner(byte[] family,
byte[] qualifier)
Gets a scanner on the current table for the given family and qualifier.
|
ResultScanner |
getScanner(Scan scan)
Returns a scanner on the current table as specified by the
Scan object. |
private List<byte[]> |
getStartKeysInRange(byte[] start,
byte[] end) |
long |
getWriteRpcTimeout(TimeUnit unit)
Get timeout of each rpc write request in this Table instance.
|
Result |
increment(Increment increment)
Increments one or more columns within a single row.
|
long |
incrementColumnValue(byte[] row,
byte[] family,
byte[] qualifier,
long amount)
|
long |
incrementColumnValue(byte[] row,
byte[] family,
byte[] qualifier,
long amount,
Durability durability)
Atomically increments a column value.
|
Result |
mutateRow(RowMutations rm)
Performs multiple mutations atomically on a single row.
|
void |
put(List<Put> puts)
Batch puts the specified data into the table.
|
void |
put(Put put)
Puts some data in the table.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
batchCoprocessorService, coprocessorService
private static final org.slf4j.Logger LOG
private final AsyncConnectionImpl conn
private final AsyncTable<?> table
private final ConcurrentMapUtils.IOExceptionSupplier<ExecutorService> poolSupplier
TableOverAsyncTable(AsyncConnectionImpl conn, AsyncTable<?> table, ConcurrentMapUtils.IOExceptionSupplier<ExecutorService> poolSupplier)
public TableName getName()
Table
public org.apache.hadoop.conf.Configuration getConfiguration()
Table
Configuration
object used by this instance.
The reference returned is not a copy, so any change made to it will affect this instance.
getConfiguration
in interface Table
public TableDescriptor getDescriptor() throws IOException
Table
table descriptor
for this
table.getDescriptor
in interface Table
IOException
- if a remote or network exception occurs.public boolean exists(Get get) throws IOException
Table
This will return true if the Get matches one or more keys, false if not.
This is a server-side call so it prevents any data from being transfered to the client.
exists
in interface Table
get
- the GetIOException
- epublic boolean[] exists(List<Get> gets) throws IOException
Table
This will return an array of booleans. Each value will be true if the related Get matches one or more keys, false if not.
This is a server-side call so it prevents any data from being transferred to the client.
exists
in interface Table
gets
- the GetsIOException
- epublic void batch(List<? extends Row> actions, Object[] results) throws IOException
Table
Table.batch(java.util.List<? extends org.apache.hadoop.hbase.client.Row>, java.lang.Object[])
call, you will not necessarily be guaranteed that the Get returns what the
Put had put.batch
in interface Table
actions
- list of Get, Put, Delete, Increment, Append, RowMutations.results
- Empty Object[], same size as actions. Provides access to partial results, in
case an exception is thrown. A null in the result array means that the call for
that action failed, even after retries. The order of the objects in the results
array corresponds to the order of actions in the request list.IOException
public <R> void batchCallback(List<? extends Row> actions, Object[] results, Batch.Callback<R> callback) throws IOException, InterruptedException
Table
Table.batch(List, Object[])
, but with a callback.batchCallback
in interface Table
IOException
InterruptedException
public Result get(Get get) throws IOException
Table
get
in interface Table
get
- The object that specifies what data to fetch and from which row.Result
instance returned won't contain any
KeyValue
, as indicated by Result.isEmpty()
.IOException
- if a remote or network exception occurs.public Result[] get(List<Get> gets) throws IOException
Table
get
in interface Table
gets
- The objects that specify what data to fetch and from which rows.Result
instance returned won't contain any
Cell
s, as indicated by Result.isEmpty()
. If
there are any failures even after retries, there will be a null
in the
results' array for those Gets, AND an exception will be thrown. The ordering of the
Result array corresponds to the order of the list of passed in Gets.IOException
- if a remote or network exception occurs.public ResultScanner getScanner(Scan scan) throws IOException
Table
Scan
object. Note that the
passed Scan
's start row and caching properties maybe changed.getScanner
in interface Table
scan
- A configured Scan
object.IOException
- if a remote or network exception occurs.public ResultScanner getScanner(byte[] family) throws IOException
Table
getScanner
in interface Table
family
- The column family to scan.IOException
- if a remote or network exception occurs.public ResultScanner getScanner(byte[] family, byte[] qualifier) throws IOException
Table
getScanner
in interface Table
family
- The column family to scan.qualifier
- The column qualifier to scan.IOException
- if a remote or network exception occurs.public void put(Put put) throws IOException
Table
put
in interface Table
put
- The data to put.IOException
- if a remote or network exception occurs.public void put(List<Put> puts) throws IOException
Table
This can be used for group commit, or for submitting user defined batches. Before sending a
batch of mutations to the server, the client runs a few validations on the input list. If an
error is found, for example, a mutation was supplied but was missing it's column an
IllegalArgumentException
will be thrown and no mutations will be applied. If there are
any failures even after retries, a RetriesExhaustedWithDetailsException
will be thrown.
RetriesExhaustedWithDetailsException contains lists of failed mutations and corresponding
remote exceptions. The ordering of mutations and exceptions in the encapsulating exception
corresponds to the order of the input list of Put requests.
put
in interface Table
puts
- The list of mutations to apply.IOException
- if a remote or network exception occurs.public void delete(Delete delete) throws IOException
Table
delete
in interface Table
delete
- The object that specifies what to delete.IOException
- if a remote or network exception occurs.public void delete(List<Delete> deletes) throws IOException
Table
If a specified row does not exist, Delete
will report as though sucessful delete; no
exception will be thrown. If there are any failures even after retries, a
RetriesExhaustedWithDetailsException
will be thrown.
RetriesExhaustedWithDetailsException contains lists of failed Delete
s and corresponding
remote exceptions.
delete
in interface Table
deletes
- List of things to delete. The input list gets modified by this method. All
successfully applied Delete
s in the list are removed (in particular it
gets re-ordered, so the order in which the elements are inserted in the list
gives no guarantee as to the order in which the Delete
s are executed).IOException
- if a remote or network exception occurs. In that case the deletes
argument will contain the Delete
instances that have not be
successfully applied.public Table.CheckAndMutateBuilder checkAndMutate(byte[] row, byte[] family)
Table
Use the returned Table.CheckAndMutateBuilder
to construct your request and then execute it.
This is a fluent style API, the code is like:
table.checkAndMutate(row, family).qualifier(qualifier).ifNotExists().thenPut(put);
checkAndMutate
in interface Table
public Table.CheckAndMutateWithFilterBuilder checkAndMutate(byte[] row, Filter filter)
Table
Use the returned Table.CheckAndMutateWithFilterBuilder
to construct your request and then
execute it. This is a fluent style API, the code is like:
table.checkAndMutate(row, filter).thenPut(put);
checkAndMutate
in interface Table
public CheckAndMutateResult checkAndMutate(CheckAndMutate checkAndMutate) throws IOException
Table
checkAndMutate
in interface Table
checkAndMutate
- The CheckAndMutate object.IOException
- if a remote or network exception occurs.public List<CheckAndMutateResult> checkAndMutate(List<CheckAndMutate> checkAndMutates) throws IOException
Table
checkAndMutate
in interface Table
checkAndMutates
- The list of CheckAndMutate.IOException
- if a remote or network exception occurs.public Result mutateRow(RowMutations rm) throws IOException
Table
mutateRow
in interface Table
rm
- object that specifies the set of mutations to perform atomicallyIOException
- if a remote or network exception occurs.public Result append(Append append) throws IOException
Table
This operation guaranteed atomicity to readers. Appends are done under a single row lock, so write operations to a row are synchronized, and readers are guaranteed to see this operation fully completed.
append
in interface Table
append
- object that specifies the columns and values to be appendedIOException
- epublic Result increment(Increment increment) throws IOException
Table
This operation ensures atomicity to readers. Increments are done under a single row lock, so write operations to a row are synchronized, and readers are guaranteed to see this operation fully completed.
increment
in interface Table
increment
- object that specifies the columns and amounts to be used for the increment
operationsIOException
- epublic long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount) throws IOException
Table
Table.incrementColumnValue(byte[], byte[], byte[], long, Durability)
The Durability
is defaulted to Durability.SYNC_WAL
.
incrementColumnValue
in interface Table
row
- The row that contains the cell to increment.family
- The column family of the cell to increment.qualifier
- The column qualifier of the cell to increment.amount
- The amount to increment the cell with (or decrement, if the amount is
negative).IOException
- if a remote or network exception occurs.public long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount, Durability durability) throws IOException
Table
amount
and written to the specified column.
Setting durability to Durability.SKIP_WAL
means that in a fail scenario you will lose
any increments that have not been flushed.
incrementColumnValue
in interface Table
row
- The row that contains the cell to increment.family
- The column family of the cell to increment.qualifier
- The column qualifier of the cell to increment.amount
- The amount to increment the cell with (or decrement, if the amount is
negative).durability
- The persistence guarantee for this increment.IOException
- if a remote or network exception occurs.public void close()
Table
public TableOverAsyncTable.RegionCoprocessorRpcChannel coprocessorService(byte[] row)
Table
RpcChannel
instance connected to the table region containing the specified row. The row given does not
actually have to exist. Whichever region would contain the row based on start and end keys will
be used. Note that the row
parameter is also not passed to the coprocessor handler
registered for this protocol, unless the row
is separately passed as an argument in the
service request. The parameter here is only used to locate the region used to handle the call.
The obtained RpcChannel
instance can be
used to access a published coprocessor Service
using standard protobuf service
invocations:
CoprocessorRpcChannel channel = myTable.coprocessorService(rowkey); MyService.BlockingInterface service = MyService.newBlockingStub(channel); MyCallRequest request = MyCallRequest.newBuilder() ... .build(); MyCallResponse response = service.myCall(null, request);
coprocessorService
in interface Table
row
- The row key used to identify the remote region locationConnection.toAsyncConnection()
private Pair<List<byte[]>,List<HRegionLocation>> getKeysAndRegionsInRange(byte[] startKey, byte[] endKey, boolean includeEndKey) throws IOException
startKey
- Starting row in range, inclusiveendKey
- Ending row in rangeincludeEndKey
- true if endRow is inclusive, false if exclusiveIOException
- if a remote or network exception occursprivate Pair<List<byte[]>,List<HRegionLocation>> getKeysAndRegionsInRange(byte[] startKey, byte[] endKey, boolean includeEndKey, boolean reload) throws IOException
startKey
- Starting row in range, inclusiveendKey
- Ending row in rangeincludeEndKey
- true if endRow is inclusive, false if exclusivereload
- true to reload information or false to use cached informationIOException
- if a remote or network exception occursprivate List<byte[]> getStartKeysInRange(byte[] start, byte[] end) throws IOException
IOException
private <R> void coprocessorService(String serviceName, byte[] startKey, byte[] endKey, Batch.Callback<R> callback, TableOverAsyncTable.StubCall<R> call) throws Throwable
Throwable
public <T extends org.apache.hbase.thirdparty.com.google.protobuf.Service,R> void coprocessorService(Class<T> service, byte[] startKey, byte[] endKey, Batch.Call<T,R> callable, Batch.Callback<R> callback) throws org.apache.hbase.thirdparty.com.google.protobuf.ServiceException, Throwable
Table
Service
subclass for each table region spanning the
range from the startKey
row to endKey
row (inclusive), and invokes the passed
Batch.Call.call(T)
method with each
Service
instance.
The given
Batch.Callback.update(byte[],byte[],Object)
method will be called with the return value from each region's
Batch.Call.call(T)
invocation.coprocessorService
in interface Table
T
- the Service
subclass to connect toR
- Return type for the callable
parameter's
Batch.Call.call(T)
methodservice
- the protocol buffer Service
implementation to callstartKey
- start region selection with region containing this row. If null
, the
selection will start with the first table region.endKey
- select regions up to and including the region containing this row. If
null
, selection will continue through the last table region.callable
- this instance's
Batch.Call.call(T)
method will
be invoked once per table region, using the Service
instance connected
to that region.org.apache.hbase.thirdparty.com.google.protobuf.ServiceException
Throwable
Connection.toAsyncConnection()
public <R extends org.apache.hbase.thirdparty.com.google.protobuf.Message> void batchCoprocessorService(org.apache.hbase.thirdparty.com.google.protobuf.Descriptors.MethodDescriptor methodDescriptor, org.apache.hbase.thirdparty.com.google.protobuf.Message request, byte[] startKey, byte[] endKey, R responsePrototype, Batch.Callback<R> callback) throws org.apache.hbase.thirdparty.com.google.protobuf.ServiceException, Throwable
Table
Service
subclass for each table region spanning the
range from the startKey
row to endKey
row (inclusive), all the invocations to
the same region server will be batched into one call. The coprocessor service is invoked
according to the service instance, method name and parameters.
The given
Batch.Callback.update(byte[],byte[],Object)
method will be called with the return value from each region's invocation.batchCoprocessorService
in interface Table
R
- the response type for the coprocessor Service methodmethodDescriptor
- the descriptor for the protobuf service method to call.request
- the method call parametersstartKey
- start region selection with region containing this row. If
null
, the selection will start with the first table region.endKey
- select regions up to and including the region containing this row. If
null
, selection will continue through the last table region.responsePrototype
- the proto type of the response of the method in Service.callback
- callback to invoke with the response for each regionorg.apache.hbase.thirdparty.com.google.protobuf.ServiceException
Throwable
Connection.toAsyncConnection()
public long getRpcTimeout(TimeUnit unit)
Table
getRpcTimeout
in interface Table
unit
- the unit of time the timeout to be represented inTable.getReadRpcTimeout(TimeUnit)
,
Table.getWriteRpcTimeout(TimeUnit)
public long getReadRpcTimeout(TimeUnit unit)
Table
getReadRpcTimeout
in interface Table
unit
- the unit of time the timeout to be represented inpublic long getWriteRpcTimeout(TimeUnit unit)
Table
getWriteRpcTimeout
in interface Table
unit
- the unit of time the timeout to be represented inpublic long getOperationTimeout(TimeUnit unit)
Table
getOperationTimeout
in interface Table
unit
- the unit of time the timeout to be represented inpublic Map<String,byte[]> getRequestAttributes()
Table
getRequestAttributes
in interface Table
public RegionLocator getRegionLocator() throws IOException
Table
RegionLocator
for this table.getRegionLocator
in interface Table
IOException
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.