아래 링크에 코드가 정리 되어 있다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kafka.utils.ZkUtils | |
object KafkaTopicTest { | |
def createZkUtils(): ZkUtils = { | |
val zookeepers = "localhost:2181" | |
val timeout = 10000 | |
ZkUtils(zookeepers, timeout, timeout, isZkSecurityEnabled = false) | |
} | |
def getPartitionsForTopics(topics: Seq[String]): Map[String, Seq[Int]] = { | |
zkUtils.getPartitionsForTopics(topics).toMap | |
} | |
def getPartitionsForTopic(topic: String): Option[Seq[Int]] = { | |
zkUtils.getPartitionsForTopics(Seq(topic)).get(topic) | |
} | |
def main(args: Array[String]): Unit = { | |
val topicName = args(0) | |
val topicAndPartitionMap = getPartitionsForTopic(topicName) | |
println(topicAndPartitionMap) | |
} | |
} |
https://gist.github.com/starblood/c35a4f70345cbbb5ad20d74d9fbe3f21
'Programming > Scala' 카테고리의 다른 글
Reactive Manifesto (0) | 2016.06.01 |
---|---|
collection 에서 lazy 방식의 view 를 생성하는 방법 (0) | 2016.04.08 |
Merging sequence of Futures of Lists into one Future containing merged list (0) | 2016.03.09 |
scala 공부 자료 (0) | 2015.12.02 |
Scala 병렬 계산을 위한 Blitz library (0) | 2015.11.20 |