Class DefaultCheckpointMetadata<T>
- java.lang.Object
-
- io.smallrye.reactive.messaging.kafka.commit.DefaultCheckpointMetadata<T>
-
- Type Parameters:
T- type of the processing state
- All Implemented Interfaces:
CheckpointMetadata<T>
public class DefaultCheckpointMetadata<T> extends Object implements CheckpointMetadata<T>
Default implementation ofCheckpointMetadata
-
-
Constructor Summary
Constructors Constructor Description DefaultCheckpointMetadata(org.apache.kafka.common.TopicPartition topicPartition, long recordOffset, io.smallrye.reactive.messaging.kafka.commit.KafkaCheckpointCommit.CheckpointState<T> checkpointState)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <S> DefaultCheckpointMetadata<S>fromMessage(org.eclipse.microprofile.reactive.messaging.Message<?> message)ProcessingState<T>getCurrent()ProcessingState<T>getNext()longgetRecordOffset()org.apache.kafka.common.TopicPartitiongetTopicPartition()booleanisPersistOnAck()TsetNext(T state)Set the next processing state to the given state, associated with the current record offset + 1.TsetNext(T state, boolean persistOnAck)Set the next processing state to the given state, associated with the current record offset + 1.Ttransform(Supplier<T> initialStateSupplier, Function<T,T> transformation)SeeCheckpointMetadata.transform(Supplier, Function, boolean)The state will not be persisted on message acknowledgement.Ttransform(Supplier<T> initialStateSupplier, Function<T,T> transformation, boolean persistOnAck)Apply the transformation to the current state, if a previous state doesn't exist, start the transformation from the supplied initial state.Ttransform(T initialState, Function<T,T> transformation)SeeCheckpointMetadata.transform(Supplier, Function, boolean)The state will not be persisted on message acknowledgement.Ttransform(T initialState, Function<T,T> transformation, boolean persistOnAck)
-
-
-
Constructor Detail
-
DefaultCheckpointMetadata
public DefaultCheckpointMetadata(org.apache.kafka.common.TopicPartition topicPartition, long recordOffset, io.smallrye.reactive.messaging.kafka.commit.KafkaCheckpointCommit.CheckpointState<T> checkpointState)
-
-
Method Detail
-
fromMessage
public static <S> DefaultCheckpointMetadata<S> fromMessage(org.eclipse.microprofile.reactive.messaging.Message<?> message)
-
getTopicPartition
public org.apache.kafka.common.TopicPartition getTopicPartition()
- Specified by:
getTopicPartitionin interfaceCheckpointMetadata<T>- Returns:
- the topic-partition of this record
-
getRecordOffset
public long getRecordOffset()
- Specified by:
getRecordOffsetin interfaceCheckpointMetadata<T>- Returns:
- the offset of this record
-
isPersistOnAck
public boolean isPersistOnAck()
- Specified by:
isPersistOnAckin interfaceCheckpointMetadata<T>- Returns:
trueif the processing state will be persisted on message acknowledgement
-
getCurrent
public ProcessingState<T> getCurrent()
- Specified by:
getCurrentin interfaceCheckpointMetadata<T>- Returns:
- the current processing state
-
getNext
public ProcessingState<T> getNext()
- Specified by:
getNextin interfaceCheckpointMetadata<T>- Returns:
- the next processing state set during this processing
-
setNext
public T setNext(T state, boolean persistOnAck)
Description copied from interface:CheckpointMetadataSet the next processing state to the given state, associated with the current record offset + 1.- Specified by:
setNextin interfaceCheckpointMetadata<T>- Parameters:
state- the next statepersistOnAck- Iftruethen the state will be persisted on message acknowledgement- Returns:
- the previous state
-
setNext
public T setNext(T state)
Description copied from interface:CheckpointMetadataSet the next processing state to the given state, associated with the current record offset + 1. The state will not be persisted on message acknowledgement.- Specified by:
setNextin interfaceCheckpointMetadata<T>- Parameters:
state- the next state- Returns:
- the previous state
-
transform
public T transform(Supplier<T> initialStateSupplier, Function<T,T> transformation, boolean persistOnAck)
Description copied from interface:CheckpointMetadataApply the transformation to the current state, if a previous state doesn't exist, start the transformation from the supplied initial state. The state will be associated with the current record offset + 1.- Specified by:
transformin interfaceCheckpointMetadata<T>- Parameters:
initialStateSupplier- if no previous state does exist, start the transformation from this state.transformation- the transformation functionpersistOnAck- Iftruethen the state will be persisted on message acknowledgement- Returns:
- the previous state
-
transform
public T transform(T initialState, Function<T,T> transformation, boolean persistOnAck)
Description copied from interface:CheckpointMetadata- Specified by:
transformin interfaceCheckpointMetadata<T>- Parameters:
initialState- if no previous state does exist, start the transformation from this state.transformation- the transformation functionpersistOnAck- Iftruethen the state will be persisted on message acknowledgement- Returns:
- the previous state
-
transform
public T transform(Supplier<T> initialStateSupplier, Function<T,T> transformation)
Description copied from interface:CheckpointMetadataSeeCheckpointMetadata.transform(Supplier, Function, boolean)The state will not be persisted on message acknowledgement.- Specified by:
transformin interfaceCheckpointMetadata<T>- Parameters:
initialStateSupplier- if no previous state does exist, start the transformation from this state.transformation- the transformation function- Returns:
- the previous state
-
transform
public T transform(T initialState, Function<T,T> transformation)
Description copied from interface:CheckpointMetadataSeeCheckpointMetadata.transform(Supplier, Function, boolean)The state will not be persisted on message acknowledgement.- Specified by:
transformin interfaceCheckpointMetadata<T>- Parameters:
initialState- if no previous state does exist, start the transformation from this state.transformation- the transformation function- Returns:
- the previous state
-
-