/**
* get broker host by topic partition
*
* @param string $topicName
* @param int $partitionId
* @access public
* @return string
*/
public function getHostByPartition($topicName, $partitionId = 0)
{
$partitionInfo = $this->metadata->getPartitionState($topicName, $partitionId);
if (!$partitionInfo) {
throw new Exception('topic:' . $topicName . ', partition id: ' . $partitionId . ' is not exists.');
}
$hostList = $this->getBrokers();
if (isset($partitionInfo['leader']) && isset($hostList[$partitionInfo['leader']])) {
return $hostList[$partitionInfo['leader']];
} else {
throw new Exception('can\'t find broker host.');
}
}