@InterfaceAudience.Private @InterfaceStability.Evolving public class BufferedMutatorImpl extends Object implements BufferedMutator
Used to communicate with a single HBase table similar to HTable
but meant for batched, potentially asynchronous puts. Obtain an instance from
a Connection and call close() afterwards.
While this can be used accross threads, great care should be used when doing so. Errors are global to the buffered mutator and the Exceptions can be thrown on any thread that causes the flush for requests.
ConnectionFactory,
ConnectionBufferedMutator.ExceptionListener| Modifier and Type | Field and Description |
|---|---|
protected AsyncProcess |
ap |
private boolean |
closed |
private org.apache.hadoop.conf.Configuration |
conf |
protected ClusterConnection |
connection |
(package private) AtomicLong |
currentWriteBufferSize |
private BufferedMutator.ExceptionListener |
listener |
private static org.apache.commons.logging.Log |
LOG |
private int |
maxKeyValueSize |
private ExecutorService |
pool |
private TableName |
tableName |
(package private) ConcurrentLinkedQueue<Mutation> |
writeAsyncBuffer |
private long |
writeBufferSize |
| Constructor and Description |
|---|
BufferedMutatorImpl(ClusterConnection conn,
RpcRetryingCallerFactory rpcCallerFactory,
RpcControllerFactory rpcFactory,
BufferedMutatorParams params) |
| Modifier and Type | Method and Description |
|---|---|
private void |
backgroundFlushCommits(boolean synchronous)
Send the operations in the buffer to the servers.
|
void |
close()
Performs a
BufferedMutator.flush() and releases any resources held. |
void |
flush()
Executes all the buffered, asynchronous
Mutation operations and waits until they
are done. |
org.apache.hadoop.conf.Configuration |
getConfiguration()
Returns the
Configuration object used by this instance. |
TableName |
getName()
Gets the fully qualified table name instance of the table that this BufferedMutator writes to.
|
List<Row> |
getWriteBuffer()
Deprecated.
Going away when we drop public support for
HTableInterface.
Ó |
long |
getWriteBufferSize()
Returns the maximum size in bytes of the write buffer for this HTable.
|
void |
mutate(List<? extends Mutation> ms)
Send some
Mutations to the table. |
void |
mutate(Mutation m)
Sends a
Mutation to the table. |
void |
setWriteBufferSize(long writeBufferSize)
Deprecated.
Going away when we drop public support for
HTableInterface. |
void |
validatePut(Put put) |
private static final org.apache.commons.logging.Log LOG
private final BufferedMutator.ExceptionListener listener
protected ClusterConnection connection
private final TableName tableName
private volatile org.apache.hadoop.conf.Configuration conf
final ConcurrentLinkedQueue<Mutation> writeAsyncBuffer
AtomicLong currentWriteBufferSize
private long writeBufferSize
private final int maxKeyValueSize
private boolean closed
private final ExecutorService pool
protected AsyncProcess ap
BufferedMutatorImpl(ClusterConnection conn, RpcRetryingCallerFactory rpcCallerFactory, RpcControllerFactory rpcFactory, BufferedMutatorParams params)
public TableName getName()
BufferedMutatorgetName in interface BufferedMutatorpublic org.apache.hadoop.conf.Configuration getConfiguration()
BufferedMutatorConfiguration 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 BufferedMutatorpublic void mutate(Mutation m) throws InterruptedIOException, RetriesExhaustedWithDetailsException
BufferedMutatorMutation to the table. The mutations will be buffered and sent over the
wire as part of a batch. Currently only supports Put and Delete mutations.mutate in interface BufferedMutatorm - The data to send.InterruptedIOExceptionRetriesExhaustedWithDetailsExceptionpublic void mutate(List<? extends Mutation> ms) throws InterruptedIOException, RetriesExhaustedWithDetailsException
BufferedMutatorMutations to the table. The mutations will be buffered and sent over the
wire as part of a batch. There is no guarantee of sending entire content of mutations
in a single batch; it will be broken up according to the write buffer capacity.mutate in interface BufferedMutatorms - The data to send.InterruptedIOExceptionRetriesExhaustedWithDetailsExceptionpublic void validatePut(Put put) throws IllegalArgumentException
IllegalArgumentExceptionpublic void close()
throws IOException
BufferedMutatorBufferedMutator.flush() and releases any resources held.close in interface Closeableclose in interface AutoCloseableclose in interface BufferedMutatorIOException - if a remote or network exception occurs.public void flush()
throws InterruptedIOException,
RetriesExhaustedWithDetailsException
BufferedMutatorMutation operations and waits until they
are done.flush in interface BufferedMutatorInterruptedIOExceptionRetriesExhaustedWithDetailsExceptionprivate void backgroundFlushCommits(boolean synchronous)
throws InterruptedIOException,
RetriesExhaustedWithDetailsException
synchronous - - if true, sends all the writes and wait for all of them to finish before
returning.InterruptedIOExceptionRetriesExhaustedWithDetailsException@Deprecated public void setWriteBufferSize(long writeBufferSize) throws RetriesExhaustedWithDetailsException, InterruptedIOException
HTableInterface.HTable.setWriteBufferSize(long) only. This ought
not be called for production uses.public long getWriteBufferSize()
The default value comes from the configuration parameter hbase.client.write.buffer.
getWriteBufferSize in interface BufferedMutator@Deprecated public List<Row> getWriteBuffer()
HTableInterface.
ÓHTable.getWriteBuffer() only. This should not beÓ
called from production uses.Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.