Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
public interface StandbyUpdateListener {

    enum SuspendReason {
        MIGRATED,
        PROMOTED;
    }
    
    /**
     * Method called when Standby Processing starts for a given State Store Partition.
     *
     * @param topicPartition   the TopicPartition of the Standby Task.
     * @param storeName        the name of the store being watched by this Standby Task.
     * @param earliestOffset   the earliest offset available on the Changelog topic.
     * @param startingOffset   the last offset written to the state store as determined from the checkpoint
     * 						   file, or -1 if there is no previous state.
     * @param currentEndOffset the current latest offset on the associated changelog partition.
     */
    void onStandbyUpdateStartonUpdateStart(final TopicPartition topicPartition,
                             final String storeName,
                             final long earliestOffset,
                             final long startingOffset,
                             final long currentEndOffset);

    /**
     * Method called after loading a batch of records from the changelog into the Standby State Store.
	 * In this case the maximum size of the batch is determined by the value of the MAX_POLL_RECORDS.
     *
     * This method is called after loading each batch and it is advised to keep processing to a minimum.
     * Any heavy processing will hold up loading the next batch, reducing the throughput of the State Updater
	 * Thread.
     *
     * If you need to do any extended processing or connecting to an external service consider doing so asynchronously.
     *
     * @param topicPartition the TopicPartition containing the values to restore
     * @param storeName the name of the store undergoing restoration
     * @param batchEndOffset the inclusive ending offset for the current restored batch for this TopicPartition
     * @param numRestored the total number of records restored in this batch for this TopicPartition
     * @param currentEndOffset the current end offset of the changelog topic partition.
     */
    void onBatchLoaded(final TopicPartition topicPartition,
                       final String storeName,
                       final long batchEndOffset,
                       final long numRestored,
                       final long currentEndOffset);

    /**
     * Method called after updates to a Standby State Store cease, either because the Standby Task was promoted to
     * an Active Task or because the Standby Task was migrated to another instance (in which case the data will
     * be cleaned up after state.cleanup.delay.ms).
     * @param topicPartition the TopicPartition containing the values to restore
     * @param storeName the name of the store undergoing restoration
     * @param storeOffset is the offset of the last changelog record that was read and put into the store at the time
     * of suspension.
     * @param currentEndOffset the current end offset of the changelog topic partition.
     * @param reason is the reason why the standby task was suspended.
     */
    void onStandbyUpdateSuspendedonUpdateSuspended(final TopicPartition topicPartition,
                                  final String storeName,
                                  final long storeOffset,
                                  final long currentEndOffset,
                                  final SuspendReason reason);
}

...