public interface ReaderGroup extends ReaderGroupNotificationListener, java.lang.AutoCloseable
ClientFactory.createReader(String, String, Serializer, ReaderConfig)
and are removed by
calling readerOffline(String, Position)
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the reader group, freeing any resources associated with it.
|
java.lang.String |
getGroupName()
Returns the name of the group.
|
ReaderGroupMetrics |
getMetrics()
Returns metrics for this reader group.
|
java.util.Set<java.lang.String> |
getOnlineReaders()
Returns a set of readerIds for the readers that are considered to be online by the group.
|
java.lang.String |
getScope()
Returns the scope of the stream which the group is associated with.
|
java.util.Map<Stream,StreamCut> |
getStreamCuts()
Returns a stream cut for each stream that this reader group is reading from.
|
java.util.Set<java.lang.String> |
getStreamNames()
Returns the set of stream names which was used to configure this group.
|
java.util.concurrent.CompletableFuture<Checkpoint> |
initiateCheckpoint(java.lang.String checkpointName,
java.util.concurrent.ScheduledExecutorService backgroundExecutor)
Initiate a checkpoint.
|
void |
readerOffline(java.lang.String readerId,
Position lastPosition)
Invoked when a reader that was added to the group is no longer consuming events.
|
void |
resetReaderGroup(ReaderGroupConfig config)
Reset a reader group with the provided
ReaderGroupConfig . |
void |
resetReadersToCheckpoint(Checkpoint checkpoint)
Deprecated.
Use
resetReaderGroup(ReaderGroupConfig) to reset readers to a given Checkpoint. |
getEndOfDataNotifier, getSegmentNotifier
ReaderGroupMetrics getMetrics()
java.lang.String getScope()
java.lang.String getGroupName()
java.util.concurrent.CompletableFuture<Checkpoint> initiateCheckpoint(java.lang.String checkpointName, java.util.concurrent.ScheduledExecutorService backgroundExecutor)
EventRead
that contains the provided checkpoint name. This can be used to provide an
indication to them that they should persist their state. Once all of the readers have
received the notification, a Checkpoint
object will be returned. This can be used to
reset the group to this point in the stream by calling
resetReadersToCheckpoint(Checkpoint)
if the checkpoint fails or the result cannot be
obtained an exception will be set on the future.
This method can be called and a new checkpoint can be initiated while another is still in
progress if they have different names. If this method is is called again before the
checkpoint has completed with the same name the future returned to the second caller will
refer to the same checkpoint object as the first.checkpointName
- The name of the checkpoint (For identification purposes)backgroundExecutor
- A threadPool that can be used to poll for the completion of the
checkpoint.@Deprecated void resetReadersToCheckpoint(Checkpoint checkpoint)
resetReaderGroup(ReaderGroupConfig)
to reset readers to a given Checkpoint.ReinitializationRequiredException
and when they rejoin the
group they will resume from the position the provided checkpoint was taken. (The mapping of
segments to readers may not be the same, and the current readers need not be the same ones as
existed at the time of the checkpoint.)checkpoint
- The checkpoint to restore to.void resetReaderGroup(ReaderGroupConfig config)
ReaderGroupConfig
.
- The stream(s) that are part of the reader group
can be specified using ReaderGroupConfig.ReaderGroupConfigBuilder.stream(String)
,
ReaderGroupConfig.ReaderGroupConfigBuilder.stream(String, StreamCut)
and
ReaderGroupConfig.ReaderGroupConfigBuilder.stream(String, StreamCut, StreamCut)
.
- To reset a reader group to a given checkpoint use
ReaderGroupConfig.ReaderGroupConfigBuilder.startFromCheckpoint(Checkpoint)
api.
- To reset a reader group to a given StreamCut use
ReaderGroupConfig.ReaderGroupConfigBuilder.startFromStreamCuts(Map)
.
ClientFactory.createReader(String, String, Serializer, ReaderConfig)
.
If they continue to read events they will eventually encounter an ReinitializationRequiredException
.config
- The new configuration for the ReaderGroup.void readerOffline(java.lang.String readerId, Position lastPosition)
ReaderGroup
.
Note that this method is automatically invoked by EventStreamReader.close()
readerId
- The id of the reader that is offline.lastPosition
- The position of the last event that was successfully processed by the
reader.java.util.Set<java.lang.String> getOnlineReaders()
ClientFactory.createReader(String, String, Serializer, ReaderConfig)
was called but
readerOffline(String, Position)
was not called subsequently.java.util.Set<java.lang.String> getStreamNames()
java.util.Map<Stream,StreamCut> getStreamCuts()
void close()
close
in interface java.lang.AutoCloseable