Package io.pravega.client
Interface BatchClientFactory
-
- All Superinterfaces:
java.lang.AutoCloseable
@Beta public interface BatchClientFactory extends java.lang.AutoCloseable
Please note this is an experimental API. Used to get metadata about and read from an existing streams. All events written to a stream will be visible to SegmentIterators Events within a segment are strictly ordered, but as this API allows for reading from multiple segments in parallel without adhering to time ordering. This allows for even greater parallelization at the expense of the ordering guarantees provided byEventStreamReader
.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
Closes the client factory.StreamCut
getNextStreamCut(StreamCut startingStreamCut, long approxDistanceToNextOffset)
Provides a streamcut approximately the requested distance after the starting streamcut.java.util.List<SegmentRange>
getSegmentRangeBetweenStreamCuts(StreamCut startStreamCut, StreamCut endStreamCut)
Provides a list of SegmentRange in between a start and end streamCut.StreamSegmentsIterator
getSegments(Stream stream, StreamCut fromStreamCut, StreamCut toStreamCut)
Provides a list of segments for a given stream between fromStreamCut and toStreamCut.<T> SegmentIterator<T>
readSegment(SegmentRange segment, Serializer<T> deserializer)
Provides a SegmentIterator to read the events in the requested segment starting from the beginning of the segment and ending at the current end of the segment.static BatchClientFactory
withScope(java.lang.String scope, ClientConfig config)
Creates a new instance of BatchClientFactory.
-
-
-
Method Detail
-
withScope
static BatchClientFactory withScope(java.lang.String scope, ClientConfig config)
Creates a new instance of BatchClientFactory.- Parameters:
scope
- The scope of the stream.config
- Configuration for the client.- Returns:
- Instance of BatchClientFactory implementation.
-
getSegments
StreamSegmentsIterator getSegments(Stream stream, StreamCut fromStreamCut, StreamCut toStreamCut)
Provides a list of segments for a given stream between fromStreamCut and toStreamCut. Passing StreamCut.UNBOUNDED or null to fromStreamCut and toStreamCut will result in using the current start of stream and the current end of stream respectively. Note: In case of stream truncation:- Passing a null to fromStreamCut will result in using the current start of the Stream post truncation.
- Passing a fromStreamCut which points to the truncated stream will result in a
NoSuchSegmentException
while iterating over SegmentRange iterator obtained viaStreamSegmentsIterator.getIterator()
- Parameters:
stream
- the stream.fromStreamCut
- starting stream cut.toStreamCut
- end stream cut.- Returns:
- Segment information between the two stream cuts.
-
readSegment
<T> SegmentIterator<T> readSegment(SegmentRange segment, Serializer<T> deserializer)
Provides a SegmentIterator to read the events in the requested segment starting from the beginning of the segment and ending at the current end of the segment.- Type Parameters:
T
- The type of events written to the segment.- Parameters:
segment
- The segment to read fromdeserializer
- A deserializer to be used to parse events- Returns:
- A SegmentIterator over the requested segment
-
close
void close()
Closes the client factory. This will close any connections created through it.- Specified by:
close
in interfacejava.lang.AutoCloseable
- See Also:
AutoCloseable.close()
-
getSegmentRangeBetweenStreamCuts
java.util.List<SegmentRange> getSegmentRangeBetweenStreamCuts(StreamCut startStreamCut, StreamCut endStreamCut)
Provides a list of SegmentRange in between a start and end streamCut.- Parameters:
startStreamCut
- start streamCut.endStreamCut
- end streamCut.- Returns:
- A list of segment range in between a start and end stream cut.
-
getNextStreamCut
StreamCut getNextStreamCut(StreamCut startingStreamCut, long approxDistanceToNextOffset) throws io.pravega.client.segment.impl.SegmentTruncatedException
Provides a streamcut approximately the requested distance after the starting streamcut. The returned stream cut will not 'skip over' scaling events. So all the segments in the returned stream cut will either be in the starting stream cut or be immediate successors to those segments. (This is so that if this method is called in a loop and all the data between the starting and returned stream cut is read before next invocation, the data will be read in order)- Parameters:
startingStreamCut
- Starting streamcutapproxDistanceToNextOffset
- approx distance to nextoffset in bytes- Returns:
- A streamcut after the apporoximate distance from the startingStreamCut.
- Throws:
io.pravega.client.segment.impl.SegmentTruncatedException
- If the data at the starting streamcut has been truncated away and can no longer be read. (In such a case it may be best to restart reading fromStreamManager.fetchStreamInfo(String, String)
'sStreamInfo.getHeadStreamCut()
-
-