public class KafkaTridentSpoutEmitter<K,V> extends Object implements IOpaquePartitionedTridentSpout.Emitter<List<Map<String,Object>>,KafkaTridentSpoutTopicPartition,Map<String,Object>>, Serializable
Constructor and Description |
---|
KafkaTridentSpoutEmitter(KafkaTridentSpoutManager<K,V> kafkaManager,
TopologyContext topologyContext)
Creates instance of this class with default 500 millisecond refresh subscription timer
|
KafkaTridentSpoutEmitter(KafkaTridentSpoutManager<K,V> kafkaManager,
TopologyContext topologyContext,
Timer refreshSubscriptionTimer)
Create a new Kafka spout emitter.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
Map<String,Object> |
emitPartitionBatch(TransactionAttempt tx,
TridentCollector collector,
KafkaTridentSpoutTopicPartition currBatchPartition,
Map<String,Object> lastBatch)
Emit a batch of tuples for a partition/transaction.
|
List<KafkaTridentSpoutTopicPartition> |
getOrderedPartitions(List<Map<String,Object>> allPartitionInfo)
Computes ordered list of topic-partitions for this task taking into consideration that topic-partitions for this task must be assigned to the Kafka consumer running on this task.
|
List<KafkaTridentSpoutTopicPartition> |
getPartitionsForTask(int taskId,
int numTasks,
List<KafkaTridentSpoutTopicPartition> allPartitionInfo) |
void |
refreshPartitions(List<KafkaTridentSpoutTopicPartition> partitionResponsibilities)
This method is called when this task is responsible for a new set of partitions.
|
String |
toString() |
public KafkaTridentSpoutEmitter(KafkaTridentSpoutManager<K,V> kafkaManager, TopologyContext topologyContext, Timer refreshSubscriptionTimer)
Create a new Kafka spout emitter.
kafkaManager
- The Kafka consumer manager to usetopologyContext
- The topology contextrefreshSubscriptionTimer
- The timer for deciding when to recheck the subscriptionpublic KafkaTridentSpoutEmitter(KafkaTridentSpoutManager<K,V> kafkaManager, TopologyContext topologyContext)
Creates instance of this class with default 500 millisecond refresh subscription timer
public Map<String,Object> emitPartitionBatch(TransactionAttempt tx, TridentCollector collector, KafkaTridentSpoutTopicPartition currBatchPartition, Map<String,Object> lastBatch)
IOpaquePartitionedTridentSpout.Emitter
Emit a batch of tuples for a partition/transaction.
Return the metadata describing this batch that will be used as lastPartitionMeta for defining the parameters of the next batch.
emitPartitionBatch
in interface IOpaquePartitionedTridentSpout.Emitter<List<Map<String,Object>>,KafkaTridentSpoutTopicPartition,Map<String,Object>>
public void refreshPartitions(List<KafkaTridentSpoutTopicPartition> partitionResponsibilities)
IOpaquePartitionedTridentSpout.Emitter
This method is called when this task is responsible for a new set of partitions. Should be used to manage things like connections to brokers.
refreshPartitions
in interface IOpaquePartitionedTridentSpout.Emitter<List<Map<String,Object>>,KafkaTridentSpoutTopicPartition,Map<String,Object>>
public List<KafkaTridentSpoutTopicPartition> getOrderedPartitions(List<Map<String,Object>> allPartitionInfo)
Computes ordered list of topic-partitions for this task taking into consideration that topic-partitions for this task must be assigned to the Kafka consumer running on this task.
getOrderedPartitions
in interface IOpaquePartitionedTridentSpout.Emitter<List<Map<String,Object>>,KafkaTridentSpoutTopicPartition,Map<String,Object>>
allPartitionInfo
- list of all partitions as returned by KafkaTridentSpoutOpaqueCoordinator
public List<KafkaTridentSpoutTopicPartition> getPartitionsForTask(int taskId, int numTasks, List<KafkaTridentSpoutTopicPartition> allPartitionInfo)
getPartitionsForTask
in interface IOpaquePartitionedTridentSpout.Emitter<List<Map<String,Object>>,KafkaTridentSpoutTopicPartition,Map<String,Object>>
taskId
public void close()
close
in interface IOpaquePartitionedTridentSpout.Emitter<List<Map<String,Object>>,KafkaTridentSpoutTopicPartition,Map<String,Object>>
Copyright © 2022 The Apache Software Foundation. All Rights Reserved.