zookeeper获取kafka相应分区的offset(java语言)
看kafka在zookeeper的存储路径为 ///consumers/[groupId]/offsets/[topic]/[partitionId] -> long (offset),但是不知道具体怎么取。
求大神帮忙,万分感谢
public List<String> getOffSet(String topic) {
List<String> results = null;
// zookeeper中保存partitions的路径
String partitions = "/consumers/group1/offsets/help/0";
System.out.println(partitions);
///consumers/[groupId]/offsets/[topic]/[partitionId] -> long (offset)
try {
// 获取子节点
results = this.zookeeper.getChildren(partitions, true);
} catch (KeeperException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
return results;
}