Package com.tangosol.io.journal
Class JournalBinaryStore
- java.lang.Object
-
- com.tangosol.io.journal.JournalBinaryStore
-
- All Implemented Interfaces:
Disposable
,BinaryStore
,BinaryStore.KeySetAware
,BinaryStore.SizeAware
,Journal.JournalConsumer
,AutoCloseable
public class JournalBinaryStore extends Object implements BinaryStore.KeySetAware, Journal.JournalConsumer
A BinaryStore that writes to a Journal.- Since:
- Coherence 3.7
- Author:
- cp 2010-06-10; rhl 2013-01-18
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
JournalBinaryStore.ClearListener
The ClearListener is used to ensure that entries are removed from the journal when the corresponding keys arecleared
from the ticket tree.-
Nested classes/interfaces inherited from interface com.tangosol.io.BinaryStore
BinaryStore.KeySetAware, BinaryStore.SizeAware
-
-
Field Summary
Fields Modifier and Type Field Description protected MultiBinaryLongMap
f_mblm
The MultiBinaryLongMap.protected BinaryLongMap
m_blmTickets
Mapping from Binary keys to journal "tickets".protected AtomicLong
m_cbTotal
Number of bytes in the Journal currently "owned" by this BinaryStore.protected long
m_cEvacuations
The number of evacuations occurred on thisJournal.JournalConsumer
.protected Journal
m_journal
The journal manager for this BinaryStore.
-
Constructor Summary
Constructors Constructor Description JournalBinaryStore(Journal journal)
Construct a JournalBinaryStore.JournalBinaryStore(Journal journal, MultiBinaryLongMap mblm)
Construct a JournalBinaryStore.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected BinaryLongMap
configureTicketTree()
Configure and return the BinaryLongMap to be used to store journal tickets.boolean
containsKey(Binary binKey)
Return true iff this BinaryStore contains a mapping for the specified key.void
dedupe(byte[][] aab)
This method may be invoked by the Journal implementation to request that any immutable byte arrays managed by the consumer be de-duplicated.void
dispose()
Invoked when all resources owned by the implementer can safely be released.void
erase(Binary binKey)
Remove the specified key from the underlying store if present.void
eraseAll()
Remove all data from the underlying store.void
evacuate(long lTicketMask, long lTicketValue)
This method may be invoked by the Journal implementation to request that the consumer evacuate a particular journal file.long
getByteCount()
Calculate the total amount of data currently stored in the journal by this BinaryStore.String
getDescription()
Format a String description of the Consumer.Journal
getJournal()
Obtain the underlying journaling system used by this BinaryStore.int
getKeyCount()
Determine the number of keys currently stored in the journal by this BinaryStore.MultiBinaryLongMap
getMultiBinaryLongMap()
Return theMultiBinaryLongMap
used to store the underlying keys in this KeySetAware BinaryStore.protected BinaryLongMap
getTicketTree()
An internal accessor for the "tree of tickets"; this accessor is used only by client threads, and has a built-in check for if the journal has already been disposed of (which could occur on a different thread).Iterator
keys()
Iterate all keys in the underlying store.Binary
load(Binary binKey)
Return the value associated with the specified key, or null if the key does not have an associated value in the underlying store.int
size()
Determine the number of keys in the BinaryStore.void
store(Binary binKey, Binary binValue)
Store the specified value under the specific key in the underlying store.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.oracle.coherence.common.base.Disposable
close
-
-
-
-
Field Detail
-
m_cEvacuations
protected volatile long m_cEvacuations
The number of evacuations occurred on thisJournal.JournalConsumer
.
-
m_journal
protected Journal m_journal
The journal manager for this BinaryStore.
-
m_blmTickets
protected BinaryLongMap m_blmTickets
Mapping from Binary keys to journal "tickets".
-
f_mblm
protected final MultiBinaryLongMap f_mblm
The MultiBinaryLongMap.
-
m_cbTotal
protected final AtomicLong m_cbTotal
Number of bytes in the Journal currently "owned" by this BinaryStore.
-
-
Constructor Detail
-
JournalBinaryStore
public JournalBinaryStore(Journal journal)
Construct a JournalBinaryStore.- Parameters:
journal
- the Journal to write to and read from
-
JournalBinaryStore
public JournalBinaryStore(Journal journal, MultiBinaryLongMap mblm)
Construct a JournalBinaryStore.- Parameters:
journal
- the Journal to write to and read frommblm
- the MultiBinaryLongMap used to store the keys and tickets
-
-
Method Detail
-
load
public Binary load(Binary binKey)
Return the value associated with the specified key, or null if the key does not have an associated value in the underlying store.- Specified by:
load
in interfaceBinaryStore
- Parameters:
binKey
- key whose associated value is to be returned- Returns:
- the value associated with the specified key, or null if no value is available for that key
-
store
public void store(Binary binKey, Binary binValue)
Store the specified value under the specific key in the underlying store. This method is intended to support both key/value creation and value update for a specific key.- Specified by:
store
in interfaceBinaryStore
- Parameters:
binKey
- key to store the value underbinValue
- value to be stored
-
erase
public void erase(Binary binKey)
Remove the specified key from the underlying store if present.- Specified by:
erase
in interfaceBinaryStore
- Parameters:
binKey
- key whose mapping is to be removed from the map
-
eraseAll
public void eraseAll()
Remove all data from the underlying store.- Specified by:
eraseAll
in interfaceBinaryStore
-
keys
public Iterator keys()
Iterate all keys in the underlying store.- Specified by:
keys
in interfaceBinaryStore
- Returns:
- a read-only iterator of the keys in the underlying store
-
size
public int size()
Determine the number of keys in the BinaryStore.- Specified by:
size
in interfaceBinaryStore.SizeAware
- Returns:
- the number of keys in the BinaryStore
-
containsKey
public boolean containsKey(Binary binKey)
Return true iff this BinaryStore contains a mapping for the specified key.- Specified by:
containsKey
in interfaceBinaryStore.KeySetAware
- Parameters:
binKey
- key whose presence in the BinaryStore is to be tested- Returns:
- true iff this BinaryStore contains a mapping for the specified key
-
getMultiBinaryLongMap
public MultiBinaryLongMap getMultiBinaryLongMap()
Return theMultiBinaryLongMap
used to store the underlying keys in this KeySetAware BinaryStore.- Specified by:
getMultiBinaryLongMap
in interfaceBinaryStore.KeySetAware
- Returns:
- the MultiBinaryLongMap used to store the keys in this BinaryStore
-
evacuate
public void evacuate(long lTicketMask, long lTicketValue)
This method may be invoked by the Journal implementation to request that the consumer evacuate a particular journal file.- Specified by:
evacuate
in interfaceJournal.JournalConsumer
- Parameters:
lTicketMask
- indicates which bits of the tickets to checklTicketValue
- indicates what bit pattern needs to be matched on the tickets in order to select them for evacuation
-
dedupe
public void dedupe(byte[][] aab)
This method may be invoked by the Journal implementation to request that any immutable byte arrays managed by the consumer be de-duplicated.- Specified by:
dedupe
in interfaceJournal.JournalConsumer
- Parameters:
aab
- an array of byte[] objects for intern-ing byte[] references
-
getDescription
public String getDescription()
Format a String description of the Consumer.- Specified by:
getDescription
in interfaceJournal.JournalConsumer
- Returns:
- a comma-delimited key-value description of this object
-
dispose
public void dispose()
Invoked when all resources owned by the implementer can safely be released.Once disposed of the object should no longer be considered to be usable.
Note the Disposable interface is compatible with try-with-resources which will automatically invoke this method.
- Specified by:
dispose
in interfaceDisposable
-
getJournal
public Journal getJournal()
Obtain the underlying journaling system used by this BinaryStore.- Returns:
- the Journal that this JournalBinaryStore uses.
-
getKeyCount
public int getKeyCount()
Determine the number of keys currently stored in the journal by this BinaryStore. Note that this doesn't including data that has been released but whose space has not yet been reclaimed by the journal.- Returns:
- the number of keys in the journal held for this BinaryStore
-
getByteCount
public long getByteCount()
Calculate the total amount of data currently stored in the journal by this BinaryStore. Note that this doesn't including data that has been released but whose space has not yet been reclaimed by the journal.- Returns:
- the number of bytes in the journal used by this BinaryStore
-
getTicketTree
protected BinaryLongMap getTicketTree()
An internal accessor for the "tree of tickets"; this accessor is used only by client threads, and has a built-in check for if the journal has already been disposed of (which could occur on a different thread).- Returns:
- the tree of tickets
-
configureTicketTree
protected BinaryLongMap configureTicketTree()
Configure and return the BinaryLongMap to be used to store journal tickets.- Returns:
- the BinaryLongMap to be used to store journal tickets
-
-