internal StreamTask GetTask(string topicName) { StreamTask task = null; var id = builder.GetTaskIdFromPartition(new Confluent.Kafka.TopicPartition(topicName, 0)); if (tasks.ContainsKey(id)) { task = tasks[id]; } else { if (!builder.GetGlobalTopics().Contains(topicName)) { task = new StreamTask("thread-0", id, partitionsByTaskId[id], builder.BuildTopology(id), supplier.GetConsumer(configuration.ToConsumerConfig(), null), configuration, supplier, producer, new MockChangelogRegister(), metricsRegistry); task.InitializeStateStores(); task.InitializeTopology(); task.RestorationIfNeeded(); task.CompleteRestoration(); tasks.Add(id, task); } } return(task); }
public TaskSynchronousTopologyDriver(string clientId, InternalTopologyBuilder topologyBuilder, IStreamConfig configuration, IStreamConfig topicConfiguration, IKafkaSupplier supplier, CancellationToken token) { this.configuration = configuration; this.configuration.ClientId = clientId; this.topicConfiguration = topicConfiguration; this.token = token; builder = topologyBuilder; this.supplier = supplier ?? new SyncKafkaSupplier(); producer = this.supplier.GetProducer(configuration.ToProducerConfig()) as SyncProducer; foreach (var sourceTopic in builder.GetSourceTopics().Union(builder.GetGlobalTopics())) { var part = new TopicPartition(sourceTopic, 0); var taskId = builder.GetTaskIdFromPartition(part); if (partitionsByTaskId.ContainsKey(taskId)) { partitionsByTaskId[taskId].Add(part); } else { partitionsByTaskId.Add(taskId, new List <TopicPartition> { part }); } } }