T
- The type of events being sent through this stream.public interface EventStreamReader<T>
extends java.lang.AutoCloseable
This class is safe to use across threads, but doing so will not increase performance.
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the reader.
|
T |
fetchEvent(EventPointer pointer)
Re-read an event that was previously read, by passing the pointer returned from
EventRead.getEventPointer() . |
ReaderConfig |
getConfig()
Gets the configuration that this reader was created with.
|
EventRead<T> |
readNextEvent(long timeout)
Gets the next event in the stream.
|
EventRead<T> readNextEvent(long timeout) throws ReinitializationRequiredException, TruncatedDataException
EventRead.getEvent()
. (As well as for most other fields)
An EventRead with null for EventRead.getEvent()
is returned when the Reader has read all events up to the
configured end StreamCut
specified using ReaderGroupConfig
.timeout
- An upper bound on how long the call may block before returning null.EventRead
, which contains the next event in the stream. In the case the timeout
is reached, EventRead.getEvent()
returns null.ReinitializationRequiredException
- Is thrown in the event that
ReaderGroup.resetReadersToCheckpoint(Checkpoint)
or
ReaderGroup.resetReaderGroup(ReaderGroupConfig)
was called
which requires readers to be reinitialized.TruncatedDataException
- if the data that would be read next has been truncated away
and can no longer be read. (If following this readNextEvent is called again it
will resume from the next available event.)ReaderConfig getConfig()
T fetchEvent(EventPointer pointer) throws io.pravega.client.segment.impl.NoSuchEventException
EventRead.getEventPointer()
.
This does not affect the current position of the reader.
This is a blocking call. Passing invalid offsets has undefined behavior.
pointer
- The pointer object to enable a random read of the event.io.pravega.client.segment.impl.NoSuchEventException
- Reader was not able to fetch the event.void close()
ReaderGroup.readerOffline(String, Position)
close
in interface java.lang.AutoCloseable
AutoCloseable.close()