Package org.apache.hadoop.hbase.client
Class AsyncBufferedMutatorImpl
java.lang.Object
org.apache.hadoop.hbase.client.AsyncBufferedMutatorImpl
- All Implemented Interfaces:
Closeable,AutoCloseable,AsyncBufferedMutator
The implementation of
AsyncBufferedMutator. Simply wrap an AsyncTable.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longprivate booleanprivate ArrayList<CompletableFuture<Void>>private static final int(package private) final ReentrantLockprivate static final org.slf4j.Loggerprivate final intprivate final intprivate final org.apache.hbase.thirdparty.io.netty.util.HashedWheelTimer(package private) org.apache.hbase.thirdparty.io.netty.util.Timeoutprivate final longprivate final AsyncTable<?>private final long -
Constructor Summary
ConstructorsConstructorDescriptionAsyncBufferedMutatorImpl(org.apache.hbase.thirdparty.io.netty.util.HashedWheelTimer periodicalFlushTimer, AsyncTable<?> table, long writeBufferSize, long periodicFlushTimeoutNs, int maxKeyValueSize, int maxMutations) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Performs aAsyncBufferedMutator.flush()and releases any resources held.protected AsyncBufferedMutatorImpl.BatchAtomically drains the current buffered mutations and futures underlockand prepares this mutator to accept a new batch.voidflush()Executes all the buffered, asynchronous operations.private voidflushOrClose(boolean close) org.apache.hadoop.conf.ConfigurationReturns theConfigurationobject used by this instance.intThe maximum number of mutations that this buffered mutator will buffer before flushing themgetName()Gets the fully qualified table name instance of the table that thisAsyncBufferedMutatorwrites to.longReturns the periodical flush interval, 0 means disabled.Returns the rpc request attributes.longReturns the maximum size in bytes of the write buffer.Send someMutations to the table.private voidSends a previously drainedAsyncBufferedMutatorImpl.Batchand wires the user-visible completion futures to the underlying results returned byAsyncTable.batch(List).Methods 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.AsyncBufferedMutator
mutate
-
Field Details
-
LOG
-
INITIAL_CAPACITY
- See Also:
-
periodicalFlushTimer
-
table
-
writeBufferSize
-
periodicFlushTimeoutNs
-
maxKeyValueSize
-
maxMutations
-
mutations
-
futures
-
bufferedSize
-
closed
-
periodicFlushTask
org.apache.hbase.thirdparty.io.netty.util.Timeout periodicFlushTask -
lock
-
-
Constructor Details
-
AsyncBufferedMutatorImpl
AsyncBufferedMutatorImpl(org.apache.hbase.thirdparty.io.netty.util.HashedWheelTimer periodicalFlushTimer, AsyncTable<?> table, long writeBufferSize, long periodicFlushTimeoutNs, int maxKeyValueSize, int maxMutations)
-
-
Method Details
-
getName
Description copied from interface:AsyncBufferedMutatorGets the fully qualified table name instance of the table that thisAsyncBufferedMutatorwrites to.- Specified by:
getNamein interfaceAsyncBufferedMutator
-
getConfiguration
Description copied from interface:AsyncBufferedMutatorReturns 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 interfaceAsyncBufferedMutator
-
drainBatch
Atomically drains the current buffered mutations and futures underlockand prepares this mutator to accept a new batch.The
lockmust be acquired before calling this method. Cancels any pendingperiodicFlushTaskto avoid a redundant flush for the data we are about to send. Swaps the sharedmutationsandfutureslists into a returnedAsyncBufferedMutatorImpl.Batch, replaces them with fresh lists, and resetsbufferedSizeto zero.If there is nothing buffered, returns
nullso callers can skip sending work.Protected for being overridden in tests.
- Returns:
- a
AsyncBufferedMutatorImpl.Batchcontaining drained mutations and futures, ornullif empty
-
sendBatch
Sends a previously drainedAsyncBufferedMutatorImpl.Batchand wires the user-visible completion futures to the underlying results returned byAsyncTable.batch(List).Preserves the one-to-one, in-order mapping between mutations and their corresponding futures.
- Parameters:
batch- the drained batch to send; may benull
-
mutate
Description copied from interface:AsyncBufferedMutatorSend 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, the implementations are free to break it up according to the write buffer capacity.- Specified by:
mutatein interfaceAsyncBufferedMutator- Parameters:
mutations- The data to send.
-
flushOrClose
-
flush
Description copied from interface:AsyncBufferedMutatorExecutes all the buffered, asynchronous operations.- Specified by:
flushin interfaceAsyncBufferedMutator
-
close
Description copied from interface:AsyncBufferedMutatorPerforms aAsyncBufferedMutator.flush()and releases any resources held.- Specified by:
closein interfaceAsyncBufferedMutator- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
getWriteBufferSize
Description copied from interface:AsyncBufferedMutatorReturns the maximum size in bytes of the write buffer.The default value comes from the configuration parameter
hbase.client.write.buffer.- Specified by:
getWriteBufferSizein interfaceAsyncBufferedMutator- Returns:
- The size of the write buffer in bytes.
-
getPeriodicalFlushTimeout
Description copied from interface:AsyncBufferedMutatorReturns the periodical flush interval, 0 means disabled.- Specified by:
getPeriodicalFlushTimeoutin interfaceAsyncBufferedMutator
-
getMaxMutations
Description copied from interface:AsyncBufferedMutatorThe maximum number of mutations that this buffered mutator will buffer before flushing them- Specified by:
getMaxMutationsin interfaceAsyncBufferedMutator
-
getRequestAttributes
Description copied from interface:AsyncBufferedMutatorReturns the rpc request attributes.- Specified by:
getRequestAttributesin interfaceAsyncBufferedMutator
-