public void StopConnections() { /* * Stop the leader finder thread first before stopping fetchers. Otherwise, if there are more partitions without * leader, then the leader finder thread will process these partitions (before shutting down) and add fetchers for * these partitions. */ Logger.InfoFormat("Stopping leader finder thread"); if (this.leaderFinderThread != null) { this.leaderFinderThread.Shutdown(); this.leaderFinderThread = null; } Logger.InfoFormat("Stopping all fetchers"); this.CloseAllFetchers(); // no need to hold the lock for the following since leaderFindThread and all fetchers have been stopped this.partitionMap = null; this.NoLeaderPartitionSet.Clear(); Logger.InfoFormat("All connections stopped"); }
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](); } }