Class MultiVersionConcurrencyControl
java.lang.Object
org.apache.hadoop.hbase.regionserver.MultiVersionConcurrencyControl
Manages the read/write consistency. This provides an interface for readers to determine what
entries to ignore, and a mechanism for writers to obtain new write numbers, then "commit" the new
writes for readers to read (thus forming atomic transactions).
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Write number and whether write has completed given out at start of a write transaction. -
Field Summary
Modifier and TypeFieldDescriptionstatic final long
private static final org.slf4j.Logger
static final long
Represents no value, or not set.(package private) final AtomicLong
private static final long
private final Object
(package private) final String
(package private) final AtomicLong
private final LinkedList<MultiVersionConcurrencyControl.WriteEntry>
-
Constructor Summary
ConstructorDescriptionMultiVersionConcurrencyControl
(long startPoint) Construct and set read point.MultiVersionConcurrencyControl
(String regionName) -
Method Summary
Modifier and TypeMethodDescriptionvoid
advanceTo
(long newStartPoint) Step the MVCC forward on to a new read/write basis.void
await()
Wait until the read point catches up to the write point; i.e.begin()
Callbegin(Runnable)
with an emptyRunnable
.Start a write transaction.boolean
complete
(MultiVersionConcurrencyControl.WriteEntry writeEntry) Mark theMultiVersionConcurrencyControl.WriteEntry
as complete and advance the read point as much as possible.void
Complete aMultiVersionConcurrencyControl.WriteEntry
that was created bybegin()
then wait until the read point catches up to our write.long
long
toString()
(package private) boolean
tryAdvanceTo
(long newStartPoint, long expected) Step the MVCC forward on to a new read/write basis.(package private) void
Wait for the global readPoint to advance up to the passed in write entry number.
-
Field Details
-
LOG
-
READPOINT_ADVANCE_WAIT_TIME
- See Also:
-
regionName
-
readPoint
-
writePoint
-
readWaiters
-
NONE
Represents no value, or not set.- See Also:
-
writeQueue
-
FIXED_SIZE
-
-
Constructor Details
-
MultiVersionConcurrencyControl
public MultiVersionConcurrencyControl() -
MultiVersionConcurrencyControl
-
MultiVersionConcurrencyControl
Construct and set read point. Write point is uninitialized.
-
-
Method Details
-
advanceTo
Step the MVCC forward on to a new read/write basis. -
tryAdvanceTo
Step the MVCC forward on to a new read/write basis.- Parameters:
newStartPoint
- Point to move read and write points to.expected
- If not -1 (#NONE)- Returns:
- Returns false if
expected
is not equal to the currentreadPoint
or ifstartPoint
is less than currentreadPoint
-
begin
Callbegin(Runnable)
with an emptyRunnable
. -
begin
Start a write transaction. Create a newMultiVersionConcurrencyControl.WriteEntry
with a new write number and add it to our queue of ongoing writes. Return this WriteEntry instance. To complete the write transaction and wait for it to be visible, callcompleteAndWait(WriteEntry)
. If the write failed, callcomplete(WriteEntry)
so we can clean up AFTER removing ALL trace of the failed write transaction.The
action
will be executed under the lock which means it can keep the same order with mvcc. -
await
Wait until the read point catches up to the write point; i.e. wait on all outstanding mvccs to complete. -
completeAndWait
Complete aMultiVersionConcurrencyControl.WriteEntry
that was created bybegin()
then wait until the read point catches up to our write. At the end of this call, the global read point is at least as large as the write point of the passed in WriteEntry. Thus, the write is visible to MVCC readers. -
complete
Mark theMultiVersionConcurrencyControl.WriteEntry
as complete and advance the read point as much as possible. Call this even if the write has FAILED (AFTER backing out the write transaction changes completely) so we can clean up the outstanding transaction. How much is the read point advanced? Let S be the set of all write numbers that are completed. Set the read point to the highest numbered write of S.- Returns:
- true if e is visible to MVCC readers (that is, readpoint >= e.writeNumber)
-
waitForRead
Wait for the global readPoint to advance up to the passed in write entry number. -
toString
-
getReadPoint
-
getWritePoint
-