private static class EventLogFactory.EventLogIteratorImpl extends Object implements EventLogIterator
Modifier and Type | Field and Description |
---|---|
private EventLog |
log
The associated EventLog for this iterator
|
private Uuid |
uuid
The associated Uuid for this iterator
|
Constructor and Description |
---|
EventLogFactory.EventLogIteratorImpl(Uuid id)
Simple constructor that assigns the Uuid
field to the appropriate internal field and creates
a transient event log.
|
EventLogFactory.EventLogIteratorImpl(Uuid id,
File logPath)
Simple constructor that assigns the Uuid
field to the appropriate internal field and creates
a persistent EventLog object using the provided
File argument.
|
Modifier and Type | Method and Description |
---|---|
void |
add(RemoteEvent evt)
Store the given RemoteEvent event.
|
void |
destroy()
Destroy the collection of stored events.
|
boolean |
hasNext()
Return true if there are any events in the collection and
false otherwise.
|
void |
init() |
void |
moveAhead(Object cookie)
Effectively removes the last set of read events from the log.
|
RemoteEvent |
next()
Return the next event in the collection.
|
RemoteEventData[] |
readAhead(int maxEvents)
Return an array of RemoteEventData with a limit of
maxEvents elements.
|
void |
remove()
Remove the event at the iterator's current cursor position.
|
private final Uuid uuid
private EventLog log
EventLogFactory.EventLogIteratorImpl(Uuid id, File logPath)
EventLogFactory.EventLogIteratorImpl(Uuid id)
public void init() throws IOException
IOException
public void add(RemoteEvent evt) throws IOException, IllegalArgumentException
EventLogIterator
add
in interface EventLogIterator
IOException
- if an I/O errors occursIllegalArgumentException
public boolean hasNext() throws IOException
EventLogIterator
hasNext
in interface EventLogIterator
IOException
- if an I/O errors occurspublic RemoteEvent next() throws IOException, ClassNotFoundException, NoSuchElementException
EventLogIterator
next
in interface EventLogIterator
IOException
- if an I/O errors occursClassNotFoundException
- if there was a problem deserializing
the stored RemoteEvent
NoSuchElementException
- if there are no available
RemoteEvent
spublic void remove() throws IOException, IllegalStateException
EventLogIterator
remove
in interface EventLogIterator
IOException
- if an I/O errors occursIllegalStateException
public RemoteEventData[] readAhead(int maxEvents) throws IOException, ClassNotFoundException
EventLogIterator
readAhead
in interface EventLogIterator
maxEvents
- maximum number of events/elements to returnIOException
- if an I/O error occursClassNotFoundException
- if a class for the serialized
object could not be foundpublic void moveAhead(Object cookie) throws IOException
EventLogIterator
moveAhead
in interface EventLogIterator
cookie
- object associated with event to read past. This object
should have been obtained from a previous call to readAhead
on this event log.IOException
- if there was a problem advancing the read pointer.public void destroy() throws IOException
EventLogIterator
destroy
in interface EventLogIterator
IOException
- if an I/O errors occursCopyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.