Source:
public void initializeState(FunctionInitializationContext context) throws Exception { if (semantic != FlinkKafkaProducer.Semantic.NONE && !((StreamingRuntimeContext) this.getRuntimeContext()).isCheckpointingEnabled()) { LOG.warn("Using semantic, but checkpointing is not enabled. Switching to semantic.", semantic, FlinkKafkaProducer.Semantic.NONE); semantic = FlinkKafkaProducer.Semantic.NONE; } nextTransactionalIdHintState = context.getOperatorStateStore().getUnionListState( NEXT_TRANSACTIONAL_ID_HINT_DESCRIPTOR_V2); if (context.getOperatorStateStore().getRegisteredStateNames().contains(NEXT_TRANSACTIONAL_ID_HINT_DESCRIPTOR)) { migrateNextTransactionalIdHindState(context); } String taskName = getRuntimeContext().getTaskName(); if (taskName.length() > maxTaskNameSize) { taskName = taskName.substring(0, maxTaskNameSize); } transactionalIdsGenerator = new TransactionalIdsGenerator( taskName + "-" + ((StreamingRuntimeContext) getRuntimeContext()).getOperatorUniqueID(), getRuntimeContext().getIndexOfThisSubtask(), getRuntimeContext().getNumberOfParallelSubtasks(), kafkaProducersPoolSize, SAFE_SCALE_DOWN_FACTOR); if (semantic != FlinkKafkaProducer.Semantic.EXACTLY_ONCE) { nextTransactionalIdHint = null; } else { ArrayList<FlinkKafkaProducer.NextTransactionalIdHint> transactionalIdHints = Lists.newArrayList(nextTransactionalIdHintState.get()); if (transactionalIdHints.size() > 1) { throw new IllegalStateException( "There should be at most one next transactional id hint written by the first subtask"); } else if (transactionalIdHints.size() == 0) { nextTransactionalIdHint = new FlinkKafkaProducer.NextTransactionalIdHint(0, 0); abortTransactions(transactionalIdsGenerator.generateIdsToAbort()); } else { nextTransactionalIdHint = transactionalIdHints.get(0); } } super.initializeState(context); }

Target:
public void initializeState(FunctionInitializationContext context) throws Exception { if (semantic != FlinkKafkaProducer.Semantic.NONE && !((StreamingRuntimeContext) this.getRuntimeContext()).isCheckpointingEnabled()) { LOG.warn("Using semantic, but checkpointing is not enabled. Switching to semantic.", semantic, FlinkKafkaProducer.Semantic.NONE); semantic = FlinkKafkaProducer.Semantic.NONE; } nextTransactionalIdHintState = context.getOperatorStateStore().getUnionListState( NEXT_TRANSACTIONAL_ID_HINT_DESCRIPTOR_V2); if (context.getOperatorStateStore().getRegisteredStateNames().contains(NEXT_TRANSACTIONAL_ID_HINT_DESCRIPTOR)) { migrateNextTransactionalIdHindState(context); } String taskName = getRuntimeContext().getTaskName(); if (taskName.length() > maxTaskNameSize) { taskName = taskName.substring(0, maxTaskNameSize); LOG.warn("Truncated task name for Kafka TransactionalId from to {}.", getRuntimeContext().getTaskName(), taskName); } transactionalIdsGenerator = new TransactionalIdsGenerator( taskName + "-" + ((StreamingRuntimeContext) getRuntimeContext()).getOperatorUniqueID(), getRuntimeContext().getIndexOfThisSubtask(), getRuntimeContext().getNumberOfParallelSubtasks(), kafkaProducersPoolSize, SAFE_SCALE_DOWN_FACTOR); if (semantic != FlinkKafkaProducer.Semantic.EXACTLY_ONCE) { nextTransactionalIdHint = null; } else { ArrayList<FlinkKafkaProducer.NextTransactionalIdHint> transactionalIdHints = Lists.newArrayList(nextTransactionalIdHintState.get()); if (transactionalIdHints.size() > 1) { throw new IllegalStateException( "There should be at most one next transactional id hint written by the first subtask"); } else if (transactionalIdHints.size() == 0) { nextTransactionalIdHint = new FlinkKafkaProducer.NextTransactionalIdHint(0, 0); abortTransactions(transactionalIdsGenerator.generateIdsToAbort()); } else { nextTransactionalIdHint = transactionalIdHints.get(0); } } super.initializeState(context); }