@InterfaceAudience.Private public class MultiVersionConcurrencyControl extends Object
Modifier and Type | Class and Description |
---|---|
static class |
MultiVersionConcurrencyControl.WriteEntry
Write number and whether write has completed given out at start of a write transaction.
|
Modifier and Type | Field and Description |
---|---|
static long |
FIXED_SIZE |
static long |
NONE
Represents no value, or not set.
|
Constructor and Description |
---|
MultiVersionConcurrencyControl() |
MultiVersionConcurrencyControl(long startPoint)
Construct and set read point.
|
Modifier and Type | Method and Description |
---|---|
void |
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.
|
MultiVersionConcurrencyControl.WriteEntry |
begin()
Start a write transaction.
|
boolean |
complete(MultiVersionConcurrencyControl.WriteEntry writeEntry)
Mark the
MultiVersionConcurrencyControl.WriteEntry as complete and advance the read point as much as possible. |
void |
completeAndWait(MultiVersionConcurrencyControl.WriteEntry e)
Complete a
MultiVersionConcurrencyControl.WriteEntry that was created by begin() then wait until the
read point catches up to our write. |
long |
getReadPoint() |
long |
getWritePoint() |
String |
toString() |
public static final long NONE
public static final long FIXED_SIZE
public MultiVersionConcurrencyControl()
public MultiVersionConcurrencyControl(long startPoint)
public void advanceTo(long newStartPoint)
newStartPoint
- public MultiVersionConcurrencyControl.WriteEntry begin()
MultiVersionConcurrencyControl.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, call
completeAndWait(WriteEntry)
. If the write failed, call
complete(WriteEntry)
so we can clean up AFTER removing ALL trace of the failed write
transaction.public void await()
public void completeAndWait(MultiVersionConcurrencyControl.WriteEntry e)
MultiVersionConcurrencyControl.WriteEntry
that was created by begin()
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.public boolean complete(MultiVersionConcurrencyControl.WriteEntry writeEntry)
MultiVersionConcurrencyControl.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.writeEntry
- public long getReadPoint()
public long getWritePoint()
Copyright © 2007–2018 The Apache Software Foundation. All rights reserved.