class TransientEventLog extends Object implements EventLog
| Modifier and Type | Class and Description |
|---|---|
private static class |
TransientEventLog.RemoteEventHolder
Helper class used to hold a remote event and a sequence id.
|
| Modifier and Type | Field and Description |
|---|---|
private boolean |
closed
Flag that is used to determine whether or not this object
has been closed.
|
private List |
entries
The associated, non-persistent storage for events
|
private java.util.concurrent.atomic.AtomicLong |
eventCounter
Counter used to produce event ids.
|
private boolean |
initialized
Flag that is used to determine whether or not this object
has been initialized.
|
private static Logger |
persistenceLogger
Logger used for persistence-related debugging messages
|
private Uuid |
uuid
The associated Uuid for this EventLog.
|
| Constructor and Description |
|---|
TransientEventLog(Uuid uuid)
Simple constructor that takes a Uuid argument.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(RemoteEvent event)
Writes the given RemoteEvent to the underlying
storage mechanism, if possible.
|
void |
close()
Close this log and release any associated runtime resources.
|
void |
delete()
Delete associated storage resources for this log.
|
void |
init()
Initializes the state of this EventLog object.
|
boolean |
isEmpty()
Returns true if this log contains no events and
false otherwise.
|
void |
moveAhead(Object cookie)
Effectively removes the last set of read events from the log.
|
RemoteEvent |
next()
Return the next RemoteEvent to be read.
|
private void |
printControlData(Logger logger,
String msg)
Output state information to the given Logger.
|
RemoteEventData[] |
readAhead(int maxEvents)
Return an array of RemoteEventData with a limit of
maxEvents elements.
|
void |
remove()
Effectively removes the last read event from the log.
|
private void |
stateCheck()
Asserts that the log is in a valid state.
|
private static final Logger persistenceLogger
private final Uuid uuid
private final List entries
private volatile boolean closed
private volatile boolean initialized
private java.util.concurrent.atomic.AtomicLong eventCounter
TransientEventLog(Uuid uuid)
IllegalArgumentException - if the argument is nullpublic void init()
throws IOException
EventLoginit in interface EventLogIOException - if an I/O error occursprivate void stateCheck()
throws IOException
IOException - if the log is in an invalid statepublic void add(RemoteEvent event) throws IOException
EventLogadd in interface EventLogIOException - if an I/O error occurspublic RemoteEvent next() throws IOException
EventLognext in interface EventLogIOException - if an I/O error occurspublic RemoteEventData[] readAhead(int maxEvents) throws IOException
EventLogreadAhead in interface EventLogmaxEvents - maximum number of events/elements to returnIOException - if an I/O error occurspublic boolean isEmpty()
throws IOException
EventLogisEmpty in interface EventLogIOExceptionpublic void remove()
throws IOException
EventLogremove in interface EventLogIOExceptionpublic void moveAhead(Object cookie) throws IOException
EventLogmoveAhead in interface EventLogcookie - object associated with event to read past. This object
should have been obtained from a call to
getCookie() on a RemoteEventData object
obtained from a call to readAhead on this event log.IOException - if there was a problem advancing the read pointer.public void close()
throws IOException
EventLogclose in interface EventLogIOExceptionpublic void delete()
throws IOException
EventLogdelete in interface EventLogIOException - if an IO error occursCopyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.