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.
|
void |
closeAt(Position position)
Close the reader at a specific position.
|
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.
|
TimeWindow |
getCurrentTimeWindow(Stream stream)
Returns a window which represents the range of time that this reader is currently reading as
provided by writers via the
EventStreamWriter.noteTime(long) API. |
EventRead<T> |
readNextEvent(long timeoutMillis)
Gets the next event in the stream.
|
TimeWindow getCurrentTimeWindow(Stream stream)
EventStreamWriter.noteTime(long)
API.
If no writers were providing timestamps at the current position in the stream `null` will be returned.stream
- the stream to obtain a time window for.EventRead<T> readNextEvent(long timeoutMillis) 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
.
Note: An EventRead with null for EventRead.getEvent()
is returned when EventRead.isCheckpoint()
is true. A null can also be returned due to delays in the Pravega cluster.
timeoutMillis
- 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 timeoutMillis
is reached, EventRead.getEvent()
returns null.ReinitializationRequiredException
- Is thrown in the event that
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 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.NoSuchEventException
- Reader was not able to fetch the event.void close()
ReaderGroup.readerOffline(String, Position)
close
in interface java.lang.AutoCloseable
AutoCloseable.close()
void closeAt(Position position)
ReaderGroup
, this will automatically invoke ReaderGroup.readerOffline(String, Position)
with
the supplied position.position
- Position
to use while reporting readerOffline on the ReaderGroup
.