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 ClassesNested classes/interfaces inherited from interface org.apache.hadoop.hbase.client.BufferedMutator
BufferedMutator.ExceptionListener -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AsyncProcessprivate final booleanprivate booleanprivate final org.apache.hadoop.conf.Configurationprivate final AtomicLongprivate final AtomicLongprivate final AtomicLongprivate final BufferedMutator.ExceptionListenerprivate static final org.slf4j.Loggerprivate final intprivate final AtomicIntegerprivate final ExecutorServiceprivate final AtomicIntegerprivate final TableNameprivate final AtomicIntegerCount the size ofwriteAsyncBuffer.private final ConcurrentLinkedQueue<Mutation>private final AtomicLongprivate Timerprivate final AtomicLongprivate final longFields inherited from interface org.apache.hadoop.hbase.client.BufferedMutator
CLASSNAME_KEY, MIN_WRITE_BUFFER_PERIODIC_FLUSH_TIMERTICK_MS -
Constructor Summary
ConstructorsConstructorDescriptionBufferedMutatorImpl(ClusterConnection conn, BufferedMutatorParams params, AsyncProcess ap) BufferedMutatorImpl(ClusterConnection conn, RpcRetryingCallerFactory rpcCallerFactory, RpcControllerFactory rpcFactory, BufferedMutatorParams params) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidvoidclose()Performs aBufferedMutator.flush()and releases any resources held.(package private) BufferedMutatorImpl.QueueRowAccessprivate AsyncProcessTaskprivate voiddoFlush(boolean flushAll) Send the operations in the buffer to the servers.voidflush()Executes all the buffered, asynchronousMutationoperations and waits until they are done.(package private) AsyncProcessorg.apache.hadoop.conf.ConfigurationReturns theConfigurationobject used by this instance.(package private) longprotected longgetName()Gets the fully qualified table name instance of the table that this BufferedMutator writes to.(package private) ExecutorServicegetPool()(package private) intCount the mutations which haven't been flushedlongReturns the current periodic flush timeout value in milliseconds.longReturns the current periodic flush timertick interval in milliseconds.longReturns the maximum size in bytes of the write buffer for this HTable.private static RetriesExhaustedWithDetailsExceptionvoidSend someMutations to the table.voidSends aMutationto the table.voidsetOperationTimeout(int operationTimeout) Set operation timeout for this mutator instancevoidsetRpcTimeout(int rpcTimeout) Set rpc timeout for this mutator instancevoidsetWriteBufferPeriodicFlush(long timeoutMs, long timerTickMs) Sets the maximum time before the buffer is automatically flushed.(package private) intsize()Count the mutations which haven't been processed.private voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:BufferedMutatorGets the fully qualified table name instance of the table that this BufferedMutator writes to.- Specified by:
getNamein interfaceBufferedMutator
-
getConfiguration
Description copied from interface:BufferedMutatorReturns theConfigurationobject used by this instance.The reference returned is not a copy, so any change made to it will affect this instance.
- Specified by:
getConfigurationin interfaceBufferedMutator
-
mutate
Description copied from interface:BufferedMutatorSends aMutationto the table. The mutations will be buffered and sent over the wire as part of a batch. Currently only supportsPutandDeletemutations.- Specified by:
mutatein interfaceBufferedMutator- Parameters:
m- The data to send.- Throws:
InterruptedIOExceptionRetriesExhaustedWithDetailsException
-
mutate
public void mutate(List<? extends Mutation> ms) throws InterruptedIOException, RetriesExhaustedWithDetailsException Description copied from interface:BufferedMutatorSend someMutations 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 ofmutationsin a single batch; it will be broken up according to the write buffer capacity.- Specified by:
mutatein interfaceBufferedMutator- Parameters:
ms- The data to send.- Throws:
InterruptedIOExceptionRetriesExhaustedWithDetailsException
-
getExecutedWriteBufferPeriodicFlushes
-
timerCallbackForWriteBufferPeriodicFlush
-
close
Description copied from interface:BufferedMutatorPerforms aBufferedMutator.flush()and releases any resources held.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceBufferedMutator- Specified by:
closein interfaceCloseable- Throws:
IOException- if a remote or network exception occurs.
-
createTask
-
flush
Description copied from interface:BufferedMutatorExecutes all the buffered, asynchronousMutationoperations and waits until they are done.- Specified by:
flushin interfaceBufferedMutator- Throws:
InterruptedIOExceptionRetriesExhaustedWithDetailsException
-
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:
InterruptedIOExceptionRetriesExhaustedWithDetailsException
-
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:
getWriteBufferSizein interfaceBufferedMutator- Returns:
- The size of the write buffer in bytes.
-
setWriteBufferPeriodicFlush
Description copied from interface:BufferedMutatorSets the maximum time before the buffer is automatically flushed.- Specified by:
setWriteBufferPeriodicFlushin 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:BufferedMutatorReturns the current periodic flush timeout value in milliseconds.- Specified by:
getWriteBufferPeriodicFlushTimeoutMsin 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:BufferedMutatorReturns the current periodic flush timertick interval in milliseconds.- Specified by:
getWriteBufferPeriodicFlushTimerTickMsin 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:BufferedMutatorSet rpc timeout for this mutator instance- Specified by:
setRpcTimeoutin interfaceBufferedMutator
-
setOperationTimeout
Description copied from interface:BufferedMutatorSet operation timeout for this mutator instance- Specified by:
setOperationTimeoutin 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
-