Package com.usatiuk.kleppmanntree
Interface LogInterface<TimestampT extends Comparable<TimestampT>,PeerIdT extends Comparable<PeerIdT>,MetaT extends NodeMeta,NodeIdT>
- Type Parameters:
TimestampT
- the type of the timestampPeerIdT
- the type of the peer IDMetaT
- the type of the node metadataNodeIdT
- the type of the node ID
public interface LogInterface<TimestampT extends Comparable<TimestampT>,PeerIdT extends Comparable<PeerIdT>,MetaT extends NodeMeta,NodeIdT>
LogInterface is an interface that allows accessing the log of operations
-
Method Summary
Modifier and TypeMethodDescriptionboolean
containsKey
(CombinedTimestamp<TimestampT, PeerIdT> timestamp) Checks if the log contains the given timestamp.List
<org.apache.commons.lang3.tuple.Pair<CombinedTimestamp<TimestampT, PeerIdT>, LogRecord<TimestampT, PeerIdT, MetaT, NodeIdT>>> getAll()
Return all the log entriesboolean
isEmpty()
Checks if the log is empty.List
<org.apache.commons.lang3.tuple.Pair<CombinedTimestamp<TimestampT, PeerIdT>, LogRecord<TimestampT, PeerIdT, MetaT, NodeIdT>>> newestSlice
(CombinedTimestamp<TimestampT, PeerIdT> since, boolean inclusive) Return all log entries that are newer than the given timestamp.org.apache.commons.lang3.tuple.Pair
<CombinedTimestamp<TimestampT, PeerIdT>, LogRecord<TimestampT, PeerIdT, MetaT, NodeIdT>> Peek the newest log entry.org.apache.commons.lang3.tuple.Pair
<CombinedTimestamp<TimestampT, PeerIdT>, LogRecord<TimestampT, PeerIdT, MetaT, NodeIdT>> Peek the oldest log entry.void
put
(CombinedTimestamp<TimestampT, PeerIdT> timestamp, LogRecord<TimestampT, PeerIdT, MetaT, NodeIdT> record) Add a log entry to the log.void
replace
(CombinedTimestamp<TimestampT, PeerIdT> timestamp, LogRecord<TimestampT, PeerIdT, MetaT, NodeIdT> record) Replace a log entry in the log.long
size()
Get the size of the log.org.apache.commons.lang3.tuple.Pair
<CombinedTimestamp<TimestampT, PeerIdT>, LogRecord<TimestampT, PeerIdT, MetaT, NodeIdT>> Take the oldest log entry.
-
Method Details
-
peekOldest
org.apache.commons.lang3.tuple.Pair<CombinedTimestamp<TimestampT,PeerIdT>, peekOldest()LogRecord<TimestampT, PeerIdT, MetaT, NodeIdT>> Peek the oldest log entry.- Returns:
- the oldest log entry
-
takeOldest
org.apache.commons.lang3.tuple.Pair<CombinedTimestamp<TimestampT,PeerIdT>, takeOldest()LogRecord<TimestampT, PeerIdT, MetaT, NodeIdT>> Take the oldest log entry.- Returns:
- the oldest log entry
-
peekNewest
org.apache.commons.lang3.tuple.Pair<CombinedTimestamp<TimestampT,PeerIdT>, peekNewest()LogRecord<TimestampT, PeerIdT, MetaT, NodeIdT>> Peek the newest log entry.- Returns:
- the newest log entry
-
newestSlice
List<org.apache.commons.lang3.tuple.Pair<CombinedTimestamp<TimestampT,PeerIdT>, newestSliceLogRecord<TimestampT, PeerIdT, MetaT, NodeIdT>>> (CombinedTimestamp<TimestampT, PeerIdT> since, boolean inclusive) Return all log entries that are newer than the given timestamp.- Parameters:
since
- the timestamp to compare withinclusive
- if true, include the log entry with the given timestamp- Returns:
- a list of log entries that are newer than the given timestamp
-
getAll
List<org.apache.commons.lang3.tuple.Pair<CombinedTimestamp<TimestampT,PeerIdT>, getAll()LogRecord<TimestampT, PeerIdT, MetaT, NodeIdT>>> Return all the log entries- Returns:
- a list of all log entries
-
isEmpty
boolean isEmpty()Checks if the log is empty.- Returns:
- true if the log is empty, false otherwise
-
containsKey
Checks if the log contains the given timestamp.- Parameters:
timestamp
- the timestamp to check- Returns:
- true if the log contains the given timestamp, false otherwise
-
size
long size()Get the size of the log.- Returns:
- the size of the log (number of entries)
-
put
void put(CombinedTimestamp<TimestampT, PeerIdT> timestamp, LogRecord<TimestampT, PeerIdT, MetaT, NodeIdT> record) Add a log entry to the log.- Parameters:
timestamp
- the timestamp of the log entryrecord
- the log entry- Throws:
IllegalStateException
- if the log entry already exists
-
replace
void replace(CombinedTimestamp<TimestampT, PeerIdT> timestamp, LogRecord<TimestampT, PeerIdT, MetaT, NodeIdT> record) Replace a log entry in the log.- Parameters:
timestamp
- the timestamp of the log entryrecord
- the log entry
-