Kafka.Client.ZooKeeperIntegration.Listeners.BrokerTopicsListener.ProcessNewBrokerInExistingTopic C# (CSharp) Метод

ProcessNewBrokerInExistingTopic() приватный Метод

Generate the updated mapping of (brokerId, numPartitions) for the new list of brokers registered under some topic.
private ProcessNewBrokerInExistingTopic ( string topic, IEnumerable childs ) : void
topic string The path of the topic under which the brokers have changed..
childs IEnumerable The list of changed brokers.
Результат void
        private void ProcessNewBrokerInExistingTopic(string topic, IEnumerable<string> childs)
        {
            if (this.actualBrokerTopicsPartitionsMap.ContainsKey(topic))
            {
                Logger.Debug("Old list of brokers -> " + this.oldBrokerTopicsPartitionsMap[topic].ToMultiString(x => x.BrokerId.ToString(), ","));
            }

            var updatedBrokers = new SortedSet<int>(childs.Select(x => int.Parse(x, CultureInfo.InvariantCulture)));
            string brokerTopicPath = ZooKeeperClient.DefaultBrokerTopicsPath + "/" + topic;
            var sortedBrokerPartitions = new SortedDictionary<int, int>();
            foreach (var bid in updatedBrokers)
            {
                var num = this.zkclient.ReadData<string>(brokerTopicPath + "/" + bid);
                sortedBrokerPartitions.Add(bid, int.Parse(num, CultureInfo.InvariantCulture));
            }

            var updatedBrokerParts = new SortedSet<Partition>();
            foreach (var bp in sortedBrokerPartitions)
            {
                for (int i = 0; i < bp.Value; i++)
                {
                    var bidPid = new Partition(bp.Key, i);
                    updatedBrokerParts.Add(bidPid);
                }
            }

            Logger.Debug("Currently registered list of brokers for topic " + topic + " -> " + childs.ToMultiString(", "));
            SortedSet<Partition> mergedBrokerParts = updatedBrokerParts;
            if (this.actualBrokerTopicsPartitionsMap.ContainsKey(topic))
            {
                SortedSet<Partition> oldBrokerParts = this.actualBrokerTopicsPartitionsMap[topic];
                Logger.Debug(
                    "Unregistered list of brokers for topic " + topic + " -> " + oldBrokerParts.ToMultiString(", "));
                foreach (var oldBrokerPart in oldBrokerParts)
                {
                    mergedBrokerParts.Add(oldBrokerPart);
                }
            }
            else
            {
                this.actualBrokerTopicsPartitionsMap.Add(topic, null);
            }

            this.actualBrokerTopicsPartitionsMap[topic] = new SortedSet<Partition>(mergedBrokerParts.Where(x => this.actualBrokerIdMap.ContainsKey(x.BrokerId)));
        }