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
Nested ClassesModifier and TypeClassDescriptionstatic classWrite number and whether write has completed given out at start of a write transaction. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longprivate static final org.slf4j.Loggerstatic final longRepresents no value, or not set.(package private) final AtomicLongprivate static final longprivate final Object(package private) final String(package private) final AtomicLongprivate final LinkedList<MultiVersionConcurrencyControl.WriteEntry> -
Constructor Summary
ConstructorsConstructorDescriptionMultiVersionConcurrencyControl(long startPoint) Construct and set read point.MultiVersionConcurrencyControl(String regionName) -
Method Summary
Modifier and TypeMethodDescriptionvoidadvanceTo(long newStartPoint) Step the MVCC forward on to a new read/write basis.voidawait()Wait until the read point catches up to the write point; i.e.begin()Callbegin(Runnable)with an emptyRunnable.Start a write transaction.booleancomplete(MultiVersionConcurrencyControl.WriteEntry writeEntry) Mark theMultiVersionConcurrencyControl.WriteEntryas complete and advance the read point as much as possible.voidComplete aMultiVersionConcurrencyControl.WriteEntrythat was created bybegin()then wait until the read point catches up to our write.longlongtoString()(package private) booleantryAdvanceTo(long newStartPoint, long expected) Step the MVCC forward on to a new read/write basis.(package private) voidWait 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
expectedis not equal to the currentreadPointor ifstartPointis less than currentreadPoint
-
begin
Callbegin(Runnable)with an emptyRunnable. -
begin
Start a write transaction. Create a newMultiVersionConcurrencyControl.WriteEntrywith 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
actionwill 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.WriteEntrythat 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.WriteEntryas 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
-