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()
long
getRecordOffset()
org.apache.kafka.common.TopicPartition
getTopicPartition()
boolean
isPersistOnAck()
T
setNext(T state)
Set the next processing state to the given state, associated with the current record offset + 1.T
setNext(T state, boolean persistOnAck)
Set the next processing state to the given state, associated with the current record offset + 1.T
transform(Supplier<T> initialStateSupplier, Function<T,T> transformation)
SeeCheckpointMetadata.transform(Supplier, Function, boolean)
The state will not be persisted on message acknowledgement.T
transform(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.T
transform(T initialState, Function<T,T> transformation)
SeeCheckpointMetadata.transform(Supplier, Function, boolean)
The state will not be persisted on message acknowledgement.T
transform(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:
getTopicPartition
in interfaceCheckpointMetadata<T>
- Returns:
- the topic-partition of this record
-
getRecordOffset
public long getRecordOffset()
- Specified by:
getRecordOffset
in interfaceCheckpointMetadata<T>
- Returns:
- the offset of this record
-
isPersistOnAck
public boolean isPersistOnAck()
- Specified by:
isPersistOnAck
in interfaceCheckpointMetadata<T>
- Returns:
true
if the processing state will be persisted on message acknowledgement
-
getCurrent
public ProcessingState<T> getCurrent()
- Specified by:
getCurrent
in interfaceCheckpointMetadata<T>
- Returns:
- the current processing state
-
getNext
public ProcessingState<T> getNext()
- Specified by:
getNext
in interfaceCheckpointMetadata<T>
- Returns:
- the next processing state set during this processing
-
setNext
public T setNext(T state, boolean persistOnAck)
Description copied from interface:CheckpointMetadata
Set the next processing state to the given state, associated with the current record offset + 1.- Specified by:
setNext
in interfaceCheckpointMetadata<T>
- Parameters:
state
- the next statepersistOnAck
- Iftrue
then the state will be persisted on message acknowledgement- Returns:
- the previous state
-
setNext
public T setNext(T state)
Description copied from interface:CheckpointMetadata
Set 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:
setNext
in 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:CheckpointMetadata
Apply 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:
transform
in interfaceCheckpointMetadata<T>
- Parameters:
initialStateSupplier
- if no previous state does exist, start the transformation from this state.transformation
- the transformation functionpersistOnAck
- Iftrue
then 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:
transform
in interfaceCheckpointMetadata<T>
- Parameters:
initialState
- if no previous state does exist, start the transformation from this state.transformation
- the transformation functionpersistOnAck
- Iftrue
then 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:CheckpointMetadata
SeeCheckpointMetadata.transform(Supplier, Function, boolean)
The state will not be persisted on message acknowledgement.- Specified by:
transform
in 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:CheckpointMetadata
SeeCheckpointMetadata.transform(Supplier, Function, boolean)
The state will not be persisted on message acknowledgement.- Specified by:
transform
in interfaceCheckpointMetadata<T>
- Parameters:
initialState
- if no previous state does exist, start the transformation from this state.transformation
- the transformation function- Returns:
- the previous state
-
-