Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ReadTracking interface and JTransaction.weakConsistency().
- Loading branch information
1 parent
24e2152
commit 3b5579f
Showing
6 changed files
with
120 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
permazen-kv/src/main/java/io/permazen/kv/mvcc/ReadTracking.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
/* | ||
* Copyright (C) 2015 Archie L. Cobbs. All rights reserved. | ||
*/ | ||
|
||
package io.permazen.kv.mvcc; | ||
|
||
import io.permazen.kv.KVStore; | ||
|
||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
/** | ||
* Implemented by {@link KVStore}'s that are capable of tracking which keys have been read. | ||
* Typically this is done to support MVCC conflict detection. | ||
* | ||
* <p> | ||
* Read tracking includes all keys explicitly or implicitly read by calls to | ||
* {@link #get get()}, {@link #getAtLeast getAtLeast()}, {@link #getAtMost getAtMost()}, and {@link #getRange getRange()}. | ||
* | ||
* <p> | ||
* When reads are being tracked, tracking may temporarily be paused and later resumed via {@link #getReadTrackingControl}. | ||
*/ | ||
public interface ReadTracking extends KVStore { | ||
|
||
/** | ||
* Get an {@link AtomicBoolean} that can be used to temporarily pause/un-pause read tracking. | ||
* | ||
* <p> | ||
* By default the returned control is true. While set to false, read tracking is disabled; setting back | ||
* to true re-enables read tracking. | ||
* | ||
* <p> | ||
* For re-entrance safety, this should be done as follows: | ||
* <blockquote><code> | ||
* final boolean previous = kv.getReadTrackingControl().getAndSet(false); | ||
* try { | ||
* // do something without tracking reads... | ||
* } finally { | ||
* kv.getReadTrackingControl().set(previous); | ||
* } | ||
* </code></blockquote> | ||
* | ||
* @return control that enables/disables read tracking | ||
*/ | ||
AtomicBoolean getReadTrackingControl(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters