static private GetPartitionsForTopics ( IZooKeeperClient zkClient, IEnumerable |
||
zkClient | IZooKeeperClient | |
topics | IEnumerable |
|
Résultat | IList |
private TopicStatisticsRecord ProcessTopic(string consumerGroup, string topic) { var topicPartitionMap = ZkUtils.GetPartitionsForTopics(this.zkClient, new[] { topic }); var topicState = new TopicStatisticsRecord { Topic = topic, PartitionsStat = new Dictionary <int, PartitionStatisticsRecord>(topicPartitionMap[topic].Count) }; foreach (var partitionId in topicPartitionMap[topic]) { try { var partitionIdInt = int.Parse(partitionId); topicState.PartitionsStat[partitionIdInt] = this.ProcessPartition(consumerGroup, topic, partitionIdInt); } catch (NoLeaderForPartitionException exc) { Logger.ErrorFormat("Could not found a leader for partition {0}. Details: {1}", exc.PartitionId, exc.FormatException()); } catch (BrokerNotAvailableException exc) { Logger.ErrorFormat("Could not found a broker information for broker {0} while processing partition {1}. Details: {2}", exc.BrokerId, partitionId, exc.FormatException()); } catch (OffsetIsUnknowException exc) { Logger.ErrorFormat("Could not retrieve offset from broker {0} for topic {1} partition {2}. Details: {3}", exc.BrokerId, exc.Topic, exc.PartitionId, exc.FormatException()); } } return(topicState); }
private Dictionary <int, TopicPartitionState> ProcessTopic(string topic) { // might throw NoPartitionsForTopicException var topicPartitionMap = ZkUtils.GetPartitionsForTopics(this.zkClient, new[] { topic }); var partitionsMetadata = new Dictionary <int, TopicPartitionState>(); foreach (var partitionId in topicPartitionMap[topic]) { var partitionIdInt = int.Parse(partitionId); partitionsMetadata[partitionIdInt] = ZkUtils.GetPartitionState(this.zkClient, topic, partitionIdInt); } return(partitionsMetadata); }