Interface ReaderGroup

    • Method Detail

      • getMetrics

        ReaderGroupMetrics getMetrics()
        Returns metrics for this reader group.
        Returns:
        a ReaderGroupMetrics object for this reader group.
      • getScope

        java.lang.String getScope()
        Returns the scope of the stream which the group is associated with.
        Returns:
        A scope string
      • cancelOutstandingCheckpoints

        void cancelOutstandingCheckpoints()
        Cancels the outStanding checkpoints.
      • getGroupName

        java.lang.String getGroupName()
        Returns the name of the group.
        Returns:
        Reader group name
      • initiateCheckpoint

        java.util.concurrent.CompletableFuture<Checkpoint> initiateCheckpoint​(java.lang.String checkpointName,
                                                                              java.util.concurrent.ScheduledExecutorService backgroundExecutor)
        Initiate a checkpoint. This causes all readers in the group to receive a special 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 and resumed reading the future will return a Checkpoint object which contains the StreamCut of the reader group at the time they received the checkpoint. This can be used to reset the group to this point in the stream by calling resetReaderGroup(ReaderGroupConfig) 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 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.
        Parameters:
        checkpointName - The name of the checkpoint (For identification purposes)
        backgroundExecutor - A threadPool that can be used to poll for the completion of the checkpoint.
        Returns:
        A future Checkpoint object that can be used to restore the reader group to this position.
      • initiateCheckpoint

        java.util.concurrent.CompletableFuture<Checkpoint> initiateCheckpoint​(java.lang.String checkpointName)
        Initiate a checkpoint. This causes all readers in the group to receive a special 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 and resumed reading the future will return a Checkpoint object which contains the StreamCut of the reader group at the time they received the checkpoint. This can be used to reset the group to this point in the stream by calling resetReaderGroup(ReaderGroupConfig) 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 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. Client internal thread pool executor is used to poll for the completion of the checkpoint
        Parameters:
        checkpointName - The name of the checkpoint (For identification purposes)
        Returns:
        A future Checkpoint object that can be used to restore the reader group to this position.
      • resetReaderGroup

        void resetReaderGroup()
        Reset a reader group to successfully completed last checkpoint. Successfully completed last checkpoint can be the last checkpoint created when automatic checkpointing is enabled as a part of ReaderGroupConfig or manually created by calling initiateCheckpoint(String, ScheduledExecutorService) If there is no successfully completed Last checkpoint present then this call reset the reader group to the original streamcut from `ReaderGroupConfig`.
      • readerOffline

        void readerOffline​(java.lang.String readerId,
                           Position lastPosition)
        Invoked when a reader that was added to the group is no longer consuming events. This will cause the events that were going to that reader to be redistributed among the other readers. Events after the lastPosition provided will be (re)read by other readers in the ReaderGroup. Note that this method is automatically invoked by EventStreamReader.close()
        Parameters:
        readerId - The id of the reader that is offline.
        lastPosition - The position of the last event that was successfully processed by the reader.
      • getStreamNames

        java.util.Set<java.lang.String> getStreamNames()
        Returns the set of scoped stream names which was used to configure this group.
        Returns:
        Set of streams for this group.
      • getStreamCuts

        java.util.Map<Stream,​StreamCut> getStreamCuts()
        Returns a StreamCut for each stream that this reader group is reading from. The stream cut corresponds to the last checkpointed read offsets of the readers, and it can be used by the application as reference to such a position. A more precise StreamCut, with the latest read offsets can be obtained using generateStreamCuts(ScheduledExecutorService) API.
        Returns:
        Map of streams that this group is reading from to the corresponding cuts.
      • getReaderSegmentDistribution

        ReaderSegmentDistribution getReaderSegmentDistribution()
        Returns current distribution of number of segments assigned to each reader in the reader group.
        Returns:
        an instance of ReaderSegmentDistribution which describes the distribution of segments to readers including unassigned segments.
      • close

        void close()
        Closes the reader group, freeing any resources associated with it.
        Specified by:
        close in interface java.lang.AutoCloseable