Package io.pravega.client.stream.impl
Class EventStreamReaderImpl<Type>
- java.lang.Object
-
- io.pravega.client.stream.impl.EventStreamReaderImpl<Type>
-
- All Implemented Interfaces:
EventStreamReader<Type>,java.lang.AutoCloseable
public class EventStreamReaderImpl<Type> extends java.lang.Object implements EventStreamReader<Type>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the reader.voidcloseAt(Position position)Close the reader at a specific position.TypefetchEvent(EventPointer pointer)Re-read an event that was previously read, by passing the pointer returned fromEventRead.getEventPointer().ReaderConfiggetConfig()Gets the configuration that this reader was created with.TimeWindowgetCurrentTimeWindow(Stream stream)Returns a window which represents the range of time that this reader is currently reading as provided by writers via theEventStreamWriter.noteTime(long)API.EventRead<Type>readNextEvent(long timeoutMillis)Gets the next event in the stream.java.lang.StringtoString()
-
-
-
Method Detail
-
readNextEvent
public EventRead<Type> readNextEvent(long timeoutMillis) throws ReinitializationRequiredException, TruncatedDataException
Description copied from interface:EventStreamReaderGets the next event in the stream. If there are no events currently available this will block up for timeoutMillis waiting for them to arrive. If none do, an EventRead will be returned with null forEventRead.getEvent(). (As well as for most other fields) An EventRead with null forEventRead.getEvent()is returned when the Reader has read all events up to the configured endStreamCutspecified usingReaderGroupConfig.Note: An EventRead with null for
EventRead.getEvent()is returned whenEventRead.isCheckpoint()is true. A null can also be returned due to delays in the Pravega cluster.- Specified by:
readNextEventin interfaceEventStreamReader<Type>- Parameters:
timeoutMillis- An upper bound on how long the call may block before returning null.- Returns:
- An instance of
EventRead, which contains the next event in the stream. In the case the timeoutMillis is reached,EventRead.getEvent()returns null. - Throws:
ReinitializationRequiredException- Is thrown in the event thatReaderGroup.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.)
-
getConfig
public ReaderConfig getConfig()
Description copied from interface:EventStreamReaderGets the configuration that this reader was created with.- Specified by:
getConfigin interfaceEventStreamReader<Type>- Returns:
- Reader configuration
-
close
public void close()
Description copied from interface:EventStreamReaderClose the reader. No further actions may be performed. If this reader is part of a reader group, this will automatically invokeReaderGroup.readerOffline(String, Position)- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceEventStreamReader<Type>- See Also:
AutoCloseable.close()
-
closeAt
public void closeAt(Position position)
Description copied from interface:EventStreamReaderClose the reader at a specific position. No further actions may be performed. If this reader is part of aReaderGroup, this will automatically invokeReaderGroup.readerOffline(String, Position)with the supplied position.- Specified by:
closeAtin interfaceEventStreamReader<Type>- Parameters:
position-Positionto use while reporting readerOffline on theReaderGroup.
-
fetchEvent
public Type fetchEvent(EventPointer pointer) throws NoSuchEventException
Description copied from interface:EventStreamReaderRe-read an event that was previously read, by passing the pointer returned fromEventRead.getEventPointer(). This does not affect the current position of the reader.This is a blocking call. Passing invalid offsets has undefined behavior.
- Specified by:
fetchEventin interfaceEventStreamReader<Type>- Parameters:
pointer- The pointer object to enable a random read of the event.- Returns:
- The event at the position specified by the provided pointer or null if the event has been deleted.
- Throws:
NoSuchEventException- Reader was not able to fetch the event.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getCurrentTimeWindow
public TimeWindow getCurrentTimeWindow(Stream stream)
Description copied from interface:EventStreamReaderReturns a window which represents the range of time that this reader is currently reading as provided by writers via theEventStreamWriter.noteTime(long)API. If no writers were providing timestamps at the current position in the stream `null` will be returned.- Specified by:
getCurrentTimeWindowin interfaceEventStreamReader<Type>- Parameters:
stream- the stream to obtain a time window for.- Returns:
- A TimeWindow which bounds the current location in the stream, or null if one cannot be established.
-
-