Class TransactionAbortStrategyContextImpl
- java.lang.Object
-
- org.apache.flink.connector.kafka.sink.internal.TransactionAbortStrategyContextImpl
-
- All Implemented Interfaces:
TransactionAbortStrategyImpl.Context
@Internal public class TransactionAbortStrategyContextImpl extends Object implements TransactionAbortStrategyImpl.Context
Implementation ofTransactionAbortStrategyImpl.Context.
-
-
Constructor Summary
Constructors Constructor Description TransactionAbortStrategyContextImpl(Supplier<Collection<String>> topicNames, int currentSubtaskId, int currentParallelism, int[] ownedSubtaskIds, int totalNumberOfOwnedSubtasks, List<String> prefixesToAbort, long startCheckpointId, TransactionAbortStrategyImpl.TransactionAborter transactionAborter, Supplier<org.apache.kafka.clients.admin.Admin> adminSupplier, Set<String> precommittedTransactionIds)Creates a newTransactionAbortStrategyContextImpl.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetCurrentParallelism()intgetCurrentSubtaskId()Collection<String>getOpenTransactionsForTopics()Returns the list of all open transactions for the topics retrieved through introspection.Set<String>getPrecommittedTransactionalIds()Returns a list of transactional ids that shouldn't be aborted because they are part of the committer state.Set<String>getPrefixesToAbort()longgetStartCheckpointId()TransactionAbortStrategyImpl.TransactionAbortergetTransactionAborter()booleanownsTransactionalId(String transactionalId)Subtask must abort transactions that they own and must not abort any transaction that they don't own.
-
-
-
Constructor Detail
-
TransactionAbortStrategyContextImpl
public TransactionAbortStrategyContextImpl(Supplier<Collection<String>> topicNames, int currentSubtaskId, int currentParallelism, int[] ownedSubtaskIds, int totalNumberOfOwnedSubtasks, List<String> prefixesToAbort, long startCheckpointId, TransactionAbortStrategyImpl.TransactionAborter transactionAborter, Supplier<org.apache.kafka.clients.admin.Admin> adminSupplier, Set<String> precommittedTransactionIds)
Creates a newTransactionAbortStrategyContextImpl.
-
-
Method Detail
-
getOpenTransactionsForTopics
public Collection<String> getOpenTransactionsForTopics()
Description copied from interface:TransactionAbortStrategyImpl.ContextReturns the list of all open transactions for the topics retrieved through introspection.- Specified by:
getOpenTransactionsForTopicsin interfaceTransactionAbortStrategyImpl.Context
-
ownsTransactionalId
public boolean ownsTransactionalId(String transactionalId)
Description copied from interface:TransactionAbortStrategyImpl.ContextSubtask must abort transactions that they own and must not abort any transaction that they don't own. Ownership is defined as follows:- Writer states contains the old subtask id and the max parallelism when it was snapshotted.
- On recovery, the state is reassigned somewhere. The new assignee takes the ownership.
- If there was a downscale, one subtask may own several old subtask ids.
- If there was an upscale, the ids usually remain stable but that isn't necessary for the abort to work.
- Any number of intermediate attempts between the recovered checkpoint and the current attempt may produce transactions > then the current parallelism. In that case, subtask ids are distributed in a round robin fashion using modulo.
- Specified by:
ownsTransactionalIdin interfaceTransactionAbortStrategyImpl.Context
-
getCurrentSubtaskId
public int getCurrentSubtaskId()
- Specified by:
getCurrentSubtaskIdin interfaceTransactionAbortStrategyImpl.Context
-
getCurrentParallelism
public int getCurrentParallelism()
- Specified by:
getCurrentParallelismin interfaceTransactionAbortStrategyImpl.Context
-
getPrefixesToAbort
public Set<String> getPrefixesToAbort()
- Specified by:
getPrefixesToAbortin interfaceTransactionAbortStrategyImpl.Context
-
getPrecommittedTransactionalIds
public Set<String> getPrecommittedTransactionalIds()
Description copied from interface:TransactionAbortStrategyImpl.ContextReturns a list of transactional ids that shouldn't be aborted because they are part of the committer state.- Specified by:
getPrecommittedTransactionalIdsin interfaceTransactionAbortStrategyImpl.Context
-
getStartCheckpointId
public long getStartCheckpointId()
- Specified by:
getStartCheckpointIdin interfaceTransactionAbortStrategyImpl.Context
-
getTransactionAborter
public TransactionAbortStrategyImpl.TransactionAborter getTransactionAborter()
- Specified by:
getTransactionAborterin interfaceTransactionAbortStrategyImpl.Context
-
-