Esempio n. 1
0
        public FetcherTest()
        {
            this.cluster = new Cluster(Configs.Select(c => new Broker(c.BrokerId, "localhost", c.Port)));
            this.topicInfos =
                this.Configs.Select(
                    c =>
                    new PartitionTopicInfo(
                        this.topic, 0, this.queue, new AtomicLong(0), new AtomicLong(0), new AtomicInteger(0), string.Empty))
                    .ToList();

            AdminUtils.CreateOrUpdateTopicPartitionAssignmentPathInZK(
                this.ZkClient,
                this.topic,
                new Dictionary<int, List<int>> { { 0, new List<int> { Configs.First().BrokerId } } },
                new Dictionary<string, string>());

            TestUtils.WaitUntilLeaderIsElectedOrChanged(this.ZkClient, this.topic, 0, 500);

            this.fetcher = new ConsumerFetcherManager("consumer1", new ConsumerConfig(string.Empty, 1234, string.Empty), ZkClient);
            this.fetcher.StopConnections();
            this.fetcher.StartConnections(this.topicInfos, this.cluster);
        }
Esempio n. 2
0
        public void StartConnections(List<PartitionTopicInfo> topicInfos, Cluster cluster)
        {
            this.leaderFinderThread = new LeaderFinderThread(this, this.consumerIdString + "-leader-finder-thread");
            this.leaderFinderThread.Start();

            [email protected]();
            try
            {
                this.partitionMap = topicInfos.ToDictionary(x => new TopicAndPartition(x.Topic, x.PartitionId), x => x);
                this.cluster = cluster;
                var noLeaders = topicInfos.Select(x => new TopicAndPartition(x.Topic, x.PartitionId)).ToList();
                foreach (var noLeader in noLeaders)
                {
                    this.NoLeaderPartitionSet.Add(noLeader);
                }

                this.cond.SignalAll();
            }
            finally
            {
                [email protected]();
            }
        }
Esempio n. 3
0
        public static Cluster GetCluster(ZkClient zkClient)
        {
            var cluster = new Cluster();
            var nodes = GetChildrenParentMayNotExist(zkClient, BrokerIdsPath);
            foreach (var node in nodes)
            {
                var brokerZkString = ReadData(zkClient, BrokerIdsPath + "/" + node).Item1;
                cluster.Add(Broker.CreateBroker(int.Parse(node), brokerZkString));
            }

            return cluster;
        }