Class BufferedMutatorImpl
- All Implemented Interfaces:
Closeable
,AutoCloseable
,BufferedMutator
Used to communicate with a single HBase table similar to Table
but meant for batched,
potentially asynchronous puts. Obtain an instance from a Connection
and call
close()
afterwards. Provide an alternate to this implementation by setting
BufferedMutatorParams.implementationClassName(String)
or by setting alternate classname
via the key {} in Configuration.
While this can be used across 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.
- Since:
- 1.0.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.client.BufferedMutator
BufferedMutator.ExceptionListener
-
Field Summary
Modifier and TypeFieldDescriptionprivate final AsyncProcess
private final boolean
private boolean
private final org.apache.hadoop.conf.Configuration
private final AtomicLong
private final AtomicLong
private final AtomicLong
private final BufferedMutator.ExceptionListener
private static final org.slf4j.Logger
private final int
private final AtomicInteger
private final ExecutorService
private final AtomicInteger
private final TableName
private final AtomicInteger
Count the size ofwriteAsyncBuffer
.private final ConcurrentLinkedQueue<Mutation>
private final AtomicLong
private Timer
private final AtomicLong
private final long
Fields inherited from interface org.apache.hadoop.hbase.client.BufferedMutator
CLASSNAME_KEY, MIN_WRITE_BUFFER_PERIODIC_FLUSH_TIMERTICK_MS
-
Constructor Summary
ConstructorDescriptionBufferedMutatorImpl
(ClusterConnection conn, BufferedMutatorParams params, AsyncProcess ap) BufferedMutatorImpl
(ClusterConnection conn, RpcRetryingCallerFactory rpcCallerFactory, RpcControllerFactory rpcFactory, BufferedMutatorParams params) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
void
close()
Performs aBufferedMutator.flush()
and releases any resources held.(package private) BufferedMutatorImpl.QueueRowAccess
private AsyncProcessTask
private void
doFlush
(boolean flushAll) Send the operations in the buffer to the servers.void
flush()
Executes all the buffered, asynchronousMutation
operations and waits until they are done.(package private) AsyncProcess
org.apache.hadoop.conf.Configuration
Returns theConfiguration
object used by this instance.(package private) long
protected long
getName()
Gets the fully qualified table name instance of the table that this BufferedMutator writes to.(package private) ExecutorService
getPool()
(package private) int
Count the mutations which haven't been flushedlong
Returns the current periodic flush timeout value in milliseconds.long
Returns the current periodic flush timertick interval in milliseconds.long
Returns the maximum size in bytes of the write buffer for this HTable.private static RetriesExhaustedWithDetailsException
void
Send someMutation
s to the table.void
Sends aMutation
to the table.void
setOperationTimeout
(int operationTimeout) Set operation timeout for this mutator instancevoid
setRpcTimeout
(int rpcTimeout) Set rpc timeout for this mutator instancevoid
setWriteBufferPeriodicFlush
(long timeoutMs, long timerTickMs) Sets the maximum time before the buffer is automatically flushed.(package private) int
size()
Count the mutations which haven't been processed.private void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.hadoop.hbase.client.BufferedMutator
disableWriteBufferPeriodicFlush, setWriteBufferPeriodicFlush
-
Field Details
-
LOG
-
listener
-
tableName
-
conf
-
writeAsyncBuffer
-
currentWriteBufferSize
-
undealtMutationCount
Count the size ofwriteAsyncBuffer
. TheConcurrentLinkedQueue.size()
is NOT a constant-time operation. -
writeBufferSize
-
writeBufferPeriodicFlushTimeoutMs
-
writeBufferPeriodicFlushTimerTickMs
-
writeBufferPeriodicFlushTimer
-
maxKeyValueSize
-
pool
-
rpcTimeout
-
operationTimeout
-
cleanupPoolOnClose
-
closed
-
ap
-
firstRecordInBufferTimestamp
-
executedWriteBufferPeriodicFlushes
-
-
Constructor Details
-
BufferedMutatorImpl
BufferedMutatorImpl(ClusterConnection conn, BufferedMutatorParams params, AsyncProcess ap) -
BufferedMutatorImpl
BufferedMutatorImpl(ClusterConnection conn, RpcRetryingCallerFactory rpcCallerFactory, RpcControllerFactory rpcFactory, BufferedMutatorParams params)
-
-
Method Details
-
checkClose
-
getPool
-
getAsyncProcess
-
getName
Description copied from interface:BufferedMutator
Gets the fully qualified table name instance of the table that this BufferedMutator writes to.- Specified by:
getName
in interfaceBufferedMutator
-
getConfiguration
Description copied from interface:BufferedMutator
Returns theConfiguration
object used by this instance.The reference returned is not a copy, so any change made to it will affect this instance.
- Specified by:
getConfiguration
in interfaceBufferedMutator
-
mutate
Description copied from interface:BufferedMutator
Sends aMutation
to the table. The mutations will be buffered and sent over the wire as part of a batch. Currently only supportsPut
andDelete
mutations.- Specified by:
mutate
in interfaceBufferedMutator
- Parameters:
m
- The data to send.- Throws:
InterruptedIOException
RetriesExhaustedWithDetailsException
-
mutate
public void mutate(List<? extends Mutation> ms) throws InterruptedIOException, RetriesExhaustedWithDetailsException Description copied from interface:BufferedMutator
Send someMutation
s 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 ofmutations
in a single batch; it will be broken up according to the write buffer capacity.- Specified by:
mutate
in interfaceBufferedMutator
- Parameters:
ms
- The data to send.- Throws:
InterruptedIOException
RetriesExhaustedWithDetailsException
-
getExecutedWriteBufferPeriodicFlushes
-
timerCallbackForWriteBufferPeriodicFlush
-
close
Description copied from interface:BufferedMutator
Performs aBufferedMutator.flush()
and releases any resources held.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceBufferedMutator
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
- if a remote or network exception occurs.
-
createTask
-
flush
Description copied from interface:BufferedMutator
Executes all the buffered, asynchronousMutation
operations and waits until they are done.- Specified by:
flush
in interfaceBufferedMutator
- Throws:
InterruptedIOException
RetriesExhaustedWithDetailsException
-
doFlush
private void doFlush(boolean flushAll) throws InterruptedIOException, RetriesExhaustedWithDetailsException Send the operations in the buffer to the servers.- Parameters:
flushAll
- - if true, sends all the writes and wait for all of them to finish before returning. Otherwise, flush until buffer size is smaller than threshold- Throws:
InterruptedIOException
RetriesExhaustedWithDetailsException
-
makeException
private static RetriesExhaustedWithDetailsException makeException(List<RetriesExhaustedWithDetailsException> errors) -
getWriteBufferSize
Returns the maximum size in bytes of the write buffer for this HTable.The default value comes from the configuration parameter
hbase.client.write.buffer
.- Specified by:
getWriteBufferSize
in interfaceBufferedMutator
- Returns:
- The size of the write buffer in bytes.
-
setWriteBufferPeriodicFlush
Description copied from interface:BufferedMutator
Sets the maximum time before the buffer is automatically flushed.- Specified by:
setWriteBufferPeriodicFlush
in interfaceBufferedMutator
- Parameters:
timeoutMs
- The maximum number of milliseconds how long records may be buffered before they are flushed. Set to 0 to disable.timerTickMs
- The number of milliseconds between each check if the timeout has been exceeded. Must be 100ms (as defined inBufferedMutator.MIN_WRITE_BUFFER_PERIODIC_FLUSH_TIMERTICK_MS
) or larger to avoid performance problems.
-
getWriteBufferPeriodicFlushTimeoutMs
Description copied from interface:BufferedMutator
Returns the current periodic flush timeout value in milliseconds.- Specified by:
getWriteBufferPeriodicFlushTimeoutMs
in interfaceBufferedMutator
- Returns:
- The maximum number of milliseconds how long records may be buffered before they are flushed. The value 0 means this is disabled.
-
getWriteBufferPeriodicFlushTimerTickMs
Description copied from interface:BufferedMutator
Returns the current periodic flush timertick interval in milliseconds.- Specified by:
getWriteBufferPeriodicFlushTimerTickMs
in interfaceBufferedMutator
- Returns:
- The number of milliseconds between each check if the timeout has been exceeded. This value only has a real meaning if the timeout has been set to > 0
-
setRpcTimeout
Description copied from interface:BufferedMutator
Set rpc timeout for this mutator instance- Specified by:
setRpcTimeout
in interfaceBufferedMutator
-
setOperationTimeout
Description copied from interface:BufferedMutator
Set operation timeout for this mutator instance- Specified by:
setOperationTimeout
in interfaceBufferedMutator
-
getCurrentWriteBufferSize
long getCurrentWriteBufferSize() -
size
int size()Count the mutations which haven't been processed.- Returns:
- count of undealt mutation
-
getUnflushedSize
int getUnflushedSize()Count the mutations which haven't been flushed- Returns:
- count of unflushed mutation
-
createQueueRowAccess
-