Class CompositeRestoreListener
- java.lang.Object
-
- org.apache.kafka.streams.processor.internals.CompositeRestoreListener
-
- All Implemented Interfaces:
BatchingStateRestoreCallback
,RecordBatchingStateRestoreCallback
,StateRestoreCallback
,StateRestoreListener
public class CompositeRestoreListener extends java.lang.Object implements RecordBatchingStateRestoreCallback, StateRestoreListener
-
-
Field Summary
Fields Modifier and Type Field Description static org.apache.kafka.streams.processor.internals.CompositeRestoreListener.NoOpStateRestoreListener
NO_OP_STATE_RESTORE_LISTENER
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
onBatchRestored(org.apache.kafka.common.TopicPartition topicPartition, java.lang.String storeName, long batchEndOffset, long numRestored)
Method called after restoring a batch of records.void
onRestoreEnd(org.apache.kafka.common.TopicPartition topicPartition, java.lang.String storeName, long totalRestored)
Method called when restoring theStateStore
is complete.void
onRestoreStart(org.apache.kafka.common.TopicPartition topicPartition, java.lang.String storeName, long startingOffset, long endingOffset)
Method called at the very beginning ofStateStore
restoration.void
restore(byte[] key, byte[] value)
void
restoreAll(java.util.Collection<KeyValue<byte[],byte[]>> records)
Called to restore a number of records.void
restoreBatch(java.util.Collection<org.apache.kafka.clients.consumer.ConsumerRecord<byte[],byte[]>> records)
-
-
-
Method Detail
-
onRestoreStart
public void onRestoreStart(org.apache.kafka.common.TopicPartition topicPartition, java.lang.String storeName, long startingOffset, long endingOffset)
Description copied from interface:StateRestoreListener
Method called at the very beginning ofStateStore
restoration.- Specified by:
onRestoreStart
in interfaceStateRestoreListener
- Parameters:
topicPartition
- the TopicPartition containing the values to restorestoreName
- the name of the store undergoing restorationstartingOffset
- the starting offset of the entire restoration process for this TopicPartitionendingOffset
- the exclusive ending offset of the entire restoration process for this TopicPartition- Throws:
StreamsException
- if user providedStateRestoreListener
raises an exception inStateRestoreListener.onRestoreStart(TopicPartition, String, long, long)
-
onBatchRestored
public void onBatchRestored(org.apache.kafka.common.TopicPartition topicPartition, java.lang.String storeName, long batchEndOffset, long numRestored)
Description copied from interface:StateRestoreListener
Method called after restoring a batch of records. In this case the maximum size of the batch is whatever the value of the MAX_POLL_RECORDS is set to. This method is called after restoring each batch and it is advised to keep processing to a minimum. Any heavy processing will hold up recovering the next batch, hence slowing down the restore process as a whole. If you need to do any extended processing or connecting to an external service consider doing so asynchronously.- Specified by:
onBatchRestored
in interfaceStateRestoreListener
- Parameters:
topicPartition
- the TopicPartition containing the values to restorestoreName
- the name of the store undergoing restorationbatchEndOffset
- the inclusive ending offset for the current restored batch for this TopicPartitionnumRestored
- the total number of records restored in this batch for this TopicPartition- Throws:
StreamsException
- if user providedStateRestoreListener
raises an exception inStateRestoreListener.onBatchRestored(TopicPartition, String, long, long)
-
onRestoreEnd
public void onRestoreEnd(org.apache.kafka.common.TopicPartition topicPartition, java.lang.String storeName, long totalRestored)
Description copied from interface:StateRestoreListener
Method called when restoring theStateStore
is complete.- Specified by:
onRestoreEnd
in interfaceStateRestoreListener
- Parameters:
topicPartition
- the TopicPartition containing the values to restorestoreName
- the name of the store just restoredtotalRestored
- the total number of records restored for this TopicPartition- Throws:
StreamsException
- if user providedStateRestoreListener
raises an exception inStateRestoreListener.onRestoreEnd(TopicPartition, String, long)
-
restoreBatch
public void restoreBatch(java.util.Collection<org.apache.kafka.clients.consumer.ConsumerRecord<byte[],byte[]>> records)
- Specified by:
restoreBatch
in interfaceRecordBatchingStateRestoreCallback
-
restoreAll
public void restoreAll(java.util.Collection<KeyValue<byte[],byte[]>> records)
Description copied from interface:BatchingStateRestoreCallback
Called to restore a number of records. This method is called repeatedly until theStateStore
is fulled restored.- Specified by:
restoreAll
in interfaceBatchingStateRestoreCallback
- Specified by:
restoreAll
in interfaceRecordBatchingStateRestoreCallback
- Parameters:
records
- the records to restore.
-
restore
public void restore(byte[] key, byte[] value)
- Specified by:
restore
in interfaceRecordBatchingStateRestoreCallback
- Specified by:
restore
in interfaceStateRestoreCallback
-
-