|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.hbase.rest.client.RemoteHTable
public class RemoteHTable
HTable interface to remote tables accessed via REST gateway
Constructor Summary | |
---|---|
RemoteHTable(Client client,
org.apache.hadoop.conf.Configuration conf,
byte[] name)
Constructor |
|
RemoteHTable(Client client,
org.apache.hadoop.conf.Configuration conf,
byte[] name,
String accessToken)
Deprecated. accessToken is not used and will be removed |
|
RemoteHTable(Client client,
org.apache.hadoop.conf.Configuration conf,
String name)
Constructor |
|
RemoteHTable(Client client,
org.apache.hadoop.conf.Configuration conf,
String name,
String accessToken)
Deprecated. accessToken is not used and will be removed |
|
RemoteHTable(Client client,
String name)
Constructor |
|
RemoteHTable(Client client,
String name,
String accessToken)
Deprecated. accessToken is not used and will be removed |
Method Summary | ||
---|---|---|
Result |
append(Append append)
Appends values to one or more columns within a single row. |
|
Object[] |
batch(List<? extends Row> actions)
Same as HTableInterface.batch(List, Object[]) , but returns an array of
results instead of using a results parameter reference. |
|
void |
batch(List<? extends Row> actions,
Object[] results)
Method that does a batch call on Deletes, Gets, Puts, Increments, Appends and RowMutations. |
|
protected CellSetModel |
buildModelFromPut(Put put)
|
|
protected String |
buildMultiRowSpec(byte[][] rows,
int maxVersions)
|
|
protected Result[] |
buildResultFromModel(CellSetModel model)
|
|
protected String |
buildRowSpec(byte[] row,
Map familyMap,
long startTime,
long endTime,
int maxVersions)
|
|
boolean |
checkAndDelete(byte[] row,
byte[] family,
byte[] qualifier,
byte[] value,
Delete delete)
Atomically checks if a row/family/qualifier value matches the expected value. |
|
boolean |
checkAndPut(byte[] row,
byte[] family,
byte[] qualifier,
byte[] value,
Put put)
Atomically checks if a row/family/qualifier value matches the expected value. |
|
void |
close()
Releases any resources help or pending changes in internal buffers. |
|
|
coprocessorExec(Class<T> protocol,
byte[] startKey,
byte[] endKey,
Batch.Call<T,R> callable)
Invoke the passed Batch.Call against
the CoprocessorProtocol instances running in the selected regions. |
|
|
coprocessorExec(Class<T> protocol,
byte[] startKey,
byte[] endKey,
Batch.Call<T,R> callable,
Batch.Callback<R> callback)
Invoke the passed Batch.Call against
the CoprocessorProtocol instances running in the selected regions. |
|
|
coprocessorProxy(Class<T> protocol,
byte[] row)
Creates and returns a proxy to the CoprocessorProtocol instance running in the region containing the specified row. |
|
void |
delete(Delete delete)
Deletes the specified cells/row. |
|
void |
delete(List<Delete> deletes)
Deletes the specified cells/rows in bulk. |
|
boolean |
exists(Get get)
Test for the existence of columns in the table, as specified in the Get. |
|
void |
flushCommits()
Executes all the buffered Put operations. |
|
Result |
get(Get get)
Extracts certain cells from a given row. |
|
Result[] |
get(List<Get> gets)
Extracts certain cells from the given rows, in batch. |
|
org.apache.hadoop.conf.Configuration |
getConfiguration()
Returns the Configuration object used by this instance. |
|
Result |
getRowOrBefore(byte[] row,
byte[] family)
Return the row that matches row exactly, or the one that immediately precedes it. |
|
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. |
|
HTableDescriptor |
getTableDescriptor()
Gets the table descriptor for this table. |
|
byte[] |
getTableName()
Gets the name of this table. |
|
long |
getWriteBufferSize()
Returns the maximum size in bytes of the write buffer for this HTable. |
|
Result |
increment(Increment increment)
Increments one or more columns within a single row. |
|
long |
incrementColumnValue(byte[] row,
byte[] family,
byte[] qualifier,
long amount)
Atomically increments a column value. |
|
long |
incrementColumnValue(byte[] row,
byte[] family,
byte[] qualifier,
long amount,
boolean writeToWAL)
Atomically increments a column value. |
|
boolean |
isAutoFlush()
Tells whether or not 'auto-flush' is turned on. |
|
RowLock |
lockRow(byte[] row)
Deprecated. RowLock and associated operations are deprecated |
|
void |
mutateRow(RowMutations rm)
Performs multiple mutations atomically on a single row. |
|
void |
put(List<Put> puts)
Puts some data in the table, in batch. |
|
void |
put(Put put)
Puts some data in the table. |
|
void |
setAutoFlush(boolean autoFlush)
See HTableInterface.setAutoFlush(boolean, boolean) |
|
void |
setAutoFlush(boolean autoFlush,
boolean clearBufferOnFail)
Turns 'auto-flush' on or off. |
|
void |
setWriteBufferSize(long writeBufferSize)
Sets the size of the buffer in bytes. |
|
void |
unlockRow(RowLock rl)
Deprecated. RowLock and associated operations are deprecated |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RemoteHTable(Client client, String name)
client
- name
- @Deprecated public RemoteHTable(Client client, String name, String accessToken)
client
- name
- accessToken
- public RemoteHTable(Client client, org.apache.hadoop.conf.Configuration conf, String name)
client
- conf
- name
- @Deprecated public RemoteHTable(Client client, org.apache.hadoop.conf.Configuration conf, String name, String accessToken)
client
- conf
- name
- accessToken
- public RemoteHTable(Client client, org.apache.hadoop.conf.Configuration conf, byte[] name)
client
- conf
- name
- @Deprecated public RemoteHTable(Client client, org.apache.hadoop.conf.Configuration conf, byte[] name, String accessToken)
client
- conf
- name
- accessToken
- Method Detail |
---|
protected String buildRowSpec(byte[] row, Map familyMap, long startTime, long endTime, int maxVersions)
protected String buildMultiRowSpec(byte[][] rows, int maxVersions)
protected Result[] buildResultFromModel(CellSetModel model)
protected CellSetModel buildModelFromPut(Put put)
public byte[] getTableName()
HTableInterface
getTableName
in interface HTableInterface
public org.apache.hadoop.conf.Configuration getConfiguration()
HTableInterface
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 HTableInterface
public HTableDescriptor getTableDescriptor() throws IOException
HTableInterface
table descriptor
for this table.
getTableDescriptor
in interface HTableInterface
IOException
- if a remote or network exception occurs.public void close() throws IOException
HTableInterface
close
in interface Closeable
close
in interface HTableInterface
IOException
- if a remote or network exception occurs.public Result get(Get get) throws IOException
HTableInterface
get
in interface HTableInterface
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
HTableInterface
get
in interface HTableInterface
gets
- The objects that specify what data to fetch and from which rows.
Result
instance returned won't
contain any KeyValue
, 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.
IOException
- if a remote or network exception occurs.public boolean exists(Get get) throws IOException
HTableInterface
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 HTableInterface
get
- the Get
IOException
- epublic void put(Put put) throws IOException
HTableInterface
If isAutoFlush
is false, the update is buffered
until the internal buffer is full.
put
in interface HTableInterface
put
- The data to put.
IOException
- if a remote or network exception occurs.public void put(List<Put> puts) throws IOException
HTableInterface
If isAutoFlush
is false, the update is buffered
until the internal buffer is full.
This can be used for group commit, or for submitting user defined batches. The writeBuffer will be periodically inspected while the List is processed, so depending on the List size the writeBuffer may flush not at all, or more than once.
put
in interface HTableInterface
puts
- The list of mutations to apply. The batch put is done by
aggregating the iteration of the Puts over the write buffer
at the client-side for a single RPC call.
IOException
- if a remote or network exception occurs.public void delete(Delete delete) throws IOException
HTableInterface
delete
in interface HTableInterface
delete
- The object that specifies what to delete.
IOException
- if a remote or network exception occurs.public void delete(List<Delete> deletes) throws IOException
HTableInterface
delete
in interface HTableInterface
deletes
- List of things to delete. List gets modified by this
method (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 void flushCommits() throws IOException
HTableInterface
Put
operations.
This method gets called once automatically for every Put
or batch
of Put
s (when put(List
is used) when
HTableInterface.isAutoFlush()
is true
.
flushCommits
in interface HTableInterface
IOException
- if a remote or network exception occurs.public ResultScanner getScanner(Scan scan) throws IOException
HTableInterface
Scan
object.
Note that the passed Scan
's start row and caching properties
maybe changed.
getScanner
in interface HTableInterface
scan
- A configured Scan
object.
IOException
- if a remote or network exception occurs.public ResultScanner getScanner(byte[] family) throws IOException
HTableInterface
getScanner
in interface HTableInterface
family
- The column family to scan.
IOException
- if a remote or network exception occurs.public ResultScanner getScanner(byte[] family, byte[] qualifier) throws IOException
HTableInterface
getScanner
in interface HTableInterface
family
- The column family to scan.qualifier
- The column qualifier to scan.
IOException
- if a remote or network exception occurs.public boolean isAutoFlush()
HTableInterface
isAutoFlush
in interface HTableInterface
true
if 'auto-flush' is enabled (default), meaning
Put
operations don't get buffered/delayed and are immediately
executed.public Result getRowOrBefore(byte[] row, byte[] family) throws IOException
HTableInterface
getRowOrBefore
in interface HTableInterface
row
- A row key.family
- Column family to include in the Result
.
IOException
- if a remote or network exception occurs.public RowLock lockRow(byte[] row) throws IOException
RowLock
and associated operations are deprecated
HTableInterface
lockRow
in interface HTableInterface
row
- The row to lock.
RowLock
containing the row and lock id.
IOException
- if a remote or network exception occurs.RowLock
,
HTableInterface.unlockRow(org.apache.hadoop.hbase.client.RowLock)
public void unlockRow(RowLock rl) throws IOException
RowLock
and associated operations are deprecated
HTableInterface
unlockRow
in interface HTableInterface
rl
- The row lock to release.
IOException
- if a remote or network exception occurs.RowLock
,
HTableInterface.unlockRow(org.apache.hadoop.hbase.client.RowLock)
public boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, byte[] value, Put put) throws IOException
HTableInterface
checkAndPut
in interface HTableInterface
row
- to checkfamily
- column family to checkqualifier
- column qualifier to checkvalue
- the expected valueput
- data to put if check succeeds
IOException
- epublic boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier, byte[] value, Delete delete) throws IOException
HTableInterface
checkAndDelete
in interface HTableInterface
row
- to checkfamily
- column family to checkqualifier
- column qualifier to checkvalue
- the expected valuedelete
- data to delete if check succeeds
IOException
- epublic Result increment(Increment increment) throws IOException
HTableInterface
This operation does not appear atomic to readers. Increments are done under a single row lock, so write operations to a row are synchronized, but readers do not take row locks so get and scan operations can see this operation partially completed.
increment
in interface HTableInterface
increment
- object that specifies the columns and amounts to be used
for the increment operations
IOException
- epublic Result append(Append append) throws IOException
HTableInterface
This operation does not appear atomic to readers. Appends are done under a single row lock, so write operations to a row are synchronized, but readers do not take row locks so get and scan operations can see this operation partially completed.
append
in interface HTableInterface
append
- object that specifies the columns and amounts to be used
for the increment operations
IOException
- epublic long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount) throws IOException
HTableInterface
Equivalent to incrementColumnValue
(row, family, qualifier, amount,
true)}
incrementColumnValue
in interface HTableInterface
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, boolean writeToWAL) throws IOException
HTableInterface
amount
and
written to the specified column.
Setting writeToWAL to false means that in a fail scenario, you will lose any increments that have not been flushed.
incrementColumnValue
in interface HTableInterface
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).writeToWAL
- if true
, the operation will be applied to the
Write Ahead Log (WAL). This makes the operation slower but safer, as if
the call returns successfully, it is guaranteed that the increment will
be safely persisted. When set to false
, the call may return
successfully before the increment is safely persisted, so it's possible
that the increment be lost in the event of a failure happening before the
operation gets persisted.
IOException
- if a remote or network exception occurs.public void batch(List<? extends Row> actions, Object[] results) throws IOException
HTableInterface
HTableInterface.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 HTableInterface
actions
- list of Get, Put, Delete, Increment, Append, RowMutations objectsresults
- 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
IOException
public Object[] batch(List<? extends Row> actions) throws IOException
HTableInterface
HTableInterface.batch(List, Object[])
, but returns an array of
results instead of using a results parameter reference.
batch
in interface HTableInterface
actions
- list of Get, Put, Delete, Increment, Append, RowMutations objects
IOException
public <T extends CoprocessorProtocol> T coprocessorProxy(Class<T> protocol, byte[] row)
HTableInterface
row
parameter is also not passed to the
coprocessor handler registered for this protocol, unless the row
is separately passed as an argument in a proxy method call. The parameter
here is just used to locate the region used to handle the call.
coprocessorProxy
in interface HTableInterface
protocol
- The class or interface defining the remote protocolrow
- The row key used to identify the remote region location
public <T extends CoprocessorProtocol,R> Map<byte[],R> coprocessorExec(Class<T> protocol, byte[] startKey, byte[] endKey, Batch.Call<T,R> callable) throws IOException, Throwable
HTableInterface
Batch.Call
against
the CoprocessorProtocol
instances running in the selected regions.
All regions beginning with the region containing the startKey
row, through to the region containing the endKey
row (inclusive)
will be used. If startKey
or endKey
is
null
, the first and last regions in the table, respectively,
will be used in the range selection.
coprocessorExec
in interface HTableInterface
T
- CoprocessorProtocol subclass for the remote invocationR
- Return type for the
Batch.Call.call(Object)
methodprotocol
- the CoprocessorProtocol implementation to callstartKey
- start region selection with region containing this rowendKey
- select regions up to and including the region containing
this rowcallable
- wraps the CoprocessorProtocol implementation method calls
made per-region
Map
of region names to
Batch.Call.call(Object)
return values
IOException
Throwable
public <T extends CoprocessorProtocol,R> void coprocessorExec(Class<T> protocol, byte[] startKey, byte[] endKey, Batch.Call<T,R> callable, Batch.Callback<R> callback) throws IOException, Throwable
HTableInterface
Batch.Call
against
the CoprocessorProtocol
instances running in the selected regions.
All regions beginning with the region containing the startKey
row, through to the region containing the endKey
row
(inclusive)
will be used. If startKey
or endKey
is
null
, the first and last regions in the table, respectively,
will be used in the range selection.
For each result, the given
Batch.Callback.update(byte[], byte[], Object)
method will be called.
coprocessorExec
in interface HTableInterface
T
- CoprocessorProtocol subclass for the remote invocationR
- Return type for the
Batch.Call.call(Object)
methodprotocol
- the CoprocessorProtocol implementation to callstartKey
- start region selection with region containing this rowendKey
- select regions up to and including the region containing
this rowcallable
- wraps the CoprocessorProtocol implementation method calls
made per-regioncallback
- an instance upon which
Batch.Callback.update(byte[], byte[], Object)
with the
Batch.Call.call(Object)
return value for each region
IOException
Throwable
public void mutateRow(RowMutations rm) throws IOException
HTableInterface
Put
and Delete
are supported.
mutateRow
in interface HTableInterface
IOException
public void setAutoFlush(boolean autoFlush)
HTableInterface
HTableInterface.setAutoFlush(boolean, boolean)
setAutoFlush
in interface HTableInterface
autoFlush
- Whether or not to enable 'auto-flush'.public void setAutoFlush(boolean autoFlush, boolean clearBufferOnFail)
HTableInterface
When enabled (default), Put
operations don't get buffered/delayed
and are immediately executed. Failed operations are not retried. This is
slower but safer.
Turning off #autoFlush
means that multiple Put
s will be
accepted before any RPC is actually sent to do the write operations. If the
application dies before pending writes get flushed to HBase, data will be
lost.
When you turn #autoFlush
off, you should also consider the
#clearBufferOnFail
option. By default, asynchronous Put
requests will be retried on failure until successful. However, this can
pollute the writeBuffer and slow down batching performance. Additionally,
you may want to issue a number of Put requests and call
HTableInterface.flushCommits()
as a barrier. In both use cases, consider setting
clearBufferOnFail to true to erase the buffer after HTableInterface.flushCommits()
has been called, regardless of success.
setAutoFlush
in interface HTableInterface
autoFlush
- Whether or not to enable 'auto-flush'.clearBufferOnFail
- Whether to keep Put failures in the writeBufferHTableInterface.flushCommits()
public long getWriteBufferSize()
HTableInterface
The default value comes from the configuration parameter
hbase.client.write.buffer
.
getWriteBufferSize
in interface HTableInterface
public void setWriteBufferSize(long writeBufferSize) throws IOException
HTableInterface
If the new size is less than the current amount of data in the write buffer, the buffer gets flushed.
setWriteBufferSize
in interface HTableInterface
writeBufferSize
- The new write buffer size, in bytes.
IOException
- if a remote or network exception occurs.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |