public class SequencerServerCache extends Object
The SequencerServer use its own thread/s. To guarantee correct tx conflict-resolution,
the conflictCache
must be updated
along with maxConflictWildcard
at the same time (atomically) to prevent race condition
when the conflict stream is already evicted from the cache but `maxConflictWildcard` is not updated yet,
which can cause situation when sequencer let the transaction go but the tx has to be cancelled.
SequencerServerCache achieves consistency by using single threaded cache. It's done by following code: `.executor(Runnable::run)`
Modifier and Type | Class and Description |
---|---|
static class |
SequencerServerCache.ConflictTxStream
Contains the conflict hash code for a stream ID and conflict param.
|
Constructor and Description |
---|
SequencerServerCache(long cacheSize)
The cache limited by size.
|
SequencerServerCache(long cacheSize,
com.github.benmanes.caffeine.cache.CacheWriter<SequencerServerCache.ConflictTxStream,Long> writer) |
Modifier and Type | Method and Description |
---|---|
Long |
getIfPresent(SequencerServerCache.ConflictTxStream conflictKey)
Returns the value associated with the
key in this cache,
or null if there is no cached value for the key . |
void |
invalidateAll()
Discard all entries in the cache
|
void |
invalidateUpTo(long trimMark)
Invalidate all records up to a trim mark.
|
void |
put(SequencerServerCache.ConflictTxStream conflictStream,
long newTail)
Put a value in the cache
|
long |
size()
The cache size
|
void |
updateMaxConflictAddress(long newMaxConflictWildcard)
Update max conflict wildcard by a new address
|
public SequencerServerCache(long cacheSize, com.github.benmanes.caffeine.cache.CacheWriter<SequencerServerCache.ConflictTxStream,Long> writer)
public SequencerServerCache(long cacheSize)
cacheSize
- cache sizepublic Long getIfPresent(SequencerServerCache.ConflictTxStream conflictKey)
key
in this cache,
or null
if there is no cached value for the key
.conflictKey
- conflict streampublic void invalidateUpTo(long trimMark)
trimMark
- trim markpublic long size()
public void put(SequencerServerCache.ConflictTxStream conflictStream, long newTail)
conflictStream
- conflict streamnewTail
- global tailpublic void invalidateAll()
public void updateMaxConflictAddress(long newMaxConflictWildcard)
newMaxConflictWildcard
- new conflict wildcardCopyright © 2019 CorfuDB. All rights reserved.