Search in sources :

Example 11 with TransactionAttempt

use of org.apache.storm.trident.topology.TransactionAttempt in project storm by apache.

the class TridentSpoutCoordinator method execute.

@Override
public void execute(Tuple tuple, BasicOutputCollector collector) {
    TransactionAttempt attempt = (TransactionAttempt) tuple.getValue(0);
    if (tuple.getSourceStreamId().equals(MasterBatchCoordinator.SUCCESS_STREAM_ID)) {
        state.cleanupBefore(attempt.getTransactionId());
        coord.success(attempt.getTransactionId());
    } else {
        long txid = attempt.getTransactionId();
        Object prevMeta = state.getPreviousState(txid);
        Object meta = coord.initializeTransaction(txid, prevMeta, state.getState(txid));
        state.overrideState(txid, meta);
        collector.emit(MasterBatchCoordinator.BATCH_STREAM_ID, new Values(attempt, meta));
    }
}
Also used : Values(org.apache.storm.tuple.Values) TransactionAttempt(org.apache.storm.trident.topology.TransactionAttempt)

Aggregations

TransactionAttempt (org.apache.storm.trident.topology.TransactionAttempt)11 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 Test (org.junit.jupiter.api.Test)7 List (java.util.List)6 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)6 ConsumerRecord (org.apache.kafka.clients.consumer.ConsumerRecord)3 HashMap (java.util.HashMap)1 OffsetAndTimestamp (org.apache.kafka.clients.consumer.OffsetAndTimestamp)1 TopicPartition (org.apache.kafka.common.TopicPartition)1 FailedException (org.apache.storm.topology.FailedException)1 Values (org.apache.storm.tuple.Values)1 EnumSource (org.junit.jupiter.params.provider.EnumSource)1